@@ -55,6 +55,17 @@ class TestOnlyParameter
55
55
// of underlying types.
56
56
class EcosystemDeviceStruct
57
57
{
58
+ private:
59
+ // Originally we wanted the constructor of EcosystemDeviceStruct to be private to ensure
60
+ // only Builder could construct it. This would ensure that this struct will only be
61
+ // created with values that conform to the spec. Unfortunately, std::make_unique is
62
+ // not able to call a private constructor. As a workaround, to ensure the constructor is
63
+ // only callable internally, we created this PrivateToken as a privately accessible
64
+ // parameter that needs to be passed into the constructor.
65
+ class PrivateToken
66
+ {
67
+ };
68
+
58
69
public:
59
70
class Builder
60
71
{
@@ -84,15 +95,10 @@ class EcosystemDeviceStruct
84
95
bool mIsAlreadyBuilt = false ;
85
96
};
86
97
87
- CHIP_ERROR Encode (const AttributeValueEncoder::ListEncodeHelper & aEncoder);
88
-
89
- private:
90
- // Constructor is intentionally private. This is to ensure that it is only constructed with
91
- // values that conform to the spec.
92
98
explicit EcosystemDeviceStruct (std::string && aDeviceName, uint64_t aDeviceNameLastEditEpochUs, EndpointId aBridgedEndpoint,
93
99
EndpointId aOriginalEndpoint, std::vector<Structs::DeviceTypeStruct::Type> && aDeviceTypes,
94
100
std::vector<std::string> && aUniqueLocationIds, uint64_t aUniqueLocationIdsLastEditEpochUs,
95
- FabricIndex aFabricIndex) :
101
+ FabricIndex aFabricIndex, PrivateToken _ ) :
96
102
mDeviceName(std::move(aDeviceName)),
97
103
mDeviceNameLastEditEpochUs(aDeviceNameLastEditEpochUs), mBridgedEndpoint(aBridgedEndpoint),
98
104
mOriginalEndpoint(aOriginalEndpoint), mDeviceTypes(std::move(aDeviceTypes)),
@@ -101,6 +107,9 @@ class EcosystemDeviceStruct
101
107
102
108
{}
103
109
110
+ CHIP_ERROR Encode (const AttributeValueEncoder::ListEncodeHelper & aEncoder);
111
+
112
+ private:
104
113
const std::string mDeviceName ;
105
114
uint64_t mDeviceNameLastEditEpochUs ;
106
115
EndpointId mBridgedEndpoint ;
@@ -122,6 +131,17 @@ struct LocationDescriptorStruct
122
131
// of underlying types.
123
132
class EcosystemLocationStruct
124
133
{
134
+ private:
135
+ // Originally we wanted the constructor of EcosystemLocationStruct to be private to ensure
136
+ // only Builder could construct it. This would ensure that this struct will only be
137
+ // created with values that conform to the spec. Unfortunately, std::make_unique is
138
+ // not able to call a private constructor. As a workaround, to ensure the constructor is
139
+ // only callable internally, we created this PrivateToken as a privately accessible
140
+ // parameter that needs to be passed into the constructor.
141
+ class PrivateToken
142
+ {
143
+ };
144
+
125
145
public:
126
146
class Builder
127
147
{
@@ -143,15 +163,16 @@ class EcosystemLocationStruct
143
163
bool mIsAlreadyBuilt = false ;
144
164
};
145
165
166
+ explicit EcosystemLocationStruct (LocationDescriptorStruct && aLocationDescriptor, uint64_t aLocationDescriptorLastEditEpochUs,
167
+ PrivateToken _) :
168
+ mLocationDescriptor(aLocationDescriptor),
169
+ mLocationDescriptorLastEditEpochUs(aLocationDescriptorLastEditEpochUs)
170
+ {}
171
+
146
172
CHIP_ERROR Encode (const AttributeValueEncoder::ListEncodeHelper & aEncoder, const std::string & aUniqueLocationId,
147
173
const FabricIndex & aFabricIndex);
148
174
149
175
private:
150
- // Constructor is intentionally private. This is to ensure that it is only constructed with
151
- // values that conform to the spec.
152
- explicit EcosystemLocationStruct (LocationDescriptorStruct && aLocationDescriptor, uint64_t aLocationDescriptorLastEditEpochUs) :
153
- mLocationDescriptor(aLocationDescriptor), mLocationDescriptorLastEditEpochUs(aLocationDescriptorLastEditEpochUs)
154
- {}
155
176
// EcosystemLocationStruct is used as a value in a key-value map.
156
177
// Because UniqueLocationId and FabricIndex are mandatory when an entry exist,
157
178
// and needs to be unique, we use it as a key to the key-value pair and is why it is
0 commit comments