PLCnext API Documentation 24.0.0.71
CommonTypeName.hxx
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Core/TypeName.hxx"
9
10namespace Arp
11{
12
28template<class T = void>
30{
31 friend class CommonTypeName<void>;
32
33public: // construction/destruction
35 CommonTypeName(void);
38 CommonTypeName(const CommonTypeName& arg) = default;
41 CommonTypeName(CommonTypeName&& arg)noexcept = default;
45 CommonTypeName& operator=(const CommonTypeName& arg) = default;
47 ~CommonTypeName(void) = default;
48
49public: // operations
52 String GetFullName(void)const;
55 String GetNamespace(void)const;
58 String GetClassName(void)const;
59
60public: // fields
63
64public: // operators
66 operator const String& (void)const;
68 operator const char*(void)const;
69
70private: // construction
71 CommonTypeName(const char* typeName);
72};
73
75// inline methods of class CommonTypeName
76template<class T>
78 : Value(TypeName<T>().GetCommonName())
79{
80}
81
82template<class T>
83inline CommonTypeName<T>::CommonTypeName(const char* typeName)
84 : Value(typeName)
85{
86}
87
88template<class T>
90{
91 return this->Value;
92}
93
94template<class T>
95inline CommonTypeName<T>::operator const char*()const
96{
97 return this->Value.CStr();
98}
99
100template<class T>
102{
103 return this->Value;
104}
105
106template<class T>
108{
109 return __Internal::TypeNameHelper::GetNamespace(this->Value, true);
110}
111
112template<class T>
114{
115 return __Internal::TypeNameHelper::GetClassName(this->Value, true);
116}
117
119// implementation of template specialization CommonTypeName<void>
121template<>
122class CommonTypeName<void>
123{
124private: // construction/destruction
125 CommonTypeName(void) = delete;
126 CommonTypeName(const CommonTypeName& arg) = delete;
127 CommonTypeName& operator=(const CommonTypeName& arg) = delete;
128 ~CommonTypeName(void) = delete;
129
130public: // static factory operations
135 template <class T2>
136 static CommonTypeName<T2> GetFrom(T2& instance)
137 {
138 return GetFrom(&instance);
139 }
140
145 template <class T2>
146 static CommonTypeName<T2> GetFrom(T2* pInstance)
147 {
148 CommonTypeName<T2> result;
149 result.Value = TypeName<void>::GetFrom(pInstance).GetCommonName();
150 return result;
151 }
152};
153
154} // end of namespace Arp
static CommonTypeName< T2 > GetFrom(T2 &instance)
Creates the CommonTypeName from the as argument passed variable.
Definition: CommonTypeName.hxx:136
static CommonTypeName< T2 > GetFrom(T2 *pInstance)
Creates the CommonTypeName from the as argument passed variable pointer.
Definition: CommonTypeName.hxx:146
This (meta programming) class provides the typename according the CLS (common language specification)...
Definition: CommonTypeName.hxx:30
CommonTypeName(void)
Constructs a CommonTypeName instance and determines the typename of the of T.
Definition: CommonTypeName.hxx:77
CommonTypeName & operator=(const CommonTypeName &arg)=default
The default assignment operator.
~CommonTypeName(void)=default
The default destructor..
String GetClassName(void) const
Gets the classname of the as template parameter given type.
Definition: CommonTypeName.hxx:113
String Value
The CLS typename of the as template argument passed type.
Definition: CommonTypeName.hxx:62
String GetFullName(void) const
Gets the full typename of this instance.
Definition: CommonTypeName.hxx:101
String GetNamespace(void) const
Gets the namespace of the as template parameter given type.
Definition: CommonTypeName.hxx:107
CommonTypeName(const CommonTypeName &arg)=default
The default copy constructor.
CommonTypeName(CommonTypeName &&arg) noexcept=default
The default move constructor.
This (meta programming) class provides the C++ typename of the as template argument passed type.
Definition: TypeName.hxx:67
String GetCommonName(void) const
Gets the common name of the as template parameter given type according to the CLS.
Definition: TypeName.hxx:156
Root namespace for the PLCnext API