xentara-plugin v2.0.3
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::model::ElementAttribute Class Referencefinal

A reference to an attribute of a specific Xentara element. More...

#include <xentara/model/ElementAttribute.hpp>

Public Member Functions

 ElementAttribute ()=default
 Constructor for a null reference.
 
 ElementAttribute (const std::weak_ptr< Element > &element, std::weak_ptr< const Attribute > attribute)
 Constructor that sets the element and the attribute.
 
 operator bool () const noexcept
 Boolean operator.
 
auto primaryKey () const -> std::string
 Gets the primary key of the attribute.
 
auto readHandle () const -> data::ReadHandle
 Gets a read handle for the attribute.
 
auto writeHandle () const -> data::WriteHandle
 Gets a write handle for the attribute.
 
auto lockElement () const -> std::shared_ptr< Element >
 Obtains a shared pointer to the element.
 
auto lockAttribute () const -> std::shared_ptr< const Attribute >
 Obtains a shared pointer to the attribute.
 
auto lock () const -> std::pair< std::shared_ptr< Element >, std::shared_ptr< const Attribute > >
 Obtains a shared pointer to both the element and the attribute.
 

Detailed Description

A reference to an attribute of a specific Xentara element.

This is a convenience class that contains a weak reference to an element, and a weak reference to an attribute.

See also
Attribute

Constructor & Destructor Documentation

◆ ElementAttribute() [1/2]

xentara::model::ElementAttribute::ElementAttribute ( )
default

Constructor for a null reference.

This constructor contstruct a null object that does not contain a reference to any elements or attributes. You must assign avalid object to this object before using it.

◆ ElementAttribute() [2/2]

xentara::model::ElementAttribute::ElementAttribute ( const std::weak_ptr< Element > &  element,
std::weak_ptr< const Attribute attribute 
)

Constructor that sets the element and the attribute.

Constructs a reference to a specific attribute of a specific element.

Parameters
elementThe element. This can be a null pointer if and only if attribute is also a null pointer, in which case a null reference is created, and this constructor is equalivalent to the default constructor.
attributeThe attribute. This can be a null pointer if and only if element is also a null pointer, in which case a null reference is created, and this constructor is equalivalent to the default constructor.

Member Function Documentation

◆ lock()

auto xentara::model::ElementAttribute::lock ( ) const -> std::pair<std::shared_ptr<Element>, std::shared_ptr<const Attribute>>

Obtains a shared pointer to both the element and the attribute.

Returns
A shared pointer to the element together with a shared pointer to the attribute. nullptr is returned for either pointer, if the corresponding object has been deleted. For a null (default constructed) reference, { nullptr, nullptr } is returned.

◆ lockAttribute()

auto xentara::model::ElementAttribute::lockAttribute ( ) const -> std::shared_ptr<const Attribute>

Obtains a shared pointer to the attribute.

Returns
A shared pointer to the attribute, or nullptr if the attribute has been deleted. nullptr is also returned for a null (default constructed) reference.

◆ lockElement()

auto xentara::model::ElementAttribute::lockElement ( ) const -> std::shared_ptr<Element>

Obtains a shared pointer to the element.

Returns
A shared pointer to the element, or nullptr if the element has been deleted. nullptr is also returned for a null (default constructed) reference.

◆ operator bool()

xentara::model::ElementAttribute::operator bool ( ) const
explicitnoexcept

Boolean operator.

This operator checks whether the object is not a null reference.

Returns
Returns true if the object contains a reference to an attribute, or false if the object is a null (default constructed) reference.

◆ primaryKey()

auto xentara::model::ElementAttribute::primaryKey ( ) const -> std::string

Gets the primary key of the attribute.

Returns
The primary key of the attribute, in UTF-8 encoding, or an empty string for a null (default constructed) reference.

◆ readHandle()

auto xentara::model::ElementAttribute::readHandle ( ) const -> data::ReadHandle

Gets a read handle for the attribute.

Returns
A read handle for the attrubute, or a default constructed read handle for a null (default constructed) reference.

◆ writeHandle()

auto xentara::model::ElementAttribute::writeHandle ( ) const -> data::WriteHandle

Gets a write handle for the attribute.

Returns
A write handle for the attrubute, or a default constructed write handle for a null (default constructed) reference.