7 #include "Arp/System/Rsc/Services/Rsc.h"
8 #include "Arp/System/Commons/Logging.h"
9 #include "Arp/System/Commons/Exceptions/Exceptions.h"
10 #include "Arp/System/Rsc/Services/RscException.hpp"
11 #include "Arp/System/Rsc/Services/IRscWriteEnumerator.hxx"
12 #include "Arp/System/Rsc/Services/RscWriter.hpp"
13 #include "Arp/System/Rsc/Services/RscArrayWriter.hpp"
16 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
36 void BeginWrite(
size_t arrayLengthArg = (
size_t) -1)
override;
45 RemotingWriter& remotingWriter;
46 bool isArrayEnumerator;
48 size_t arrayLength = 0;
49 bool endWritten =
false;
50 size_t fieldCount = 0;
57 : isArrayEnumerator(isArrayEnumeratorArg)
58 , remotingWriter(rscWriter.GetRemotingWriter())
59 , rscType(GetRscTypeFrom(T()))
60 , fieldCount(StructInfo<T>().FieldCount)
69 Log::Error(
"Rsc Enumerating was not ended properly, call EndWrite() method when writing was finished.");
76 this->arrayLength = arrayLengthArg;
78 if(this->isArrayEnumerator)
80 if(this->arrayLength == (
size_t) -1)
88 this->remotingWriter.WriteBeginStruct(this->fieldCount);
92 this->remotingWriter.WriteTag(this->rscType);
94 this->remotingWriter.WriteArrayLength(this->arrayLength);
98 if(this->arrayLength != (
size_t) -1)
100 throw ArgumentException(
"Array length could not be defined for standard enumerators.");
109 if(this->isArrayEnumerator)
111 if(this->arrayLength == 0)
120 this->remotingWriter.WriteEnumeratorTag(this->rscType);
123 this->remotingWriter.WriteFieldCount(this->fieldCount);
126 RscValueAdapter<T> valueAdapter(current);
127 valueAdapter.Write(this->remotingWriter,
false);
134 this->remotingWriter.WriteTag(arrayElementType);
135 this->remotingWriter.WriteArrayLength(arraySize);
136 return RscArrayWriter(arraySize, arrayElementType, this->remotingWriter);
142 if(this->isArrayEnumerator)
144 if(this->arrayLength != 0)
154 this->endWritten =
true;
This exception is used when an invalid argument occurs.
Definition: ArgumentException.hpp:15
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:15
Interface for writing an array or an enumerator. For regular enumerators UndefinedArrayLength is used...
Definition: IRscWriteEnumerator.hxx:23
Helper class to read an array of primtive types from an RscVariant. This class uses the array informa...
Definition: RscArrayWriter.hpp:22
Implementation of IRscWriteEnumerator used on client side.
Definition: RscWriteEnumerator.hxx:24
void BeginWrite(size_t arrayLengthArg=(size_t) -1) override
Begins the operation to write the enumerator.
Definition: RscWriteEnumerator.hxx:74
void EndWrite(void) override
Ends the enumerator. With an array enumerator all enumerator elements had to be written
Definition: RscWriteEnumerator.hxx:140
void WriteNext(const T ¤t) override
Writes the next enumerator element.
Definition: RscWriteEnumerator.hxx:107
RscWriteEnumerator(RscWriter &rscWriter, bool isArrayEnumerator)
Constructs an RscEnumeratorBase instance.
Definition: RscWriteEnumerator.hxx:56
~RscWriteEnumerator(void)
Destructs this instance and frees all resources.
Definition: RscWriteEnumerator.hxx:65
RscWriteEnumerator(const RscWriteEnumerator &arg)=default
Copy constructor.
Writes data to Rsc.
Definition: RscWriter.hpp:31
@ 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
@ Enumerator
Enumerator type, handled by Rsc with IRscReadEnumerator and IRscWriteEnumerator
@ Struct
Complex datatype with implements IRscSerializable
Root namespace for the PLCnext API