9 #include "Arp/System/Core/TypeName.hxx" 10 #include "Arp/System/Commons/Exceptions/ArgumentException.hpp" 11 #include "Arp/System/Nm/GenericPayload.hpp" 12 #include "Arp/System/Nm/IPayload.hpp" 13 #include "Arp/System/Nm/Notification.hpp" 14 #include "Arp/System/Nm/NotificationManager.hpp" 15 #include "Arp/System/Nm/RscVariantHelpers.hpp" 16 #include <type_traits> 18 namespace Arp {
namespace System {
namespace Nm
22 class LongStringPayloadField;
41 template<
typename PayloadType>
47 using ValueType = RawPayloadType::value_type;
93 static size_t FieldIndexToFormatStringIndex(
size_t fieldIndex);
104 template < typename T, typename std::enable_if < !std::is_same<T, String>::value&&
105 !std::is_enum<T>::value >::type* =
nullptr >
108 return this->payload.
AddField(Arp::System::Rsc::Services::GetRscType<T>());
117 template < typename T, typename std::enable_if < std::is_same<T, String>::value ||
118 std::is_enum<T>::value >::type* =
nullptr >
128 template < typename T, typename std::enable_if < !std::is_enum<T>::value >::type* =
nullptr >
131 this->payload.SetFieldValue(fieldIndex, ValueType(value));
139 template<typename T, typename std::enable_if<std::is_enum<T>::value>::type* =
nullptr>
146 catch (
const std::out_of_range&)
150 "The supplied value is not a enumerated value of {}",
TypeName<T>().Value)
159 template < typename T, typename std::enable_if < !std::is_enum<T>::value >::type* =
nullptr >
162 const ValueType& value = this->payload.
GetFieldValue(fieldIndex);
175 template<typename T, typename std::enable_if<std::is_enum<T>::value>::type* =
nullptr>
195 template<
typename PayloadType>
200 template<
typename PayloadType>
204 this->payload.SetFieldValue(this->payload.GetFieldIndexFormatString(), formatString);
208 template<
typename PayloadType>
210 : payload(GetId(), GetName(), notification)
215 template<
typename PayloadType>
217 : payload(GetId(), GetName(), payloadArg.GetAsRawPayloadType())
222 template<
typename PayloadType>
226 template<
typename PayloadType>
232 id = SpecializedPayloadHelper::GetINotificationManagerInfo().GetPayloadTypeId(
233 GetPayloadTypeName());
239 template<
typename PayloadType>
242 return GetPayloadTypeId();
246 template<
typename PayloadType>
253 template<
typename PayloadType>
256 return GetPayloadTypeName();
260 template<
typename PayloadType>
267 template<
typename PayloadType>
273 template<
typename PayloadType>
276 return this->payload.MoveOutRawPayload();
279 template<
typename PayloadType>
286 template<
typename PayloadType>
289 this->payload.
SetFieldValue(this->payload.GetFieldIndexFormatString(), formatString);
293 template<
typename PayloadType>
296 return fieldIndex - 1;
300 template<
typename PayloadType>
static ArgumentException Create(const char *paramName, const T ¶mValue)
Creates an ArgumentException instance using a default message text.
Definition: ArgumentException.hpp:112
const RawPayloadType & GetAsRawPayloadType() const final
Returns a reference to the raw payload object
Definition: SpecializedPayload.hpp:261
String with undefined format. Deprecated with remoting version 4 used by Rsc.
This (meta programming) class provides the C++ typename of the as template argument passed type...
Definition: TypeName.hxx:55
const String GetName() const final
Returns the PayloadTypeName
Definition: SpecializedPayload.hpp:254
Contains meta data and paylod of a Notification
Definition: Notification.hpp:21
void SetFieldValue(size_t fieldIndex, const T &value)
Sets the value of a payload field
Definition: SpecializedPayload.hpp:129
PayloadTypeIdType GetId() const final
Returns the PayloadTypeId
Definition: SpecializedPayload.hpp:240
Interface for Paylo objects
Definition: IPayload.hpp:18
static Enum Parse(const char *input)
Parses the given input string.
Definition: Enum.hxx:190
size_t AddField(FieldType type)
Adds a field with the given FieldType
void SetFieldValue(size_t fieldIndex, T value)
Sets the value of a payload field
Definition: SpecializedPayload.hpp:140
void SetFormatString(const String &formatString)
summary>Retuns the index in the format string for a given payload field
Definition: SpecializedPayload.hpp:287
SpecializedPayload(const Notification ¬ification)
Creates a view on a Notification object
Definition: SpecializedPayload.hpp:209
Adapter class for enums to make them loggable and parsable from e.g. XML files.
Definition: Enum.hxx:23
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType. Only supported types of RemotingMarshalType are included.
Definition: RscType.hpp:27
Generic access to a IPayload
Definition: GenericPayload.hpp:18
static PayloadTypeIdType GetPayloadTypeId()
Returns the PayloadTypeId
Definition: SpecializedPayload.hpp:227
Base class for custom Payload classes
Definition: SpecializedPayload.hpp:42
size_t GetFieldCount() const
Gets the number of fields in the payload
Definition: SpecializedPayload.hpp:301
const T GetFieldValueAs(size_t fieldIndex) const
Gets a field value with the specified type
Definition: SpecializedPayload.hpp:160
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
const String ToString() const override
Get a human readable string representation
Definition: SpecializedPayload.hpp:268
Interface for information about the Notification Manager
Definition: INotificationManagerInfo.hpp:20
Root namespace for the PLCnext API
const ValueType & GetFieldValue(size_t fieldIndex) const
Returns the raw value of a field
T rscvariant_cast(const Rsc::Services::RscVariant< N > &value)
Casts an RscVariant to T
Definition: RscVariantHelpers.hpp:56
bool IsReadOnly() const
Returns true if this object is a view on a Payload
Definition: SpecializedPayload.hpp:280
static const String GetPayloadTypeName()
Returns the PayloadType name
Definition: SpecializedPayload.hpp:247
System components used by the System, Device, Plc or Io domains.
Helper class to get access to INotificationManagerInfo
Definition: SpecializedPayload.hpp:191
size_t AddField()
Adds a payload field
Definition: SpecializedPayload.hpp:106
Definition: LongStringPayloadField.hpp:16