PLCnext API Documentation 25.0.2.69
TypeDefinition.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Core/Enumerator.hxx"
9#include "Arp/Plc/Commons/Meta/TypeInfo.hpp"
10#include "Arp/Plc/Commons/Meta/TypeSystem/FieldDefinition.hpp"
11#include <vector>
12#include <initializer_list>
13
14namespace Arp { namespace Plc { namespace Commons { namespace Meta { namespace TypeSystem
15{
16
17class TypeDomain;
18class FieldDefinition;
19
23{
24 friend class TypeDomain;
25 friend class FieldDefinition;
26
27public: // typedefs
28 using Fields = std::vector<FieldDefinition>;
29 using FieldList = std::initializer_list<FieldDefinition>;
30
31private: // nested typed
33
34public: // construction/destruction
36 TypeDefinition(DataType dataType, const String& typeName, size_t size, size_t alignment, const FieldList& fields);
37 TypeDefinition(DataType dataType, const String& typeName, size_t size, size_t alignment, StandardAttribute standardAttributes, const FieldList& fields);
38 TypeDefinition(DataType dataType, const String& typeName, size_t size, size_t alignment, StandardAttribute standardAttributes, const CustomAttributes& customAttributes, const FieldList& fields);
39
44 ~TypeDefinition(void) noexcept;
45
46public: // setter/getter operations
47 TypeInfo& GetTypeInfo(void);
48 const TypeInfo& GetTypeInfo(void)const;
49 Fields& GetFields(void);
50 const Fields& GetFields(void)const;
51
52public: // operations
54
55 void ReserveFields(size_t numFields);
56 void AddField(FieldDefinition&& field);
57
58private: // methods
59 FieldDefinition* GetField(const String& name);
60 void ResolveType(const String& libraryNamespace);
61
62private: // fields
63 String typeName;
64 TypeInfo typeInfo;
65 Fields fields;
66};
67
68}}}}} // end of namespace Arp::Plc::Commons::Meta::TypeSystem
Declares the interface of the enumerator pattern, which is leaned on .NET enumerator idiom.
Definition: IEnumerator.hxx:49
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Provides detailed type information within TypeBrowser interface.
Definition: TypeInfo.hpp:28
Defines meta infomration about one field in a type
Definition: FieldDefinition.hpp:19
IEnumerator over the children of the type
Definition: TypeDefinition.cpp:13
Defines the meta information of a type
Definition: TypeDefinition.hpp:23
void AddField(FieldDefinition &&field)
Add infomration about one field
Definition: TypeDefinition.cpp:136
IEnumerator< ChildTypeInfo >::Ptr CreateChildTypeInfoEnumerator(void)
Returns an IEnumerator over the type's fields as ChildTypeInfo
Definition: TypeDefinition.cpp:95
TypeDefinition & operator=(const TypeDefinition &arg)
Copy assignment operator.
TypeInfo & GetTypeInfo(void)
Returns the TypeInfo of this type
Definition: TypeDefinition.cpp:71
~TypeDefinition(void) noexcept
Destructs this instance and frees all resources.
TypeDefinition & operator=(TypeDefinition &&arg) noexcept
Move assignment operator.
Fields & GetFields(void)
Returns a reference to the type's fields
Definition: TypeDefinition.cpp:83
TypeDefinition(void)
Constructs an TypeDefinition instance.
TypeDefinition(TypeDefinition &&arg) noexcept
Move constructor.
void ReserveFields(size_t numFields)
Allocate memory for fields
Definition: TypeDefinition.cpp:128
TypeDefinition(const TypeDefinition &arg)
Copy constructor.
Container for the type information of a library
Definition: TypeDomain.hpp:26
std::vector< CustomAttribute > CustomAttributes
List of type attributes TypeAttribute.
Definition: CustomAttributes.hpp:15
StandardAttribute
Standard attributes to types
Definition: StandardAttribute.hpp:18
Root namespace for the PLCnext API