xentara-plugin v1.2.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::io::IoBatch Class Referenceabstract

An I/O batch in a Xentara system. More...

#include <io/IoBatch.hpp>

+ Inheritance diagram for xentara::io::IoBatch:

Classes

class  FallbackConfigHandler
 A helper object used to handle config parameters unknown to the sub class. More...
 

Public Member Functions

virtual internal ~IoBatch ()=0
 Virtual destructor.
 
auto name () const -> std::string
 Gets the name of the I/O batch.
 
auto primaryKey () const -> std::string
 Gets the primary key of the I/O batch.
 
auto uuid () const -> utils::core::Uuid
 Gets the UUID of the I/O batch.
 
virtual auto resolveAttribute (std::string_view name) -> const model::Attribute *
 Called by the framework to resolve an attribute with a specific name.
 
virtual auto resolveTask (std::string_view name) -> std::shared_ptr< process::Task >
 Called by the framework to resolve a task with a specific name.
 
virtual auto resolveEvent (std::string_view name) -> std::shared_ptr< process::Event >
 Called by the framework to resolve an event with a specific name.
 
virtual auto readHandle (const model::Attribute &attribute) const noexcept -> data::ReadHandle
 Called by the framework to get a read handle for a specific attribute.
 
virtual auto writeHandle (const model::Attribute &attribute) noexcept -> data::WriteHandle
 Called by the framework to get a write handle for a specific attribute.
 
- Public Member Functions inherited from xentara::utils::tools::DisableCopy
constexpr DisableCopy () noexcept=default
 
 DisableCopy (const DisableCopy &)=delete
 
DisableCopyoperator= (const DisableCopy &)=delete
 

Protected Types

using ConfigIntializer = memory::Initializer< memory::Array >
 Type alias for an initializer for the configuration.
 

Protected Member Functions

virtual auto loadConfig (const ConfigIntializer &initializer, utils::json::decoder::Object &jsonObject, config::Resolver &resolver, const FallbackConfigHandler &fallbackHandler) -> void=0
 Called by the framework to load the I/o batch's configuration from a JSON object.
 
virtual auto realize () -> void
 Called by the framework once all references have been resolved.
 
virtual auto prepare () -> void
 Called by the framework to prepare the I/O batch for operation.
 
virtual auto cleanup () -> void
 Called by the framework to cleanup the I/O batch after operation.
 
auto configBlock () const noexcept -> const memory::ArrayBlock &
 Gets the memory block that the configuration is stored in.
 

Detailed Description

An I/O batch in a Xentara system.

I/O batches are used to group together I/O points that have common attributes, or that are handled together as a unit. Examples include database queries, polls, transactions, etc.

See also
I/O Batches
I/O Batches in the Xentara user manual

Member Typedef Documentation

◆ ConfigIntializer

Type alias for an initializer for the configuration.

Constructor & Destructor Documentation

◆ ~IoBatch()

xentara::io::IoBatch::~IoBatch ( )
pure virtualdefault

Virtual destructor.

Member Function Documentation

◆ cleanup()

virtual auto xentara::io::IoBatch::cleanup ( ) -> void
protectedvirtual

Called by the framework to cleanup the I/O batch after operation.

This method is called by the framework after Xentara has completely shut down.

Default Implementation
The default implementation does nothing.

◆ configBlock()

auto xentara::io::IoBatch::configBlock ( ) const -> const memory::ArrayBlock &
protectednoexcept

Gets the memory block that the configuration is stored in.

◆ loadConfig()

virtual auto xentara::io::IoBatch::loadConfig ( const ConfigIntializer initializer,
utils::json::decoder::Object jsonObject,
config::Resolver resolver,
const FallbackConfigHandler fallbackHandler 
) -> void
protectedpure virtual

Called by the framework to load the I/o batch's configuration from a JSON object.

Parameters
initializerAn 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 batch class.
jsonObjectThe JSON object
resolverAn object that allows you to resolve cross references
fallbackHandlerAn 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_errorThe function must throw this exception (or a suitable subclass) if an error occurs
See also
Loading Element Configs
Examples
LoadingElementConfig.cpp

◆ name()

auto xentara::io::IoBatch::name ( ) const -> std::string

Gets the name of the I/O batch.

Note
The name is only known once the configuration of the I/O batch has been loaded.
Returns
The name of the I/O batch, in UTF-8 encoding.

◆ prepare()

virtual auto xentara::io::IoBatch::prepare ( ) -> void
protectedvirtual

Called by the framework to prepare the I/O batch 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_errorThe 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::IoBatch::primaryKey ( ) const -> std::string

Gets the primary key of the I/O batch.

Note
The primary key is only fully known once the entire configuration has been loaded.
Returns
The primary key of the I/O batch, in UTF-8 encoding.

◆ readHandle()

virtual auto xentara::io::IoBatch::readHandle ( const model::Attribute attribute) const -> data::ReadHandle
virtualnoexcept

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
attributeThe 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::IoBatch::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_errorThe 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()

virtual auto xentara::io::IoBatch::resolveAttribute ( std::string_view  name) -> const model::Attribute *
virtual

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 batch 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 batch does not provide an attribute with the given name.
Parameters
nameThe 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 batch does not provide an attribute with the given name
Exceptions
std::runtime_errorThe function must throw this exception (or a suitable subclass) if an error occurs
See also
Publishing Attributes

◆ resolveEvent()

virtual auto xentara::io::IoBatch::resolveEvent ( std::string_view  name) -> std::shared_ptr< process::Event >
virtual

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 batch, you can derive your I/O batch class from xentara::plugin::EnableSharedFromThis and use the aliasing constructor (8) of std::shared_ptr together with sharedFromThis():

return std::shared_ptr(sharedFromThis(), &_myEvent);

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 batch does not provide an event with the given name.
Parameters
nameThe name of the desired event, in UTF-8 encoding
Returns
A pointer to the event, or nullptr if the I/O batch does not provide an event with the given name
Exceptions
std::runtime_errorThe function must throw this exception (or a suitable subclass) if an error occurs
See also
Publishing Events

◆ resolveTask()

virtual auto xentara::io::IoBatch::resolveTask ( std::string_view  name) -> std::shared_ptr< process::Task >
virtual

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 batch, you can derive your I/O batch class from xentara::plugin::EnableSharedFromThis and use the aliasing constructor (8) of std::shared_ptr together with sharedFromThis():

return std::shared_ptr(sharedFromThis(), &_myTask);

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 batch does not provide a task with the given name.
Parameters
nameThe name of the desired task, in UTF-8 encoding
Returns
A pointer to the task, or nullptr if the I/O batch does not provide a task with the given name
Exceptions
std::runtime_errorThe function must throw this exception (or a suitable subclass) if an error occurs
See also
Publishing Tasks
Examples
PublishingConfigAttributes.cpp

◆ uuid()

auto xentara::io::IoBatch::uuid ( ) const -> utils::core::Uuid

Gets the UUID of the I/O batch.

Note
The UUID is only known once the configuration of the I/O batch has been loaded.

◆ writeHandle()

virtual auto xentara::io::IoBatch::writeHandle ( const model::Attribute attribute) -> data::WriteHandle
virtualnoexcept

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
attributeThe 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