PLCnext API Documentation 23.0.2.9
GenericPayload.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
9#include "Arp/System/Nm/IPayload.hpp"
10#include "Arp/System/Nm/Notification.hpp"
11
12
13namespace Arp { namespace System { namespace Nm
14{
15
16
19{
20public: // typedefs
21 using ValueType = RawPayloadType::value_type;
23
24private: // typedefs
25 using FieldInfos = std::vector<FieldType>;
26
27public: // construction/destruction
31 explicit GenericPayload(const Notification& notification);
32
35
37 GenericPayload(PayloadTypeIdType id, const String& name, const RawPayloadType& payloadArg);
38
40 GenericPayload(PayloadTypeIdType id, const String& name, const Notification& notification);
41
42 ~GenericPayload() override = default;
43
44public: // operations
45 // Methods of IPayload
46 PayloadTypeIdType GetId() const override;
47 const String GetName() const override;
48 const RawPayloadType& GetAsRawPayloadType() const override;
49 const String ToString() const override;
50
51 RawPayloadType&& MoveOutRawPayload();
52
53
55 bool IsReadOnly() const;
56
58 size_t GetFieldCount() const;
59
62 const ValueType& GetFieldValue(size_t fieldIndex) const;
63
66 FieldType GetFieldType(size_t fieldIndex) const;
67
70
73 size_t AddField(FieldType type);
74 void SetFieldValue(size_t fieldIndex, const ValueType& value);
75
76private: // methods
77 void InitializeFields();
78 bool HasAssociatedNotification() const;
79 bool CanFieldBeAdded() const;
80 const String FormatValue(const String& formatString, const ValueType& value) const;
81
82private: // fields
84 String Name;
85 const Notification* NotificationPtr = nullptr;
86 RawPayloadType Payload;
87 FieldInfos Fields;
88 size_t FieldIndexFormatString = 0;
89};
90
91
92}}} // end of namespace Arp::System::Nm
Generic access to a IPayload
Definition: GenericPayload.hpp:19
size_t GetFieldCount() const
Returns the number of fields of the Payload
bool IsReadOnly() const
Returns true if this object is a view to a Notification
FieldType GetFieldType(size_t fieldIndex) const
Returns the FieldType for the given field
const String GetName() const override
Returns the PayloadTypeName
const RawPayloadType & GetAsRawPayloadType() const override
Returns a reference to the raw payload object
GenericPayload(const Notification &notification)
Read only access to a notification
PayloadTypeIdType GetId() const override
Returns the PayloadTypeId
const String ToString() const override
Get a human readable string representation
GenericPayload(PayloadTypeIdType id, const String &name, const Notification &notification)
Manually create a payload
size_t GetFieldIndexFormatString() const
Returnsd the field index of the format string
GenericPayload(PayloadTypeIdType id, const String &name)
Manually create a payload
GenericPayload(PayloadTypeIdType id, const String &name, const RawPayloadType &payloadArg)
Manually create a payload
const ValueType & GetFieldValue(size_t fieldIndex) const
Returns the raw value of a field
size_t AddField(FieldType type)
Adds a field with the given FieldType
Interface for Paylo objects
Definition: IPayload.hpp:19
Contains meta data and paylod of a Notification
Definition: Notification.hpp:22
@ System
System components used by the System, Device, Plc or Io domains.
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
RscType
Data types supported by RSC.
Definition: RscType.hpp:36
Root namespace for the PLCnext API