PLCnext API Documentation 25.0.2.69
TypeInfo.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Plc/Commons/DataTypeEnum.hpp"
9#include "Arp/Plc/Commons/Meta/TypeIdentifier.hpp"
10#include "Arp/Plc/Commons/Meta/ArrayDimension.hpp"
11#include "Arp/Plc/Commons/Meta/ArrayDimensions.hpp"
12#include "Arp/Plc/Commons/Meta/StandardAttributes.hpp"
13#include "Arp/Plc/Commons/Meta/CustomAttribute.hpp"
14#include "Arp/Plc/Commons/Meta/CustomAttributes.hpp"
15#include "Arp/Base/Rsc/Commons/RscSerializable.hpp"
16#include <vector>
17#include <numeric>
18
19namespace Arp { namespace Plc { namespace Commons { namespace Meta
20{
21
22
23using namespace Arp::Base::Rsc::Commons;
24
25
28{
29public: // construction/destruction
31 TypeInfo(void) = default;
32
33 TypeInfo(DataType dataType, const TypeIdentifier& typeId, size_t size, size_t alignment);
34
35 ARP_DEPRECATED("Use ChildTypeInfo to define arrays")
36 TypeInfo(DataType elementType, const TypeIdentifier& elementTypeId, size_t elementSize, size_t alignment, const ArrayDimension& arrayDimension);
37
39 TypeInfo(DataType elementType, const TypeIdentifier& elementTypeId, size_t elementSize, size_t alignment, const ArrayDimensions& arrayDimensions);
40
41 TypeInfo(DataType dataType, const TypeIdentifier& typeId, size_t size, size_t alignment, StandardAttributes standardAttributes,
42 const CustomAttributes& customAttributes);
43
44 TypeInfo(DataType dataType, const TypeIdentifier& typeId);
46 TypeInfo(const TypeInfo& arg) = default;
48 TypeInfo(TypeInfo&& arg) noexcept = default;
50 TypeInfo& operator=(const TypeInfo& arg) = default;
52 TypeInfo& operator=(TypeInfo&& arg) noexcept = default;
54 virtual ~TypeInfo(void) noexcept = default;
55
56protected:
57 TypeInfo(DataType dataType, const TypeIdentifier& typeId, size_t size, size_t alignment, const ArrayDimensions& arrayDimensions,
58 StandardAttributes standardAttributes, const CustomAttributes& customAttributes);
59
60
61public: // static fields
62 static const TypeInfo Empty;
63
64public: // RscSerializable operatios
65 void Serialize(RscWriter& writer)const;
66 void Deserialize(RscReader& reader);
67
68public: // static operations
69 static size_t GetFieldCount(void);
70
71public: // setter/getter operations
72 bool IsEmpty(void)const;
73 bool IsHidden(void)const;
74 size_t GetTypeSize()const;
75 void SetDataType(DataTypeEnum arg);
77 const CustomAttributes& GetAttributes(void)const;
78 void SetTypeIdentifier(const TypeIdentifier& value);
79 const TypeIdentifier& GetTypeIdentifier(void)const;
80 size_t GetAlignment(void)const;
82 const ArrayDimensions& GetArrayDimensions(void)const;
85 size_t GetCacheSize(void)const;
86
87public: // operations
89 void AddCustomAttribute(const String& name, const RscVariant<256>& value);
90
91private: // methods
92
93 ARP_DEPRECATED("To be removed")
94 void InsertDimension(ArrayDimension& dimension);
95
96protected: // fields
97 DataTypeEnum dataType = DataType::None;
98 TypeIdentifier typeId;
99 size_t size = 0;
100 size_t alignment = 0;
101 ArrayDimensions dimensions; // To be moved to ChildTypeInfo
102 StandardAttributes standardAttributes;
103 CustomAttributes customAttributes;
104
105private: // fields
106};
107
108}}}} // end of namespace Arp::Plc::Commons::Meta
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Any custom struct type which is intended to be marshalled in a Rsc serialization context,...
Definition: RscSerializable.hpp:35
Rsc class for variant data types like primitive data type, strings or information about arrays or str...
Definition: RscVariant.hxx:57
Reads marshaled data of RSC services.
Definition: RscReader.hpp:34
Writes marshalled data of RSC services.
Definition: RscWriter.hpp:34
Provide array information.
Definition: ArrayDimension.hpp:19
Provide array information.
Definition: ArrayDimensions.hpp:18
Provides detailed type information of a child within TypeBrowser interface.
Definition: ChildTypeInfo.hpp:27
Collection of StandardAttribute flags
Definition: StandardAttributes.hpp:16
Identifies a type descriptions
Definition: TypeIdentifier.hpp:25
Provides detailed type information within TypeBrowser interface.
Definition: TypeInfo.hpp:28
bool IsEmpty(void) const
Determines if this instance is empty.
Definition: TypeInfo.cpp:124
const CustomAttributes & GetAttributes(void) const
List of data attributes.
Definition: TypeInfo.cpp:163
size_t GetTypeSize() const
Get the size of the type.
Definition: TypeInfo.cpp:138
const StandardAttributes & GetStandardAttributes(void) const
Returns the StandardAttributes
Definition: TypeInfo.cpp:205
void AddStandardAttribute(StandardAttribute value)
Adds a StandardAttribute flags
Definition: TypeInfo.cpp:212
size_t GetCacheSize(void) const
Get the cache size
Definition: TypeInfo.cpp:227
bool IsHidden(void) const
Determines if this type is hidden.
Definition: TypeInfo.cpp:131
void AddCustomAttribute(const String &name, const RscVariant< 256 > &value)
Adds a CustomAttribute
Definition: TypeInfo.cpp:220
size_t GetAlignment(void) const
Get alignment.
Definition: TypeInfo.cpp:191
DataTypeEnum GetDataType() const
Get respective data type.
Definition: TypeInfo.cpp:156
void SetStandardAttributes(StandardAttribute value)
Sets the StandardAttributes
Definition: TypeInfo.cpp:198
void SetDataType(DataTypeEnum arg)
Set the data type.
Definition: TypeInfo.cpp:149
const ArrayDimensions & GetArrayDimensions(void) const
Deprecated! List of array dimensions and their informations.
Definition: TypeInfo.cpp:184
TypeInfo(void)=default
Constructs an TypeInfo instance for simple elementary data type.
const TypeIdentifier & GetTypeIdentifier(void) const
The TypeIdentifier of a struct, program or any other complex type.
Definition: TypeInfo.cpp:176
void SetTypeIdentifier(const TypeIdentifier &value)
The TypeIdentifier of a struct, program or any other complex type.
Definition: TypeInfo.cpp:169
Definition: DataTypeEnum.hpp:15
std::vector< CustomAttribute > CustomAttributes
List of type attributes TypeAttribute.
Definition: CustomAttributes.hpp:15
StandardAttribute
Standard attributes to types
Definition: StandardAttribute.hpp:18
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38