Base class for driver specific I/O points.
More...
#include <io/Io.hpp>
Base class for driver specific I/O points.
- See also
- I/O Points
-
I/O Points in the Xentara user manual
◆ ConfigIntializer
Type alias for an initializer for the configuration.
◆ ~Io()
◆ cleanup()
virtual auto xentara::io::Io::cleanup |
( |
| ) |
-> void |
|
protectedvirtual |
Called by the framework to cleanup the I/O point after operation.
This method is called by the framework after Xentara has completely shut down.
- Default Implementation
- The default implementation does nothing.
◆ configBlock()
Gets the memory block that the configuration is stored in.
◆ dataType()
virtual auto xentara::io::Io::dataType |
( |
| ) |
const -> const data::DataType & |
|
pure virtual |
Gets the data type of the I/O point.
◆ directions()
virtual auto xentara::io::Io::directions |
( |
| ) |
const -> Directions |
|
pure virtual |
Gets the directions supported by the I/O point.
◆ loadConfig()
Called by the framework to load the I/O point's configuration from a JSON object.
- Parameters
-
initializer | An initializer object for the memory block that contains the configuration. Use this object to access the storage for any configuration attributes you added to the config() array in the I/O point class. |
jsonObject | The JSON object |
resolver | An object that allows you to resolve cross references |
fallbackHandler | An object that handles config parameters unknown to the sub class. You should call the function call operator of this object for any config parameters you do not recognize. |
- Exceptions
-
std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- See also
- Loading Element Configs
- Examples
- LoadingElementConfig.cpp
◆ name()
Gets the name of the I/O point.
- Note
- The name is only known once the configuration of the I/O point has been loaded.
- Returns
- The name of the I/O point, in UTF-8 encoding.
◆ prepare()
virtual auto xentara::io::Io::prepare |
( |
| ) |
-> void |
|
protectedvirtual |
Called by the framework to prepare the I/O point 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.
- 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
◆ primaryKey()
auto xentara::io::Io::primaryKey |
( |
| ) |
const -> std::string |
Gets the primary key of the I/O point.
- Note
- The primary key is only fully known once the entire configuration has been loaded.
- Returns
- The primary key of the I/O point, in UTF-8 encoding.
◆ readHandle()
Called by the framework to get a read handle for a specific attribute.
The implementation for this method must return a read handle for the given attribute's value.
- Default Implementation
- The default implementation returns an error handle with error data::ReadHandle::Error::Unknown.
- Parameters
-
attribute | The desired attribute. This will never be one of the standard configuration attributes, as these are handled automatically by the framework. |
- Returns
- A read handle for the attribute, or an error handle with an appropriate error code on error
- See also
- Publishing Attributes
- Examples
- PublishingConfigAttributes.cpp
◆ realize()
virtual auto xentara::io::Io::realize |
( |
| ) |
-> void |
|
protectedvirtual |
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 loadConfig().
- 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
◆ resolveAttribute()
Called by the framework to resolve an attribute with a specific name.
The implementation for this method must return a reference to the attribute with the given name, if the I/O point supports it.
Attributes are always resolved after Xentara model elements. This means that when this function is called, all references to Xentara model elements you submitted in loadConfig() have already been resolved.
- Default Implementation
- The default implementation returns nullptr, denoting that the I/O point does not provide an attribute with the given name.
- Parameters
-
name | The name of the desired attribute, in UTF-8 encoding. This will never be one of the standard configuration attributes, as these are resolved automatically by the framework. |
- Returns
- A pointer to the attribute description, or nullptr if the I/O point does not provide an attribute with the given name
- Exceptions
-
std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- See also
- Publishing Attributes
- Examples
- PublishingConfigAttributes.cpp
◆ resolveEvent()
Called by the framework to resolve an event with a specific name.
The implementation for this method must return a pointer to the event with the given name. You can either create the event on demand from within this function, or return a pointer to an existing event.
If the event you which to return is not a shared object itself, but a regular member of the I/O point, you can derive your I/O point class from xentara::plugin::EnableSharedFromThis and use the aliasing constructor (8) of std::shared_ptr together with sharedFromThis():
Events are always resolved after Xentara model elements. This means that when this function is called, all references to Xentara model elements you submitted in loadConfig() have already been resolved.
- Default Implementation
- The default implementation returns nullptr, denoting that the I/O point does not provide an event with the given name.
- Parameters
-
name | The name of the desired event, in UTF-8 encoding |
- Returns
- A pointer to the event, or nullptr if the I/O point does not provide an event with the given name
- Exceptions
-
std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- See also
- Publishing Events
◆ resolveTask()
Called by the framework to resolve a task with a specific name.
The implementation for this method must return a pointer to the task with the given name. You can either create the task on demand from within this function, or return a pointer to an existing task.
If the task you which to return is not a shared object itself, but a regular member of the I/O point, you can derive your I/O point class from xentara::plugin::EnableSharedFromThis and use the aliasing constructor (8) of std::shared_ptr together with sharedFromThis():
Tasks are always resolved after Xentara model elements. This means that when this function is called, all references to Xentara model elements you submitted in loadConfig() have already been resolved.
- Default Implementation
- The default implementation returns nullptr, denoting that the I/O point does not provide a task with the given name.
- Parameters
-
name | The name of the desired task, in UTF-8 encoding |
- Returns
- A pointer to the task, or nullptr if the I/O point does not provide a task with the given name
- Exceptions
-
std::runtime_error | The function must throw this exception (or a suitable subclass) if an error occurs |
- See also
- Publishing Tasks
◆ uuid()
Gets the UUID of the I/O point.
- Note
- The UUID is only known once the configuration of the I/O point has been loaded.
◆ writeHandle()
Called by the framework to get a write handle for a specific attribute.
The implementation for this method must return a write handle for the given attribute's value.
- Default Implementation
- The default implementation returns an error handle with error data::WriteHandle::Error::Unknown.
- Parameters
-
attribute | The desired attribute. This will never be one of the standard configuration attributes, as these are handled automatically by the framework. |
- Returns
- A write handle for the attribute, or an error handle with an appropriate error code on error
- See also
- Publishing Attributes