PLCnext API Documentation 25.0.2.69
DataTag.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Plc/Commons/DataTypeEnum.hpp"
9#include "Arp/Plc/Commons/Meta/TypeIdentifier.hpp"
10#include "Arp/Base/Rsc/Commons/RscSerializable.hpp"
11#include "Arp/Base/Commons/Exceptions/InvalidOperationException.hpp"
12
13namespace Arp { namespace Plc { namespace Commons { namespace Meta
14{
15
16using namespace Arp::Base::Rsc::Commons;
17
18//forwards
19class DataInfo;
21
24{
25 friend class DataInfo;
26
27public: // construction/destruction
29 DataTag(void) = default;
31 DataTag(const String& name, byte* valueAddress, DataType dataType, const TypeIdentifier& typeId, bool isBackgroundDomain = false);
33 DataTag(const DataTag& arg) = default;
35 DataTag(DataTag&& arg) = default;
37 DataTag& operator=(const DataTag& arg) = default;
39 DataTag& operator=(DataTag&& arg) = default;
41 ~DataTag(void) = default;
42
43public: // setter/getter operations
46 bool IsEmpty(void)const;
47
50 const String& GetName(void)const;
51
53 void SetDataType(DataType value);
54
58
61 const DataTypeEnum& GetDataType(void)const;
62
66
70
72 void SetValueAddress(byte* value);
73
76 byte* GetDataAddress(void)const;
77
80 byte* GetVariableAddress(void)const;
81
84 byte* GetChangeCounterpartAddress(void)const;
85
88 bool IsBackgroundDomain(void)const;
89
92 bool& IsBackgroundDomain(void);
93
96 bool IsNullPointer(void)const;
97
100 bool IsChangeCounterpartNullPointer(void)const;
101
104 bool IsEmptyOrNullPointer(void)const;
105
106public: // operations
108 void ResolveIndirection(void);
109
111 void ShiftValueAddress(size_t offset);
112
115 void SetChangeCounterpart(byte* value, byte* typeTag);
116
119 void SetChangeCounterpart(const DataTag& changeCounterpart);
120
123 void GetChangeInfo(byte*& valueAddressOut, byte*& changeCounterpartAddressOut, bool& isBackgroundDomainOut)const;
124
127 void Change(IChangeNavigator* pChangeNavigator);
128
129public: // RscSerializable operations
130 void Serialize(RscWriter& writer)const;
131 void Deserialize(RscReader& reader);
132 static size_t GetFieldCount(void);
133
134private: // methods
135 void SetName(const String& value);
136 void SwapDomain(void);
137
138private: // static methods
139 static byte* ResolveIndirectAddress(byte* address);
140
141private: // fields
142 String name;
143 DataTypeEnum dataType = DataType::None;
144 TypeIdentifier typeId;
145 byte* variableAddress = nullptr;
146 byte* changeCounterpartAddress = nullptr;
147 bool isBackgroundDomain = false;
148};
149
150}}}} // end of namespace Arp::Plc::Meta
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
Provides detailed informations for the respective data object.
Definition: DataInfo.hpp:29
Includes kind as well as instance browse name.
Definition: DataTag.hpp:24
byte * GetVariableAddress(void) const
For internal use only.
Definition: DataTag.cpp:90
DataTag(const DataTag &arg)=default
Constructs an DataTag instance.
bool IsChangeCounterpartNullPointer(void) const
Only for internal using.
Definition: DataTag.cpp:131
bool IsEmpty(void) const
Determines if this instance is empty.
Definition: DataTag.cpp:24
DataTag(DataTag &&arg)=default
Move constructor.
DataTag(void)=default
Constructs an DataTag instance.
void ResolveIndirection(void)
Resolves the value address if this is an indirect data type like reference or pointer.
Definition: DataTag.cpp:152
void SetChangeCounterpart(byte *value, byte *typeTag)
For internal use only.
Definition: DataTag.cpp:95
bool IsNullPointer(void) const
Only for internal using.
Definition: DataTag.cpp:126
void GetChangeInfo(byte *&valueAddressOut, byte *&changeCounterpartAddressOut, bool &isBackgroundDomainOut) const
For internal use only.
Definition: DataTag.cpp:173
DataTag & operator=(DataTag &&arg)=default
Move assignment operator
bool IsBackgroundDomain(void) const
Only for internal using.
Definition: DataTag.cpp:116
void ShiftValueAddress(size_t offset)
Shifts the value address for the given offset .
Definition: DataTag.cpp:69
TypeIdentifier & GetTypeIdentifier(void)
Returns the type identifier of this instance.
Definition: DataTag.cpp:54
void SetValueAddress(byte *value)
Sets the value address of this instance.
Definition: DataTag.cpp:64
void SetDataType(DataType value)
Sets the data type.
Definition: DataTag.cpp:39
DataTypeEnum & GetDataType(void)
The data type of this instance.
Definition: DataTag.cpp:44
byte * GetDataAddress(void) const
For internal use only.
Definition: DataTag.cpp:74
byte * GetChangeCounterpartAddress(void) const
For internal use only.
Definition: DataTag.cpp:100
void Change(IChangeNavigator *pChangeNavigator)
For internal use only.
Definition: DataTag.cpp:187
bool & IsBackgroundDomain(void)
Only for internal using.
const TypeIdentifier & GetTypeIdentifier(void) const
Returns the type identifier of this instance.
const String & GetName(void) const
Provides data browsing instance naming for this object.
Definition: DataTag.cpp:34
~DataTag(void)=default
Destructs this instance and frees all resources.
bool IsEmptyOrNullPointer(void) const
Only for internal using.
Definition: DataTag.cpp:136
DataTag & operator=(const DataTag &arg)=default
Copy assignment operator.
const DataTypeEnum & GetDataType(void) const
The data type of this instance.
Enables switching of counterparts during download change
Definition: IChangeNavigator.hpp:17
Identifies a type descriptions
Definition: TypeIdentifier.hpp:25
Definition: DataTypeEnum.hpp:15
Root namespace for the PLCnext API