PLCnext API Documentation
22.9.0.33
|
Base class for custom Payload classes More...
#include <SpecializedPayload.hpp>
Public Types | |
using | ValueType = RawPayloadType::value_type |
using | FieldType = Arp::System::Rsc::Services::RscType |
Public Member Functions | |
SpecializedPayload (const Notification ¬ification) | |
Creates a view on a Notification object More... | |
SpecializedPayload (const GenericPayload &payloadArg) | |
Creates a view on a GenericPayload object More... | |
PayloadTypeIdType | GetId () const final |
Returns the PayloadTypeId More... | |
const String | GetName () const final |
Returns the PayloadTypeName More... | |
const RawPayloadType & | GetAsRawPayloadType () const final |
Returns a reference to the raw payload object More... | |
const String | ToString () const override |
Get a human readable string representation More... | |
RawPayloadType && | MoveOutRawPayload () |
bool | IsReadOnly () const |
Returns true if this object is a view on a Payload More... | |
Static Public Member Functions | |
static PayloadTypeIdType | GetPayloadTypeId () |
Returns the PayloadTypeId More... | |
static const String | GetPayloadTypeName () |
Returns the PayloadType name More... | |
Protected Member Functions | |
SpecializedPayload (const String &formatString) | |
Creates a SpecializedPayload with an format string More... | |
void | SetFormatString (const String &formatString) |
template<typename T , typename std::enable_if<(!std::is_same< T, String >::value)&&(!std::is_enum< T >::value) >::type * = nullptr> | |
size_t | AddField () |
Adds a payload field More... | |
template<typename T , typename std::enable_if< std::is_same< T, String >::value||std::is_enum< T >::value >::type * = nullptr> | |
size_t | AddField () |
Adds a payload field More... | |
template<typename T , typename std::enable_if< !std::is_enum< T >::value >::type * = nullptr> | |
void | SetFieldValue (size_t fieldIndex, const T &value) |
Sets the value of a payload field More... | |
template<typename T , typename std::enable_if< std::is_enum< T >::value >::type * = nullptr> | |
void | SetFieldValue (size_t fieldIndex, T value) |
Sets the value of a payload field More... | |
template<typename T , typename std::enable_if< !std::is_enum< T >::value >::type * = nullptr> | |
const T | GetFieldValueAs (size_t fieldIndex) const |
Gets a field value with the specified type More... | |
template<typename T , typename std::enable_if< std::is_enum< T >::value >::type * = nullptr> | |
const T | GetFieldValueAs (size_t fieldIndex) const |
Gets a field value with the specified type More... | |
size_t | GetFieldCount () const |
Gets the number of fields in the payload More... | |
Static Protected Member Functions | |
static size_t | FieldIndexToFormatStringIndex (size_t fieldIndex) |
Friends | |
class | LongStringPayloadField |
Base class for custom Payload classes
Derive from this class to implement a custom notification payload.
Do not change the order of the defined payload fields. Otherwise the fields could be intepreted wrong resulting in exceptions.
Typically a derived class contains a member to store the field index for each payload field. The AddField method should be called using direct member initialization so these calls are generated by the compiler for all constructors. The constructors of this base class should be made avaibale by a using directive. (using SpecializedPaylod::SpecializedPayload;)
Implement a constructor of the derived class taking the payload field values as arguments and use SetFieldValue to store them.
Added Get methods to return the payload field with the correct type.
|
explicit |
Creates a view on a Notification object
The Notification is just referenced so it must stay alive to avoid dangling references.
|
explicit |
Creates a view on a GenericPayload object
The GenericPayload is just referenced so it must stay alive to avoid dangling references.
|
explicitprotected |
Creates a SpecializedPayload with an format string
formatString | Formatstring to generate a huiman readable representation |
|
inlineprotected |
Adds a payload field
The type of the field is defined by the template parameter T.
|
inlineprotected |
Adds a payload field
The type of the field is defined by the template parameter T. Specialization for strings and enumerations. Enumerations are stored as strings to enable human readability.
|
finalvirtual |
Returns a reference to the raw payload object
The reference object must not be destroyed while the reference is used!
Implements Arp::System::Nm::IPayload.
|
protected |
Gets the number of fields in the payload
|
inlineprotected |
Gets a field value with the specified type
fieldIndex | index of the field to get |
|
inlineprotected |
Gets a field value with the specified type
fieldIndex | index of the field to get |
Specialization for enumerations. Enumerations are stored as strings to enable human readability.
|
finalvirtual |
Returns the PayloadTypeId
Implements Arp::System::Nm::IPayload.
|
finalvirtual |
Returns the PayloadTypeName
Implements Arp::System::Nm::IPayload.
|
static |
Returns the PayloadTypeId
This funtion uses the NotificationManager internally to query the id.
|
static |
Returns the PayloadType name
The payload type name is generated from the class name
bool Arp::System::Nm::SpecializedPayload< PayloadType >::IsReadOnly |
Returns true if this object is a view on a Payload
|
inlineprotected |
Sets the value of a payload field
fieldIndex | index of the field to set |
value | new value |
|
inlineprotected |
Sets the value of a payload field
fieldIndex | index of the field to set |
value | new value |
Specialization for enumerations. Enumerations are stored as strings to enable human readability.
|
protected |
< summary>Sets the formatString This function should only be used, if the FormatString cannot be determined as a constructor parameter. summary>Retuns the index in the format string for a given payload field
|
overridevirtual |
Get a human readable string representation
Implements Arp::System::Nm::IPayload.