PLCnext API Documentation 23.6.0.37
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
69public: // operators
70 bool operator==(const TypeIdentifier& rhs)const;
71 bool operator<(const TypeIdentifier& rhs)const;
72
73public: // setter/getter operations
76 bool IsEmpty(void)const;
79 const String& GetName(void)const;
80
83 const String& GetNamespace(void)const;
84
87 String GetFullName(void)const;
88
91 const byte* GetTypeTag(void)const;
92
96 ARP_DEPRECATED("CounterpartTypeTag is not used any more. It will be removed.")
97 const byte* GetChangeCounterpartTypeTag(void)const;
98
101 size_t GetHashValue(void)const;
102
105 size_t GetCacheSize()const;
106
107public: // operations
108
111 String ToString(void)const;
112
115 void SwapDomain(void);
116
120
122 bool AreFullNamesEqual(const TypeIdentifier& other) const;
123
124public: // IRscSerializable operations
125 void Serialize(RscWriter& writer)const override;
126 void Deserialize(RscReader& reader)override;
127 static size_t GetFieldCount(void);
128
129private: // methods
131 ARP_DEPRECATED("CounterpartTypeTag is not used any more. It will be removed.")
132 void SetChangeCounterpartTypeTag(const byte* value);
133
134private: // fields
135 String name;
136 String namespace_;
137 const byte* typeTag = nullptr;
138 const byte* namespaceTag = nullptr;
139
140private: // static fields
141 static const char namespaceSeparator = '/';
142};
143
146std::ostream& operator<<(std::ostream& os, const TypeIdentifier& typeId);
147
148}}}} // end of namespace Arp::Plc::Meta
149
150namespace std
151{
152
153// hash functor for TypeIdentifier
154template<>
156{
157private: // usings
159
160public:
162 using result_type = size_t;
163
164public:
165 result_type operator()(const argument_type& key) const
166 {
167 return key.GetHashValue();
168 }
169};
170}
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.
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.
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:1971
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:1899
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