PLCnext API Documentation 23.6.0.37
ArrayDimension.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8
9#include "Arp/System/Rsc/Services/IRscSerializable.hpp"
10#include "Arp/System/Rsc/Services/RscReader.hpp"
11#include "Arp/System/Rsc/Services/RscString.hxx"
12#include "Arp/System/Rsc/Services/RscWriter.hpp"
13
14namespace Arp { namespace Plc { namespace Commons { namespace Meta
15{
16
17using namespace Arp::System::Rsc::Services;
18
21{
22public: // typedefs
23
24public: // construction/destruction
26 ArrayDimension(void) = default;
28 explicit ArrayDimension(size_t count);
30 ArrayDimension(uint32 count, int32 offset);
32 ArrayDimension(const ArrayDimension& arg) = default;
36 ArrayDimension& operator=(const ArrayDimension& arg) = default;
40 ~ArrayDimension(void) override = default;
41
42public: // operators
43
44public: // setter/getter operations
47 uint32 GetCount(void)const;
48
51 int32 GetOffset(void)const;
52
55 static size_t GetCacheSize(void);
56
57public: // IRscSerializable operations
58 void Serialize(RscWriter& writer)const override;
59 void Deserialize(RscReader& reader)override;
60 static size_t GetFieldCount(void);
61
62private: // static methods
63
64private: // methods
65
66private: // fields
67 uint32 count = 0;
68 int32 offset = 0;
69
70private: // static fields
71
72};
73
75// inline methods of class ArrayDimension
76
78{
79 return this->count;
80}
81
83{
84 return this->offset;
85}
86
87inline size_t ArrayDimension::GetFieldCount(void)
88{
89 return 2;
90}
91
93{
94 size_t cacheSize = 0;
95 cacheSize += sizeof(count);
96 cacheSize += sizeof(offset);
97
98 return cacheSize;
99}
100
101inline bool operator==(const ArrayDimension& lhs, const ArrayDimension& rhs)
102{
103 return (lhs.GetCount() == rhs.GetCount()) && (lhs.GetOffset() == rhs.GetOffset());
104}
105
106inline bool operator!= (const ArrayDimension& lhs, const ArrayDimension& rhs)
107{
108 return !(lhs == rhs);
109}
110
111inline bool operator< (const ArrayDimension& lhs, const ArrayDimension& rhs)
112{
113 return (lhs.GetCount() < rhs.GetCount()) || ((lhs.GetCount() == rhs.GetCount()) && (lhs.GetOffset() < rhs.GetOffset()));
114}
115
116inline std::ostream& operator<<(std::ostream& os, const ArrayDimension& rhs)
117{
118 os << "[";
119 if (rhs.GetOffset() != 0)
120 {
121 os << rhs.GetOffset() << "," ;
122 }
123 os << rhs.GetCount() << "]";
124 return os;
125}
126
127}}}} // end of namespace Arp::Plc::Meta
Provide array information.
Definition: ArrayDimension.hpp:21
ArrayDimension(ArrayDimension &&arg)=default
Move constructor.
int32 GetOffset(void) const
Get the index offset of the array for this vector element
Definition: ArrayDimension.hpp:82
uint32 GetCount(void) const
Get the number of array elements for this vector element.
Definition: ArrayDimension.hpp:77
void Deserialize(RscReader &reader) override
Deserializes the datatype. All fields of the datatype have to be deserialized in use of RscReader.
~ArrayDimension(void) override=default
Destructs this instance and frees all resources.
static size_t GetCacheSize(void)
Get the cache size
Definition: ArrayDimension.hpp:92
ArrayDimension(uint32 count, int32 offset)
Constructs an ArrayDimension instance.
void Serialize(RscWriter &writer) const override
Serializes the datatype. All fields of the datatype have to be serialized in use of RscWriter.
ArrayDimension & operator=(ArrayDimension &&arg)=default
Move assignment operator.
ArrayDimension(const ArrayDimension &arg)=default
Copy constructor.
ArrayDimension(void)=default
Constructs an ArrayDimension instance.
ArrayDimension(size_t count)
Constructs an ArrayDimension instance.
ArrayDimension & operator=(const ArrayDimension &arg)=default
Copy assignment operator.
Marshalls structure or class data types. Serialize and Deserialize have to marshal fields in the same...
Definition: IRscSerializable.hpp:20
Reads data from Rsc
Definition: RscReader.hpp:27
Writes data to Rsc.
Definition: RscWriter.hpp:32
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:36
std::int32_t int32
The Arp integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:38
Namespace for classes and interfaces for the Remote Service Call implementation
Root namespace for the PLCnext API