PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | List of all members
Arp::Io::Commons::Configuration::TicBase Class Reference

This class is the base class for all predefined Tic elements. More...

#include <TicBase.hpp>

Inheritance diagram for Arp::Io::Commons::Configuration::TicBase:
Inheritance graph

Public Types

using Ptr = std::shared_ptr< TicBase >
 
using ChildPtr = ITicSerializable::Ptr
 
using ChildElements = std::vector< ChildPtr >
 
- Public Types inherited from Arp::Io::Commons::Configuration::ITicSerializable
using Ptr = std::shared_ptr< ITicSerializable >
 

Public Member Functions

 TicBase (const TicBase &arg)=delete
 
 TicBase (TicBase &&arg) noexcept
 Default move constructor.
 
TicBaseoperator= (const TicBase &arg)=delete
 
TicBaseoperator= (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
 
- Public Member Functions inherited from Arp::Io::Commons::Configuration::ITicSerializable
 ITicSerializable (void)=default
 Constructs an ITicSerializable instance.
 
 ITicSerializable (const ITicSerializable &arg)=default
 Copy constructor.
 
 ITicSerializable (ITicSerializable &&arg) noexcept=default
 Move constructor.
 
ITicSerializableoperator= (const ITicSerializable &arg)=default
 Copy-assignment operator.
 
ITicSerializableoperator= (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...
 

Detailed Description

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.

Member Function Documentation

◆ GetChildElements()

const TicBase::ChildElements & Arp::Io::Commons::Configuration::TicBase::GetChildElements ( void  ) const

Returns all childs of this element.

Returns
The childs of this element.

◆ OnReadEnd()

void Arp::Io::Commons::Configuration::TicBase::OnReadEnd ( void  )
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.

◆ ReadTic()

void Arp::Io::Commons::Configuration::TicBase::ReadTic ( TicReader reader)
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.

Parameters
readerThe TicReader to read the Tic content from.

Implements Arp::Io::Commons::Configuration::ITicSerializable.

◆ TryCreateCustomElement()

bool Arp::Io::Commons::Configuration::TicBase::TryCreateCustomElement ( const String elementName,
ChildPtr &  result 
)
virtual

Factory method to create child elements.

Parameters
elementNameName of the child element to create.
resultThe created child element.
Returns
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.

◆ TryCreateElement()

bool Arp::Io::Commons::Configuration::TicBase::TryCreateElement ( const String elementName,
ChildPtr &  result 
)
virtual

Factory method to create child elements.

Parameters
elementNameName of the child element to create.
resultThe created child element.
Returns
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.

◆ TryReadAttribute()

bool Arp::Io::Commons::Configuration::TicBase::TryReadAttribute ( TicReader reader,
const String attributeName 
)
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.

Parameters
readerThe TicReader to read the Tic content from.
attributeNameName of the attribute to read.
Returns
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.

◆ TryReadCustomAttribute()

bool Arp::Io::Commons::Configuration::TicBase::TryReadCustomAttribute ( TicReader reader,
const String attributeName 
)
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.

Parameters
readerThe TicReader to read the Tic content from.
attributeNameName of the attribute to read.
Returns
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.

◆ WriteTic()

void Arp::Io::Commons::Configuration::TicBase::WriteTic ( TicWriter &  writer)
finalvirtual

This method is currently not implemented and should not be used.

Exceptions
NotImplementedExceptionAlways.

Implements Arp::Io::Commons::Configuration::ITicSerializable.


The documentation for this class was generated from the following files: