PLCnext API Documentation 25.0.2.69
|
This class is the base class for all predefined Tic elements. More...
#include <TicBase.hpp>
Public Types | |
using | Ptr = std::shared_ptr< TicBase > |
using | ChildPtr = ITicSerializable::Ptr |
using | ChildElements = std::vector< ChildPtr > |
![]() | |
using | Ptr = std::shared_ptr< ITicSerializable > |
Public Member Functions | |
TicBase (const TicBase &arg)=delete | |
TicBase (TicBase &&arg) noexcept | |
Default move constructor. | |
TicBase & | operator= (const TicBase &arg)=delete |
TicBase & | operator= (TicBase &&arg) noexcept |
Default move-assignment operator. | |
~TicBase (void) override | |
Default destructor. | |
TicBase (void) | |
Default constructor. | |
const ChildElements & | GetChildElements (void) const |
Returns all childs of this element. More... | |
void | ReadTic (TicReader &reader) final |
This operation shall be implemented by all classes which should read its context from Tic files. More... | |
void | WriteTic (TicWriter &writer) final |
This method is currently not implemented and should not be used. More... | |
virtual bool | TryReadAttribute (TicReader &reader, const String &attributeName) |
This operation is called every time an attribute is read. More... | |
virtual bool | TryCreateElement (const String &elementName, ChildPtr &result) |
Factory method to create child elements. More... | |
virtual bool | TryReadCustomAttribute (TicReader &reader, const String &attributeName) |
This operation is called every time an attribute is read. More... | |
virtual bool | TryCreateCustomElement (const String &elementName, ChildPtr &result) |
Factory method to create child elements. More... | |
virtual void | OnReadEnd (void) |
Validates the content of the current element. More... | |
Impl & | GetImpl (void) |
For internal use only. | |
const Impl & | GetImpl (void) const |
![]() | |
ITicSerializable (void)=default | |
Constructs an ITicSerializable instance. | |
ITicSerializable (const ITicSerializable &arg)=default | |
Copy constructor. | |
ITicSerializable (ITicSerializable &&arg) noexcept=default | |
Move constructor. | |
ITicSerializable & | operator= (const ITicSerializable &arg)=default |
Copy-assignment operator. | |
ITicSerializable & | operator= (ITicSerializable &&arg) noexcept=default |
Move-assignment operator. | |
virtual | ~ITicSerializable (void)=default |
Destructs this instance and frees all resources. | |
virtual void | ReadTic (TicReader &reader)=0 |
This operation shall be implemented to read the content from Tic documents. More... | |
virtual void | WriteTic (TicWriter &writer)=0 |
This operation shall be implemented to write the content to Tic documents. More... | |
This class is the base class for all predefined Tic elements.
TicBase reads one tic element. Currently only read operations are implemented. All read sub-elements are stored as child elements as separate instances of type ITicSerializable.
The virtual methods TryReadAttribute, TryCreateElement and OnReadEnd have to be specialized by a derived class to read specific attributes and sub-elements.
For every read attribute from the attribute list it calls TryReadAttribute. This methods should read the attribute value and return true
, except if the value is unknown or should not be evaluated, then false
has to be returned. In this case TicBase skips the value.
For every read sub-element the factory method TryCreateElement is called. If the sub-element is known, the method shall create a new instance of ITicSerializable and returns true
. If the subelement is unknown or should be skipped false
shall be returned.
After all attributes and sub-element have been read, the method OnReadEnd will be called. This method should be used, to do some post processing and validation checks. Here could be checked for example, if all mandatory attributes has been read.
const TicBase::ChildElements & Arp::Io::Commons::Configuration::TicBase::GetChildElements | ( | void | ) | const |
Returns all childs of this element.
|
virtual |
Validates the content of the current element.
This method is called after all sub-elements and attributes have been read. It might be used to check if all mandatory elements/attributes have been read and are valid.
Reimplemented in Arp::Io::Commons::Configuration::TicPorts, Arp::Io::Commons::Configuration::TicFrame, Arp::Io::Commons::Configuration::TicFrames, and Arp::Io::Commons::Configuration::TicPort.
|
finalvirtual |
This operation shall be implemented by all classes which should read its context from Tic files.
This method reads the base structure of the current Tic element. It reads the attribute and element list. For every read attribute the method TryReadAttribute is called, to read its content. For every child element a child shall be created by using the factory method TryCreateElement. After all attributes and elements are evaluated the method OnReadEnd is called to check the consistency of the read element.
reader | The TicReader to read the Tic content from. |
Implements Arp::Io::Commons::Configuration::ITicSerializable.
|
virtual |
Factory method to create child elements.
elementName | Name of the child element to create. |
result | The created child element. |
true
if the element was created, false
if the element should be skipped.The default implementation of this class always returns false
to skip all elements besides a Tic frames element. If a Tic frames element (called 'IO:Frames') is read, an element of type TicFrames is created by default. This method returns false
by default and should be overloaded by a cunstomized tic element class if needed.
|
virtual |
Factory method to create child elements.
elementName | Name of the child element to create. |
result | The created child element. |
true
if the element was created, false
if the element should be skipped.The default implementation of this class always returns false
to skip all elements besides a Tic frames element. If a Tic frames element (called 'IO:Frames') is read, an element of type TicFrames is created by default.
Reimplemented in Arp::Io::Commons::Configuration::TicFrame, Arp::Io::Commons::Configuration::TicFrames, Arp::Io::Commons::Configuration::TicPort, and Arp::Io::Commons::Configuration::TicPorts.
|
virtual |
This operation is called every time an attribute is read.
This operation should read the attribute value from the given TicReader. If the element should not be processed, the method shall return false
to skip the read attribute.
reader | The TicReader to read the Tic content from. |
attributeName | Name of the attribute to read. |
true
if the value could be read, or false
if the attribute should be skipped.The default implementation in this class always returns false
to skip all attributes.
Reimplemented in Arp::Io::Commons::Configuration::TicFrame, Arp::Io::Commons::Configuration::TicFrames, Arp::Io::Commons::Configuration::TicPort, and Arp::Io::Commons::Configuration::TicPorts.
|
virtual |
This operation is called every time an attribute is read.
This operation should read the custom attribute value from the given TicReader. If the element should not be processed, the method shall return false
to skip the read attribute. This method returns false
by default and should be overloaded by a cunstomized tic element class if needed.
reader | The TicReader to read the Tic content from. |
attributeName | Name of the attribute to read. |
true
if the value could be read, or false
if the attribute should be skipped.The default implementation in this class always returns false
to skip all attributes.
|
finalvirtual |
This method is currently not implemented and should not be used.
NotImplementedException | Always. |
Implements Arp::Io::Commons::Configuration::ITicSerializable.