7 #include "Arp/System/Rsc/Services/Rsc.h" 8 #include "Arp/System/Rsc/Services/RscValueAdapter.hxx" 9 #include "Arp/System/Rsc/Services/RscStream.hpp" 10 #include "Arp/System/Rsc/Services/RemotingWriter.hpp" 12 #include <type_traits> 23 namespace Arp {
namespace System {
namespace Rsc {
namespace Services
27 class RscClientContext;
36 RscWriter(BinaryWriter2& remotingWriter, RscClientContext* pClientContext =
nullptr);
55 RemotingWriter& GetRemotingWriter(
void);
62 void WriteConfirmation(
bool flush =
false);
70 template<
class T>
void Write(
const T& value);
78 template<
class T>
void Write(
const T& value,
bool writeTag);
85 template<
int N>
void WriteString(
const String& value);
92 template<
int N>
void WriteString(
const char(&value)[N]);
99 template<
class T>
void WriteObject(
const T& value);
106 template<
int N>
void WriteObjectString(
const String& value);
113 template<
int N>
void WriteObjectString(
const char(&value)[N]);
120 template<
class T>
void WriteArray(
const std::vector<T>& values);
127 template<
class T>
void WriteArray(
const std::vector<std::vector<T>>& values);
135 template<
class T,
size_t N>
void WriteArray(
const std::array<T, N>& values);
143 template<
class T>
void BeginArray(
size_t size);
146 RemotingWriter remotingWriter;
152 inline RscWriter::RscWriter(BinaryWriter2& remotingWriter, RscClientContext* pClientContextArg)
153 : remotingWriter(remotingWriter, *this, pClientContextArg)
159 return this->remotingWriter;
164 this->remotingWriter.WriteConfirmation(flush);
175 RscValueAdapter<T> valueAdapter(value);
176 valueAdapter.Write(this->remotingWriter);
182 RscValueAdapter<T> valueAdapter(value);
183 valueAdapter.Write(this->remotingWriter, writetTag);
189 this->remotingWriter.WriteStringInternal(value, N);
195 this->remotingWriter.WriteStringInternal(value, N);
201 size_t length = values.size();
202 this->BeginArray<T>(length);
203 for (
size_t i = 0; i < length; ++i)
205 const T& value = values[i];
206 RscValueAdapter<T> valueAdapter(value);
207 valueAdapter.Write(this->remotingWriter,
false);
215 this->BeginArray<T>(values.size());
216 for(
const std::vector<T>& innerArray : values)
218 this->remotingWriter.WriteArrayLength(innerArray.size());
220 for(
const T& value : innerArray)
222 RscValueAdapter<T> valueAdapter(value);
223 valueAdapter.Write(this->remotingWriter,
false);
228 template<
class T,
size_t N>
231 this->BeginArray<T>(N);
232 for(
size_t i = 0; i < N; ++i)
234 const T& value = values[i];
235 RscValueAdapter<T> valueAdapter(value);
236 valueAdapter.Write(this->remotingWriter,
false);
241 inline void RscWriter::BeginArray(
size_t size)
243 RscType elementType = GetRscTypeFrom(T());
247 this->remotingWriter.WriteBeginStruct(StructInfo<T>().FieldCount);
251 this->remotingWriter.WriteTag(elementType);
253 this->remotingWriter.WriteArrayLength(size);
260 this->remotingWriter.WriteObjectType(GetRscTypeFrom(value));
267 this->remotingWriter.WriteObjectString(RscStringEncoding::Utf8, value);
273 this->remotingWriter.WriteObjectString(RscStringEncoding::Utf8, value);
void WriteString(const String &value)
Writes a string in format Utf-8.
Definition: RscWriter.hpp:187
void Write(const T &value)
Writes an element of T from Rsc. Datatag and format is determined deducted by type of T...
Definition: RscWriter.hpp:173
Complex datatype with implements IRscSerializable
Writes data to Rsc.
Definition: RscWriter.hpp:32
RemotingWriter & GetRemotingWriter(void)
Returns reference to RemotingWriter
Definition: RscWriter.hpp:157
void WriteConfirmation(bool flush=false)
Sends a confirmation message to remote station.
Definition: RscWriter.hpp:162
void WriteArray(const std::vector< T > &values)
Writes an array to Rsc. The data to write has to be stored in a std::vector.
Definition: RscWriter.hpp:199
RscType
Datatypes supported by Rsc. Values are identical with CommonRemoting::RemotingMarshalType. Only supported types of RemotingMarshalType are included.
Definition: RscType.hpp:27
Definition: RemotingReader.hpp:10
Enables Rsc services to marshal large data packets as stream.
Definition: RscStream.hpp:17
Root namespace for the PLCnext API
void WriteObject(const T &value)
Writes an object. Datatag and format is determined deducted by type of T. This method doesn't support...
Definition: RscWriter.hpp:258
RscStream GetStream()
Creates an instance of RscStream initialized to write stream data.
Definition: RscWriter.hpp:167
System components used by the System, Device, Plc or Io domains.
void WriteObjectString(const String &value)
Writes a string in object format as Utf8 string.
Definition: RscWriter.hpp:265