|
|
| auto | element () const noexcept -> const model::Element & |
| | Gets the Xentara element for this skill element.
|
| |
| auto | element () noexcept -> model::Element & |
| | Gets the Xentara element for this skill element.
|
| |
| auto | rootElement () const -> std::shared_ptr< const model::Element > |
| | Returns the invisible root element of the model this element belongs to.
|
| |
| auto | rootElement () -> std::shared_ptr< model::Element > |
| | Returns the invisible root element of the model this element belongs to.
|
| |
|
| auto | findAttribute (std::string_view primaryKey) -> model::ElementAttribute |
| | Finds the attribute with a specific primary key in the model this element belongs to.
|
| |
| auto | findAttributeVerbose (std::string_view primaryKey) -> utils::eh::expected< model::ElementAttribute, std::string > |
| | Finds the attribute with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findEvent (std::string_view primaryKey) const -> std::shared_ptr< const process::Event > |
| | Finds the event with a specific primary key in the model this element belongs to.
|
| |
| auto | findEvent (std::string_view primaryKey) -> std::shared_ptr< process::Event > |
| | Finds the event with a specific primary key in the model this element belongs to.
|
| |
| auto | findEventVerbose (std::string_view primaryKey) const -> utils::eh::expected< std::shared_ptr< const process::Event >, std::string > |
| | Finds the event with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findEventVerbose (std::string_view primaryKey) -> utils::eh::expected< std::shared_ptr< process::Event >, std::string > |
| | Finds the event with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findExtendedEvent (std::string_view primaryKey) const -> process::ExtendedEvent |
| | Finds the extended event with a specific primary key in the model this element belongs to.
|
| |
| auto | findExtendedEventVerbose (std::string_view primaryKey) const -> utils::eh::expected< process::ExtendedEvent, std::string > |
| | Finds the extended event with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findTask (std::string_view primaryKey) const -> std::shared_ptr< const process::Task > |
| | Finds the task with a specific primary key in the model this element belongs to.
|
| |
| auto | findTask (std::string_view primaryKey) -> std::shared_ptr< process::Task > |
| | Finds the task with a specific primary key in the model this element belongs to.
|
| |
| auto | findTaskVerbose (std::string_view primaryKey) const -> utils::eh::expected< std::shared_ptr< const process::Task >, std::string > |
| | Finds the task with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findTaskVerbose (std::string_view primaryKey) -> utils::eh::expected< std::shared_ptr< process::Task >, std::string > |
| | Finds the task with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findElement (std::string_view primaryKey) const -> std::shared_ptr< const model::Element > |
| | Finds the element with a specific primary key in the model this element belongs to.
|
| |
| auto | findElement (std::string_view primaryKey) -> std::shared_ptr< model::Element > |
| | Finds the element with a specific primary key in the model this element belongs to.
|
| |
| auto | findElementVerbose (std::string_view primaryKey) const -> utils::eh::expected< std::shared_ptr< const model::Element >, std::string > |
| | Finds the element with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findElementVerbose (std::string_view primaryKey) -> utils::eh::expected< std::shared_ptr< model::Element >, std::string > |
| | Finds the element with a specific primary key in the model this element belongs to, returning an error message on error.
|
| |
| auto | findElement (const utils::core::Uuid &uuid) const -> std::shared_ptr< const model::Element > |
| | Finds the element with a specific UUID in the model this element belongs to.
|
| |
| auto | findElement (const utils::core::Uuid &uuid) -> std::shared_ptr< model::Element > |
| | Finds the element with a specific UUID in the model this element belongs to.
|
| |
|
| auto | securityContext () const -> const security::Context & |
| | Returns the security context of the element.
|
| |
| auto | checkAccess (const security::Authorization &authorization, const security::Entitlement &entitlement) const -> bool |
| | Checks an authorization for a certain entitlement using the ACL for this element.
|
| |
Base class for elements provided by a Xentara skill.
- Examples
- LoadingElementConfig.cpp, and PublishingConfigAttributes.cpp.
Called by the framework to create a new child element of this element.
The implementation for this method must use the given factory to create a new element of the given element class:
return factory.makeShared<MyChildElement>();
If your element requires access to the child element later, you must store an std::weak_ptr to it somewhere.
The framework will call load() on the newly created element.
- Default Implementation
- The default implementation returns nullptr, denoting that the element does not support child elements.
- Parameters
-
| elementClass | The class for the new element |
| factory | The factory that must be used to create the element |
- Returns
- The newly created element, or nullptr if the element does not support child elements of the given class
- Exceptions
-
| std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- See also
- Creating Skill Element Objects
Called by the framework to iterate over all the attributes.
Implementations must call the given function once for each custom attribute, until the function returns true. If the function returns true for any attribute, the implementation must return true, otherwise false. A possible implementation looks like this:
{
return
function(myGlobalCustomAttribute);
function(mySharedCustomAttribute);
}
static const Role kError
The role for an error.
Definition Attribute.hpp:290
static const std::string_view kAddress
The standard name for an address.
Definition Attribute.hpp:300
A function object used to iterate over all the attributes of an element.
Definition ForEachAttributeFunction.hpp:25
virtual auto forEachAttribute(const model::ForEachAttributeFunction &function) const -> bool
Called by the framework to iterate over all the attributes.
Usually, attributes are defined as members at global or namespace scope, or as static member variables. For such attributes, you can just pass a reference to the attribute to the function. The same goes for attributes that are members of your skill object, or of any other object that never gets destroyed until Xentara shuts down.
Sometimes, however, an attribute will be a member of an element class, or be dynamically created in some other way. In that case, you need to call the function using a shared pointer to the attribute. This ensures that the attribute will not be destroyed while another element is accessing it. To create a shared pointer to an attribute, either make the attribute itself a shared object by creating it using std::make_shared, or make it a member of another shared object, and use the aliasing constructor (8) of std::shared_ptr to create a shared pointer to the attribute from a pointer to the containing object. If the attribute is a member of your element class, derive the element class from EnableSharedFromThis and use sharedFromThis<Alias>() to create the shared pointer.
In the following example, the element published two standard attributes, and one attribute that is a member of the element class:
{
return
function(sharedFromThis(&myValueAttribute));
}
static const Attribute kQuality
The attribute for the quality of a value.
Definition Attribute.hpp:278
static const Attribute kUpdateTime
The attribute for the update time stamp of a value.
Definition Attribute.hpp:272
The implementation must not call the function with the standard attributes model::Attribute::kPrimaryKey, model::Attribute::kName, and model::Attribute::kUuid, as these are handled automatically by the framework.
This callback is always called after all Xentara model elements references have been resolved. This means that when this function is called, all references to Xentara model elements you submitted in load() have already been resolved.
- Default Implementation
- The default implementation returns false, denoting that there are no custom attributes.
- Parameters
-
| function | The function that should be called for each attribute |
- Exceptions
-
| std::runtime_error | The function may throw this exception (or a suitable subclass) if an error occurs. |
- Examples
- PublishingConfigAttributes.cpp.
Called by the framework to iterate over all the events.
Implementations must call the given function once for each event, until the function returns true. If the function returns true for any event, the implementation must return true, otherwise false. A possible implementation looks like this:
{
using namespace std::literals;
return
function("c78470d1-ca76-4c02-af7a-ac4c5ac7ea82"_uuid, "myCustomEvent"sv, myCustomEvent);
}
static const Attribute kDeviceState
The attribute for the state of a device.
Definition Attribute.hpp:280
A function object used to iterate over all the events of an element.
Definition ForEachEventFunction.hpp:17
static const Role kConnected
The standard role for the connection event of an I/O component.
Definition Event.hpp:272
virtual auto forEachEvent(const model::ForEachEventFunction &function) -> bool
Called by the framework to iterate over all the events.
If the events are not shared object itself, but regular member variables, you can derive your element class from EnableSharedFromThis and use sharedFromThis<Alias>() to create shared pointers to the events:
{
using namespace std::literals;
return
function("c78470d1-ca76-4c02-af7a-ac4c5ac7ea82"_uuid, "myCustomEvent"sv, sharedFromThis(&myCustomEvent));
}
You can also use the aliasing constructor (8) of std::shared_ptr to create a shared pointer to an event that is a member of a shared object not derived from EnableSharedFromThis.
This callback is always called after all Xentara model elements references have been resolved. This means that when this function is called, all references to Xentara model elements you submitted in load() have already been resolved.
- Attention
- This function is non-const only to allow you to call function with member variables of this. The implementation must not have any side-effects that modify this element object.
- Default Implementation
- The default implementation returns false, denoting that there are no custom events.
- Parameters
-
| function | The function that should be called for each event |
- Exceptions
-
| std::runtime_error | The function may throw this exception (or a suitable subclass) if an error occurs. |
Called by the framework to iterate over all the tasks.
Implementations must call the given function once for each task, until the function returns true. If the function returns true for any task, the implementation must return true, otherwise false. A possible implementation looks like this:
{
using namespace std::literals;
return
function("myTask1"sv, "e9cc34eb-4e40-434d-8865-994391999c0a"_uuid, myTask1) ||
function("myTask2"sv, "5e394548-1528-4439-95f6-756a7b7c20f1"_uuid, myTask2) ||
function("myTask3"sv, "a9e0c04c-cb14-4c99-8c89-8e0f1ddf5f1d"_uuid, myTask3);
}
A function object used to iterate over all the tasks of an element.
Definition ForEachTaskFunction.hpp:17
virtual auto forEachTask(const model::ForEachTaskFunction &function) -> bool
Called by the framework to iterate over all the tasks.
If the tasks are not shared object itself, but regular member variables, you can derive your element class from EnableSharedFromThis and use sharedFromThis<Alias>() to create shared pointers to the tasks:
{
using namespace std::literals;
auto sharedThis = sharedFromThis();
return
function("myTask1"sv, "e9cc34eb-4e40-434d-8865-994391999c0a"_uuid, sharedFromThis(&myTask1)) ||
function("myTask2"sv, "5e394548-1528-4439-95f6-756a7b7c20f1"_uuid, sharedFromThis(&myTask2)) ||
function("myTask3"sv, "a9e0c04c-cb14-4c99-8c89-8e0f1ddf5f1d"_uuid, sharedFromThis(&myTask3));
}
You can also use the aliasing constructor (8) of std::shared_ptr to create a shared pointer to a task that is a member of a shared object not derived from EnableSharedFromThis.
This callback is always called after all Xentara model elements references have been resolved. This means that when this function is called, all references to Xentara model elements you submitted in load() have already been resolved.
- Attention
- This function is non-const only to allow you to call function with member variables of this. The implementation must not have any side-effects that modify this element object.
- Default Implementation
- The default implementation returns false, denoting that there are no custom tasks.
- Parameters
-
| function | The function that should be called for each task |
- Exceptions
-
| std::runtime_error | The function may throw this exception (or a suitable subclass) if an error occurs. |
| virtual auto xentara::skill::Element::prepare |
( |
| ) |
-> void |
|
privatevirtual |
Called by the framework to prepare the element for operation.
This method is called by the framework after all objects have been realized, but before any processing is done. It allows you to prepare the object for operation. This is the place where read and write handles for attributes should be fetched, for example.
This method is called before the prepare() method of any child elements. You can override postPrepare() if you need to perform actions after all child elements have been prepared.
- Exceptions
-
| std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- Default Implementation
- The default implementation does nothing.
- See also
- Loading Element Configs
| virtual auto xentara::skill::Element::realize |
( |
| ) |
-> void |
|
privatevirtual |
Called by the framework once all references have been resolved.
This method is called by the framework after the configuration has been completely loaded and all references have been resolved, but before the objects are prepared for processing. Use this function to perform initialization that requires access to the objects you submitted to the resolver in load().
This method is called before the realize() method of any child elements. You can override postRealize() if you need to perform actions after all child elements have been realized.
- Exceptions
-
| std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- Default Implementation
- The default implementation does nothing.
- See also
- Loading Element Configs
Returns the invisible root element of the model this element belongs to.
The invisible root element is the parent element of all top-level elements in the model. It does not have a name, a primary key, attributes, events, or tasks. The only thing the invisible root element can be used for is accessing its children using childElements() or forEachChildElement(), and getting its uuid().
- Returns
- The invisible root element of the model.
- See also
- model::Element::rootElement();
Returns the invisible root element of the model this element belongs to.
The invisible root element is the parent element of all top-level elements in the model. It does not have a name, a primary key, attributes, events, or tasks. The only thing the invisible root element can be used for is accessing its children using childElements() or forEachChildElement(), and getting its uuid().
- Returns
- The invisible root element of the model.
- See also
- model::Element::rootElement();