8 #include "Arp/System/Rsc/Services/Rsc.h"
9 #include "Arp/System/Commons/Exceptions/Exceptions.h"
10 #include "Arp/System/Rsc/Services/RemotingWriter.hpp"
11 #include "Arp/System/Rsc/Services/RscVariant.hxx"
14 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
24 using WriteElementFunction = RscVariant<>::WriteElementFunction;
101 void WriteRemotingValue(
RscType type,
const byte* pValue);
106 RemotingWriter* pWriter =
nullptr;
107 WriteElementFunction writeElementFunction;
108 size_t maxStringSize = 0;
116 : arrayInformation(value.GetArrayInformation())
117 , pWriter(value.typeInfo.pWriter)
130 if (value.typeInfo.pWriteElementFunction !=
nullptr)
132 this->writeElementFunction = *value.typeInfo.pWriteElementFunction;
134 else if(this->pWriter !=
nullptr)
136 this->writeElementFunction = [&](
RscType type,
const byte * pValue)
138 WriteRemotingValue(type, pValue);
150 return this->arrayInformation.
Size;
160 return this->position;
170 this->
WriteNext(
reinterpret_cast<const byte*
>(¤t));
180 this->
WriteNext(
reinterpret_cast<const byte*
>(¤t));
190 if(N != this->maxStringSize)
194 this->writeElementFunction(this->
GetElementType(),
reinterpret_cast<const byte*
>(current.
CStr()));
198 template<
int MaxStringSize>
209 if(this->pWriter ==
nullptr)
221 return structVariant;
229 throw InvalidOperationException(
"This instance of RscArrayWriter is not initialized to contain objects");
231 if(N != this->maxStringSize)
233 throw InvalidOperationException(
"Size of current doesn't fit to maxStringSize");
235 this->writeElementFunction(current.GetType(), current.GetDataAddress());
236 if(current.ContainsTypeInformation())
238 current.typeInfo.pWriter = this->pWriter;
The class contains date and time informations.
Definition: DateTime.hpp:45
This exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:15
static ArgumentException Create(const char *paramName, const T ¶mValue)
Creates an ArgumentException instance using a default message text.
Definition: ArgumentException.hpp:112
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:15
Helper class to read an array of primtive types from an RscVariant. This class uses the array informa...
Definition: RscArrayWriter.hpp:22
RscArrayWriter & operator=(const RscArrayWriter &arg)=default
Assignment operator.
~RscArrayWriter(void)=default
Destructs this instance and frees all resources.
RscArrayWriter WriteNextArray(size_t size)
Writes the next subarray for arrays with more than one dimension. The next subarray is written with a...
RscArrayWriter(const RscVariant< N > &value)
Constructs an RscArray instance.
Definition: RscArrayWriter.hpp:115
RscArrayWriter(const RscArrayWriter &arg)=default
Copy constructor.
RscType GetElementType(void) const
Returns the element type
Definition: RscArrayWriter.hpp:153
size_t GetSize(void) const
Returns number of Elements contained in array
Definition: RscArrayWriter.hpp:148
size_t GetPosition(void) const
Returns current writing position in array
Definition: RscArrayWriter.hpp:158
RscArrayWriter(size_t size, RscType elementType, RemotingWriter &writer, size_t dimensions=1)
Constructs an RscArrayWriter instance.
void WriteNext(const T ¤t)
Writes the next single array element using the callback function given by ArrayInformation of RscVari...
Definition: RscArrayWriter.hpp:164
void WriteNext(const byte *pCurrent)
Writes the next single array element using the callback function given by ArrayInformation of RscVari...
RscArrayWriter(size_t size, RscType elementType, WriteElementFunction writeFunction)
Constructs an RscArrayWriter instance.
Contains a static string with string lentgh up to N characters. The string has to be null terminated.
Definition: RscString.hxx:21
const char * CStr(void) const
Returns pointer to internal buffer.
Definition: RscString.hxx:111
Rsc container class for primitive data type, strings or information about arrays or structs....
Definition: RscVariant.hxx:39
static RscVariant< MaxStringSize > CreateStructVariant(size_t fieldCount)
Creates a new RscVariant initialized with RscStructInformation
Definition: RscVariant.hxx:557
void SetWriteElementFunction(WriteElementFunction *pFunction) const
Sets callback for write function to write a single array element. This could only be used for Variant...
Definition: RscVariant.hxx:724
const byte * GetDataAddress(void) const
Gets a raw pointer to internal data buffer. To read data prefer CopyTo and to write prefer assignment...
Definition: RscVariant.hxx:514
@ System
System components used by the System, Device, Plc or Io domains.
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType....
Definition: RscType.hpp:37
@ Object
Object type handled by Rsc as RscVariant
@ Struct
Complex datatype with implements IRscSerializable
@ DateTime
Datetime, handled by Rsc with DateTime
Root namespace for the PLCnext API