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);
167 return rscvariant_cast<T>(value);
175 template<typename T, typename std::enable_if<std::is_enum<T>::value>::type* =
nullptr>
195 template<
typename PayloadType>
200 template<
typename PayloadType>
202 : payload(GetId(), GetName())
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>
263 return this->payload.GetAsRawPayloadType();
267 template<
typename PayloadType>
270 return this->payload.ToString();
273 template<
typename PayloadType>
276 return this->payload.MoveOutRawPayload();
279 template<
typename PayloadType>
282 return this->payload.IsReadOnly();
286 template<
typename PayloadType>
289 this->payload.SetFieldValue(this->payload.GetFieldIndexFormatString(), formatString);
293 template<
typename PayloadType>
296 return fieldIndex - 1;
300 template<
typename PayloadType>
303 return this->payload.GetFieldCount();
Adapter class for enums to make them loggable and parsable from e.g. XML files.
Definition: Enum.hxx:23
static ArgumentException Create(const char *paramName, const T ¶mValue)
Creates an ArgumentException instance using a default message text.
Definition: ArgumentException.hpp:112
Generic access to a IPayload
Definition: GenericPayload.hpp:19
const ValueType & GetFieldValue(size_t fieldIndex) const
Returns the raw value of a field
size_t GetFieldIndexFormatString() const
Returnsd the field index of the format string
size_t AddField(FieldType type)
Adds a field with the given FieldType
Interface for information about the Notification Manager
Definition: INotificationManagerInfo.hpp:21
Interface for Paylo objects
Definition: IPayload.hpp:19
Definition: LongStringPayloadField.hpp:17
Contains meta data and paylod of a Notification
Definition: Notification.hpp:22
Helper class to get access to INotificationManagerInfo
Definition: SpecializedPayload.hpp:192
Base class for custom Payload classes
Definition: SpecializedPayload.hpp:43
bool IsReadOnly() const
Returns true if this object is a view on a Payload
Definition: SpecializedPayload.hpp:280
size_t AddField()
Adds a payload field
Definition: SpecializedPayload.hpp:106
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
static const String GetPayloadTypeName()
Returns the PayloadType name
Definition: SpecializedPayload.hpp:247
const RawPayloadType & GetAsRawPayloadType() const final
Returns a reference to the raw payload object
Definition: SpecializedPayload.hpp:261
const String GetName() const final
Returns the PayloadTypeName
Definition: SpecializedPayload.hpp:254
size_t GetFieldCount() const
Gets the number of fields in the payload
Definition: SpecializedPayload.hpp:301
void SetFieldValue(size_t fieldIndex, T value)
Sets the value of a payload field
Definition: SpecializedPayload.hpp:140
void SetFormatString(const String &formatString)
Definition: SpecializedPayload.hpp:287
const T GetFieldValueAs(size_t fieldIndex) const
Gets a field value with the specified type
Definition: SpecializedPayload.hpp:160
const String ToString() const override
Get a human readable string representation
Definition: SpecializedPayload.hpp:268
SpecializedPayload(const Notification ¬ification)
Creates a view on a Notification object
Definition: SpecializedPayload.hpp:209
static PayloadTypeIdType GetPayloadTypeId()
Returns the PayloadTypeId
Definition: SpecializedPayload.hpp:227
This (meta programming) class provides the C++ typename of the as template argument passed type.
Definition: TypeName.hxx:56
String Value
The resulting typename.
Definition: TypeName.hxx:114
static Enum Parse(const String &input)
Parses the given input string.
Definition: Enum.hxx:228
static SelfType Format(const SelfType &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: BasicString.hxx:1483
@ 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
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType....
Definition: RscType.hpp:37
@ String
String with undefined format. Deprecated with remoting version 4 used by Rsc.
Root namespace for the PLCnext API
Namespace of the C++ standard library