PLCnext API Documentation 23.6.0.37
RscType.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Core/TypeDeduction.hxx"
9#include "Arp/System/Core/Enum.hxx"
10#include <type_traits>
11
12// forwards
13namespace Arp { namespace System { namespace Security
14{
15class SecurityToken;
16}}}
17
18namespace Arp { namespace System { namespace Rsc { namespace Services
19{
20
21// usings
22using SecurityToken = Arp::System::Security::SecurityToken;
23
24// forwards
25template<int N>
26class RscString;
27template<int N>
28class SecureString;
29class IRscSerializable;
30class RscVersion;
31class RscGuid;
32
35enum class RscType : uint8
36{
38 None = 0xFF,
40 End = 0,
42 Null = 0,
44 Void = 1,
46 Bool = 2,
48 Char = 3,
50 Int8 = 4,
52 Uint8 = 5,
54 Int16 = 6,
56 Uint16 = 7,
58 Int32 = 8,
60 Uint32 = 9,
62 Int64 = 10,
64 Uint64 = 11,
66 Real32 = 12,
68 Real64 = 13,
70 Struct = 18,
73 String = 19,
75 Utf8String = 19,
77 Array = 20,
79 DateTime = 23,
81 Version = 24,
83 Guid = 25,
85 AnsiString = 26,
87 Object = 28,
89 Utf16String = 30,
91 Stream = 34,
93 Enumerator = 35,
95 SecureString = 36,
97 Enum = 37,
99 Dictionary = 38,
101 SecurityToken = 39,
103 Exception = 40,
105 IecTime = 41,
107 IecTime64 = 42,
110 IecDate = 43,
112 IecDate64 = 44,
115 IecDateTime = 45,
117 IecDateTime64 = 46,
120 IecTimeOfDay = 47,
122 IecTimeOfDay64 = 48,
123};
124
129{
130 RscArrayInformation(void) = default;
131 RscArrayInformation(size_t size, RscType elementType, size_t dimensions = 1, size_t fieldCount = 0)
132 : Size(size)
133 , ElementType(elementType)
134 , Dimensions(dimensions)
135 , FieldCount(fieldCount)
136 {}
137
141 size_t Size = 0;
142
146 size_t Dimensions = 1;
147
152
156 size_t FieldCount = 0;
157};
158
161{
162 RscStructInformation(size_t fieldCount) : FieldCount(fieldCount) {}
163
167 size_t FieldCount = 0;
168};
169
170// global function GetRscType to determine RscType value by type
172template<class T, bool isSerializable = std::is_base_of<IRscSerializable, T>::value>
173struct StructInfo
174{
175 size_t FieldCount = 0;
176};
177
178template<class T>
179struct StructInfo<T, true>
180{
181 size_t FieldCount = T::GetFieldCount();
182};
183
184template<class T>
185constexpr RscType GetRscType(void)
186{
187 // REMARK: constexpr might only have a single return statement
188 return std::is_enum<T>::value ? GetRscType<typename underlying_enum_type<T>::type>() :
189 (
190 std::is_class<T>::value ? RscType::Struct :
191 (
192 std::is_array<T>::value ? RscType::Array : RscType::None
193 )
194 );
195}
196
197template<>
198constexpr RscType GetRscType<boolean>()
199{
200 return RscType::Bool;
201}
202
203template<>
204constexpr RscType GetRscType<char8>()
205{
206 return RscType::Uint8;
207}
208
209template<>
210constexpr RscType GetRscType<uint8>()
211{
212 return RscType::Uint8;
213}
214
215template<>
216constexpr RscType GetRscType<int8>()
217{
218 return RscType::Int8;
219}
220
221template<>
222constexpr RscType GetRscType<uint16>()
223{
224 return RscType::Uint16;
225}
226
227template<>
228constexpr RscType GetRscType<int16>()
229{
230 return RscType::Int16;
231}
232
233template<>
234constexpr RscType GetRscType<uint32>()
235{
236 return RscType::Uint32;
237}
238
239template<>
240constexpr RscType GetRscType<int32>()
241{
242 return RscType::Int32;
243}
244
245template<>
246constexpr RscType GetRscType<uint64>()
247{
248 return RscType::Uint64;
249}
250
251template<>
252constexpr RscType GetRscType<int64>()
253{
254 return RscType::Int64;
255}
256
257template<>
258constexpr RscType GetRscType<float32>()
259{
260 return RscType::Real32;
261}
262
263template<>
264constexpr RscType GetRscType<float64>()
265{
266 return RscType::Real64;
267}
268
269template<>
270constexpr RscType GetRscType<char*>()
271{
272 return RscType::Utf8String;
273}
274
275template<>
276constexpr RscType GetRscType<String>()
277{
278 return RscType::Utf8String;
279}
280
281template<>
282constexpr RscType GetRscType<DateTime>()
283{
284 return RscType::DateTime;
285}
286
287template<>
288constexpr RscType GetRscType<RscVersion>()
289{
290 return RscType::Version;
291}
292
293template<>
294constexpr RscType GetRscType<RscGuid>()
295{
296 return RscType::Guid;
297}
298
299template<>
300constexpr RscType GetRscType<SecurityToken>()
301{
303}
304
305template<class T>
306constexpr RscType GetRscTypeFrom(const T& /*value*/)
307{
308 return GetRscType<T>();
309}
310
311template<int N>
312constexpr RscType GetRscTypeFrom(const char(&)[N])
313{
314 return RscType::Utf8String;
315}
316
317template<int N>
318constexpr RscType GetRscTypeFrom(const RscString<N>&)
319{
320 return RscType::Utf8String;
321}
322
323template<int N>
324constexpr RscType GetRscTypeFrom(const SecureString<N>&)
325{
327}
328
329template<>
330constexpr RscType GetRscTypeFrom(const String&)
331{
332 return RscType::Utf8String;
333}
334
335template<>
336constexpr RscType GetRscTypeFrom(const DateTime&)
337{
338 return RscType::DateTime;
339}
340
341template<>
342constexpr RscType GetRscTypeFrom(const RscVersion&)
343{
344 return RscType::Version;
345}
346
347template<>
348constexpr RscType GetRscTypeFrom(const RscGuid&)
349{
350 return RscType::Guid;
351}
352
353template<>
354constexpr RscType GetRscTypeFrom(const SecurityToken&)
355{
357}
358
359constexpr bool IsPrimitiveRscType(RscType type)
360{
361 return (type >= RscType::Bool && type <= RscType::Real64) || (type >= RscType::IecTime && type <= RscType::IecTimeOfDay64);
362}
363
365// global stream operators of enum LogLevel for logging and parsing
366ARP_CXX_SYMBOL_EXPORT std::ostream& operator<<(std::ostream& os, const RscType value);
367ARP_CXX_SYMBOL_EXPORT std::istream& operator>>(std::istream& is, RscType& value);
368
369}}}} // end of namespace Arp::System::Rsc::Services
This class represents the version of a special SDK or Arp build.
Definition: BasicVersion.hpp:36
The class contains date and time informations.
Definition: DateTime.hpp:46
Adapter class for enums to make them loggable and parsable from e.g. XML files.
Definition: Enum.hxx:23
This class defines a base class for all enumerator implementations and some predefined enumerators as...
Definition: Enumerator.hxx:22
This is the base class of all Arp exception classes.
Definition: Exception.hpp:16
Specialized version of RscString for security context. Not implemented in this version....
Definition: SecureString.hxx:19
Definition: SecurityToken.hpp:12
std::uint8_t uint8
The Arp unsigned integer type of 1 byte size.
Definition: PrimitiveTypes.hpp:28
@ System
System components used by the System, Device, Plc or Io domains.
RscType
Data types supported by RSC.
Definition: RscType.hpp:36
@ IecTimeOfDay
summary>IEC type: LTIME_OF_DAY, LTOD [int64]
@ Version
Arp::System::Rsc::Services::RscVersion
@ Dictionary
Dictionary type. Not supported.
@ IecDateTime
summary>IEC type: LDATE_AND_TIME, LDT [int64]
@ Array
std::vector<T> or RSC enumerators
@ Object
Object type as Arp::System::Rsc::Services::RscVariant
@ SecurityToken
Security token needed for security services as Arp::System::Security::SecurityToken
@ Struct
struct derived by IRscSerializable
@ AnsiString
Ansi string, not supported in Rsc context
@ IecTime
summary>IEC type: LTIME [int64]
@ Guid
Universal unique ID Arp::System::Rsc::Services::RscGuid
@ IecDate
summary>IEC type: LDATE [int64]
@ Stream
Streamed type to marshal large data blobs Arp::System::Rsc::Services::RscStream/>
@ SecureString
String for security context, handled by Rsc with Arp::System::Rsc::Services::SecureString
@ Utf8String
Utf-8 string, Arp::System::Rsc::Services::RscString
@ Utf16String
Utf-16 string, not implemented in Rsc context
Root namespace for the PLCnext API
Contains information to marshall an array
Definition: RscType.hpp:129
size_t Size
Count of array elements
Definition: RscType.hpp:141
size_t FieldCount
Count of Fields of struct element type
Definition: RscType.hpp:156
size_t Dimensions
Array Dimensions
Definition: RscType.hpp:146
RscType ElementType
Array element type
Definition: RscType.hpp:151
Contains information to marshall an struct
Definition: RscType.hpp:161
size_t FieldCount
Count of struct fields
Definition: RscType.hpp:167