PLCnext API Documentation 25.0.2.69
TypeIdentifier.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Rsc/Commons/Rsc.hpp"
9#include "Arp/Base/Rsc/Commons/RscSerializable.hpp"
10#include "Arp/Base/Rsc/Commons/RscString.hxx"
11
12namespace Arp { namespace Plc { namespace Commons { namespace Meta
13{
14
15using namespace Arp::Base::Rsc::Commons;
16using namespace Arp::Base::Rsc::Commons::Services;
17
18// forwards
19class DataTag;
20
25{
26 friend class DataTag;
27
28public: // typedefs
29
30public: // construction/destruction
32 TypeIdentifier(void) = default;
33 TypeIdentifier(const String& name, const char* namespace_, const void* typeTag = nullptr);
34 TypeIdentifier(const String& name, const char* namespace_, const void* typeTag, const void* namespaceTag);
36 TypeIdentifier(const TypeIdentifier& arg) = default;
38 TypeIdentifier(TypeIdentifier&& arg) noexcept = default;
40 TypeIdentifier& operator=(const TypeIdentifier& arg) = default;
42 TypeIdentifier& operator=(TypeIdentifier&& arg) noexcept = default;
44 ~TypeIdentifier(void) noexcept = default;
45
46public: // static properties
48 static const TypeIdentifier Empty;
49
50public: // static operations
51 static TypeIdentifier Create(const String& commonTypeName, const char* libraryNamespace, void* typeTag = nullptr);
52 static TypeIdentifier Create(const String& commonTypeName, const char* libraryNamespace, void* typeTag, const void* namespaceTag);
53
54 static size_t GetMaxTypenameLength();
55 static size_t GetMaxNamespaceLength();
56
57public: // operators
58 bool operator==(const TypeIdentifier& rhs)const;
59 bool operator<(const TypeIdentifier& rhs)const;
60
61public: // setter/getter operations
62 bool IsEmpty(void)const;
63 const String& GetName(void)const;
64 const String& GetNamespace(void)const;
65 String GetFullName(void)const;
66 const byte* GetTypeTag(void)const;
67 ARP_DEPRECATED("CounterpartTypeTag is not used any more. It will be removed.")
68 const byte* GetChangeCounterpartTypeTag(void)const;
69 size_t GetHashValue(void)const;
70 size_t GetCacheSize()const;
71
72public: // operations
73 String ToString(void)const;
74 void SwapDomain(void);
76 bool AreFullNamesEqual(const TypeIdentifier& other) const;
77
78public: // RscSerializable operations
79 void Serialize(RscWriter& writer)const;
80 void Deserialize(RscReader& reader);
81 static size_t GetFieldCount(void);
82
83private: // methods
85 ARP_DEPRECATED("CounterpartTypeTag is not used any more. It will be removed.")
86 void SetChangeCounterpartTypeTag(const byte* value);
87
88private: // fields
89 String name;
90 String namespace_;
91 const byte* typeTag = nullptr;
92 const byte* namespaceTag = nullptr;
93
94private: // static fields
95 static const char namespaceSeparator = '/';
96};
97
98std::ostream& operator<<(std::ostream& os, const TypeIdentifier& typeId);
99
100}}}} // end of namespace Arp::Plc::Meta
101
103// template specialization of TypeIdentifier formatter
104template<> struct fmt::formatter<Arp::Plc::Commons::Meta::TypeIdentifier> : public fmt::ostream_formatter {};
105
106namespace std
107{
108
109// hash functor for TypeIdentifier
110template<>
112{
113private: // usings
115
116public:
118 using result_type = size_t;
119
120public:
121 result_type operator()(const argument_type& key) const
122 {
123 return key.GetHashValue();
124 }
125};
126}
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
Reads marshaled data of RSC services.
Definition: RscReader.hpp:34
Writes marshalled data of RSC services.
Definition: RscWriter.hpp:34
Includes kind as well as instance browse name.
Definition: DataTag.hpp:24
Identifies a type descriptions
Definition: TypeIdentifier.hpp:25
TypeIdentifier(const TypeIdentifier &arg)=default
Copy constructor.
bool IsEmpty(void) const
Checks if this instance is empty.
Definition: TypeIdentifier.cpp:65
bool AreFullNamesEqual(const TypeIdentifier &other) const
Checks whether the full name of this and another TypeIdentifier are euqal
Definition: TypeIdentifier.cpp:169
TypeIdentifier & operator=(const TypeIdentifier &arg)=default
Copy assignment operator.
static size_t GetMaxNamespaceLength()
Returns the maximum length of the namespace
Definition: TypeIdentifier.cpp:33
TypeIdentifier CreateUniqueComponentTypeIdentifier() const
Creates a TypoeIdentifier with a unique name for components
Definition: TypeIdentifier.cpp:218
TypeIdentifier & operator=(TypeIdentifier &&arg) noexcept=default
Move assignment operator
const String & GetName(void) const
Get type name of the corresponding object.
Definition: TypeIdentifier.cpp:71
~TypeIdentifier(void) noexcept=default
Destructs this instance and frees all resources.
String GetFullName(void) const
Get fullqualified type name and namespace.
Definition: TypeIdentifier.cpp:84
TypeIdentifier(void)=default
Constructs an TypeId instance.
TypeIdentifier(TypeIdentifier &&arg) noexcept=default
Move constructor.
static const TypeIdentifier Empty
Empty instance to enable retruning const&
Definition: TypeIdentifier.hpp:48
static size_t GetMaxTypenameLength()
Returns the maximum length of the typename
Definition: TypeIdentifier.cpp:27
static TypeIdentifier Create(const String &commonTypeName, const char *libraryNamespace, void *typeTag=nullptr)
Creates a TypeIdentifier
Definition: TypeIdentifier.cpp:196
const String & GetNamespace(void) const
Get type namespace of the corresponding object.
Definition: TypeIdentifier.cpp:78
size_t GetHashValue(void) const
Gets the hash value of this instance.
Definition: TypeIdentifier.cpp:111
const byte * GetChangeCounterpartTypeTag(void) const
Deprecated! Get the internal type tag of the change counterpart.
Definition: TypeIdentifier.cpp:104
const byte * GetTypeTag(void) const
Get the internal type dataTag of the corresponding object.
Definition: TypeIdentifier.cpp:96
void SwapDomain(void)
Swaps the type tag with its counterpart.
Definition: TypeIdentifier.cpp:119
String ToString(void) const
Get full qualified type name and namespace.
Definition: TypeIdentifier.cpp:158
size_t GetCacheSize() const
Get the cache size
Definition: TypeIdentifier.cpp:136
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 fmtlib.
Definition: BasicFormatter.hxx:107
Namespace of the C++ standard library