PLCnext API Documentation 25.0.2.69
TypeIdentifierDeduction.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Core/CommonTypeName.hxx"
9#include "Arp/System/Core/TypeDeduction.hxx"
10#include "Arp/Plc/Commons/DataTypeEnum.hpp"
11#include "Arp/Plc/Commons/Meta/TypeIdentifier.hpp"
12#include "Arp/Plc/Commons/Meta/TypeSystem/DataTypeDeduction.hxx"
13#include <type_traits>
14namespace Arp { namespace Plc { namespace Commons { namespace Meta { namespace TypeSystem
15{
16
17using namespace Arp::Plc::Commons;
18
20{
21public: // construction/destruction
22 explicit TypeIdentifierDeduction(const char* libraryNamespace);
23
24public: // static operations
25 template<class T>
26 TypeIdentifier operator()(const T& value)const;
27
28private: // fields
29 const char* libraryNamespace;
30};
31
33// inline methods of class TypeIdentifierDeduction
34template<class T>
35inline TypeIdentifier TypeIdentifierDeduction::operator()(const T& value)const
36{
37 DataTypeEnum dataType = static_cast<DataType>(DataTypeDeduction<T>());
38 if (!dataType.IsComplex(true))
39 {
41 }
42 if (dataType == DataType::Program)
43 {
44 return TypeIdentifier::Create(CommonTypeName<void>::GetFrom(value), this->libraryNamespace);
45 }
46 // else must deduce typeId
47 String typeName = CommonTypeName <
48 typename std::remove_all_extents <
49 typename std::remove_pointer <
50 typename remove_shared_ptr <
51 typename std::remove_const<T>::type >::type >::type >::type > ();
52
53 return TypeIdentifier::Create(typeName, this->libraryNamespace);
54}
55
56}}}}} // end of namespace Arp::Plc::Commons::Meta::TypeSystem
This (meta programming) class provides the type-name according the CLS (common language specification...
Definition: CommonTypeName.hxx:33
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Identifies a type descriptions
Definition: TypeIdentifier.hpp:25
static const TypeIdentifier Empty
Empty instance to enable retruning const&
Definition: TypeIdentifier.hpp:48
static TypeIdentifier Create(const String &commonTypeName, const char *libraryNamespace, void *typeTag=nullptr)
Creates a TypeIdentifier
Definition: TypeIdentifier.cpp:196
Definition: DataTypeDeduction.hxx:16
Definition: TypeIdentifierDeduction.hxx:20
TypeIdentifierDeduction(const char *libraryNamespace)
Constructs an TypeIdentifierDeduction instance.
Definition: TypeIdentifierDeduction.cpp:13
Definition: DataTypeEnum.hpp:15
bool IsComplex(bool useBaseType=true) const
Checks if this data type is complex.
Definition: DataTypeEnum.cpp:75
Namespace for classes shared between PLC components
Definition: PlcStateChangedPayload.hpp:15
Root namespace for the PLCnext API
Gets the value type of a shared_ptr.
Definition: TypeDeduction.hxx:95