Skip to content

Commit ee680a7

Browse files
committed
Explicit copy c-tors for DCS data classes
1 parent dca327a commit ee680a7

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

Detectors/DCS/include/DetectorsDCS/DataPointCompositeObject.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ struct alignas(128) DataPointCompositeObject final {
7979
const DataPointIdentifier& id,
8080
const DataPointValue& data) noexcept : id(id), data(data) {}
8181

82+
/**
83+
* Copy constructor
84+
*/
85+
DataPointCompositeObject(const DataPointCompositeObject& src) noexcept : DataPointCompositeObject(src.id, src.data) {}
86+
87+
DataPointCompositeObject& operator=(const DataPointCompositeObject& src) noexcept
88+
{
89+
if (&src != this) {
90+
memcpy(this, &src, sizeof(DataPointCompositeObject));
91+
}
92+
return *this;
93+
}
94+
8295
/**
8396
* Bit-by bit equality comparison of DataPointCompositeObjects.
8497
*
@@ -278,6 +291,25 @@ template <typename T>
278291
T getValue(const DataPointCompositeObject& dpcom);
279292

280293
} // namespace dcs
294+
295+
/// Defining DataPointCompositeObject explicitly as messageable
296+
namespace framework
297+
{
298+
template <typename T>
299+
struct is_messageable;
300+
template <>
301+
struct is_messageable<o2::dcs::DataPointCompositeObject> : std::true_type {
302+
};
303+
} // namespace framework
304+
281305
} // namespace o2
282306

307+
/// Defining DataPointCompositeObject explicitly as copiable
308+
namespace std
309+
{
310+
template <>
311+
struct is_trivially_copyable<o2::dcs::DataPointCompositeObject> : std::true_type {
312+
};
313+
} // namespace std
314+
283315
#endif /* O2_DCS_DATAPOINT_COMPOSITE_OBJECT_H */

Detectors/DCS/include/DetectorsDCS/DataPointIdentifier.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ class alignas(64) DataPointIdentifier final
7979
((char*)&pt8)[7] = type;
8080
}
8181

82+
/**
83+
* A copy constructor for DataPointIdentifier.
84+
*/
85+
DataPointIdentifier(const DataPointIdentifier& src) noexcept : DataPointIdentifier(src.pt1, src.pt2, src.pt3, src.pt4, src.pt5, src.pt6, src.pt7, src.pt8) {}
86+
87+
DataPointIdentifier& operator=(const DataPointIdentifier& src) noexcept
88+
{
89+
if (&src != this) {
90+
memcpy(this, &src, sizeof(DataPointIdentifier));
91+
}
92+
return *this;
93+
}
94+
8295
/**
8396
* This stati procedure fills the given DataPointIdentifier object with
8497
* the given parameters.
@@ -202,6 +215,16 @@ struct DPIDHash {
202215
};
203216
} // namespace dcs
204217

218+
/// Defining DataPointIdentifier explicitly as messageable
219+
namespace framework
220+
{
221+
template <typename T>
222+
struct is_messageable;
223+
template <>
224+
struct is_messageable<o2::dcs::DataPointIdentifier> : std::true_type {
225+
};
226+
} // namespace framework
227+
205228
} // namespace o2
206229

207230
// specailized std::hash
@@ -214,6 +237,11 @@ struct hash<o2::dcs::DataPointIdentifier> {
214237
return std::hash<uint64_t>{}(dpid.hash_code());
215238
}
216239
};
240+
241+
template <>
242+
struct is_trivially_copyable<o2::dcs::DataPointIdentifier> : std::true_type {
243+
};
244+
217245
} // namespace std
218246

219247
#endif /* O2_DCS_DATAPOINT_IDENTIFIER_H */

0 commit comments

Comments
 (0)