PLCnext API Documentation 24.0.0.71
TypeIdentifier.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Rsc/Services/IRscSerializable.hpp"
9#include "Arp/System/Rsc/Services/RscReader.hpp"
10#include "Arp/System/Rsc/Services/RscString.hxx"
11#include "Arp/System/Rsc/Services/RscWriter.hpp"
12namespace Arp { namespace Plc { namespace Commons { namespace Meta
13{
14
15using namespace Arp::System::Rsc::Services;
16
17// forwards
18class DataTag;
19
24{
25 friend class DataTag;
26
27public: // typedefs
28
29public: // construction/destruction
31 TypeIdentifier(void) = default;
34 TypeIdentifier(const String& name, const char* namespace_, const void* typeTag = nullptr);
37 TypeIdentifier(const String& name, const char* namespace_, const void* typeTag, const void* namespaceTag);
39 TypeIdentifier(const TypeIdentifier& arg) = default;
43 TypeIdentifier& operator=(const TypeIdentifier& arg) = default;
47 ~TypeIdentifier(void) override = default;
48
49public: // static properties
51 static const TypeIdentifier Empty;
52
53public: // static operations
59 static TypeIdentifier Create(const String& commonTypeName, const char* libraryNamespace, void* typeTag = nullptr);
60
67 static TypeIdentifier Create(const String& commonTypeName, const char* libraryNamespace, void* typeTag, const void* namespaceTag);
68
70 static size_t GetMaxTypenameLength();
71
73 static size_t GetMaxNamespaceLength();
74
75public: // operators
76 bool operator==(const TypeIdentifier& rhs)const;
77 bool operator<(const TypeIdentifier& rhs)const;
78
79public: // setter/getter operations
82 bool IsEmpty(void)const;
85 const String& GetName(void)const;
86
89 const String& GetNamespace(void)const;
90
93 String GetFullName(void)const;
94
97 const byte* GetTypeTag(void)const;
98
102 ARP_DEPRECATED("CounterpartTypeTag is not used any more. It will be removed.")
103 const byte* GetChangeCounterpartTypeTag(void)const;
104
107 size_t GetHashValue(void)const;
108
111 size_t GetCacheSize()const;
112
113public: // operations
114
117 String ToString(void)const;
118
121 void SwapDomain(void);
122
126
128 bool AreFullNamesEqual(const TypeIdentifier& other) const;
129
130public: // IRscSerializable operations
131 void Serialize(RscWriter& writer)const override;
132 void Deserialize(RscReader& reader)override;
133 static size_t GetFieldCount(void);
134
135private: // methods
137 ARP_DEPRECATED("CounterpartTypeTag is not used any more. It will be removed.")
138 void SetChangeCounterpartTypeTag(const byte* value);
139
140private: // fields
141 String name;
142 String namespace_;
143 const byte* typeTag = nullptr;
144 const byte* namespaceTag = nullptr;
145
146private: // static fields
147 static const char namespaceSeparator = '/';
148};
149
152std::ostream& operator<<(std::ostream& os, const TypeIdentifier& typeId);
153
154}}}} // end of namespace Arp::Plc::Meta
155
156namespace std
157{
158
159// hash functor for TypeIdentifier
160template<>
162{
163private: // usings
165
166public:
168 using result_type = size_t;
169
170public:
171 result_type operator()(const argument_type& key) const
172 {
173 return key.GetHashValue();
174 }
175};
176}
Includes kind as well as instance browse name.
Definition: DataTag.hpp:25
Identifies a type descriptions
Definition: TypeIdentifier.hpp:24
void Deserialize(RscReader &reader) override
Deserializes the datatype. All fields of the datatype have to be deserialized in use of RscReader.
TypeIdentifier & operator=(TypeIdentifier &&arg)=default
Move assignment operator
TypeIdentifier(const TypeIdentifier &arg)=default
Copy constructor.
bool IsEmpty(void) const
Checks if this instance is empty.
bool AreFullNamesEqual(const TypeIdentifier &other) const
Checks whether the full name of this and another TypeIdentifier are euqal
static TypeIdentifier Create(const String &commonTypeName, const char *libraryNamespace, void *typeTag, const void *namespaceTag)
Creates a TypeIdentifier
TypeIdentifier & operator=(const TypeIdentifier &arg)=default
Copy assignment operator.
TypeIdentifier CreateUniqueComponentTypeIdentifier() const
Creates a TypoeIdentifier with a unique name for components
const String & GetName(void) const
Get type name of the corresponding object.
static TypeIdentifier Create(const String &commonTypeName, const char *libraryNamespace, void *typeTag=nullptr)
Creates a TypeIdentifier
String GetFullName(void) const
Get fullqualified type name and namespace.
TypeIdentifier(void)=default
Constructs an TypeId instance.
static size_t GetMaxTypenameLength()
Returns the maximum length of the typename
TypeIdentifier(const String &name, const char *namespace_, const void *typeTag, const void *namespaceTag)
Constructs an TypeId instance.
void Serialize(RscWriter &writer) const override
Serializes the datatype. All fields of the datatype have to be serialized in use of RscWriter.
TypeIdentifier(TypeIdentifier &&arg)=default
Move constructor.
static const TypeIdentifier Empty
Empty instance to enable retruning const&
Definition: TypeIdentifier.hpp:51
~TypeIdentifier(void) override=default
Destructs this instance and frees all resources.
const String & GetNamespace(void) const
Get type namespace of the corresponding object.
size_t GetHashValue(void) const
Gets the hash value of this instance.
const byte * GetChangeCounterpartTypeTag(void) const
Deprecated! Get the internal type tag of the change counterpart.
const byte * GetTypeTag(void) const
Get the internal type dataTag of the corresponding object.
void SwapDomain(void)
Swaps the type tag with its counterpart.
String ToString(void) const
Get full qualified type name and namespace.
size_t GetCacheSize() const
Get the cache size
TypeIdentifier(const String &name, const char *namespace_, const void *typeTag=nullptr)
Constructs an TypeId instance.
static size_t GetMaxNamespaceLength()
Returns the maximum length of the namespace
Marshalls structure or class data types. Serialize and Deserialize have to marshal fields in the same...
Definition: IRscSerializable.hpp:20
Reads data from Rsc
Definition: RscReader.hpp:27
Writes data to Rsc.
Definition: RscWriter.hpp:32
bool operator<(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:1980
bool operator==(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on equality.
Definition: BasicString.hxx:1908
Namespace for classes and interfaces for the Remote Service Call implementation
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
Namespace of the C++ standard library