ChimeraTK-DeviceAccess  03.18.00
TransferElementID.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 #pragma once
4 
5 #include <cstddef>
6 #include <functional>
7 #include <iosfwd>
8 
9 namespace ChimeraTK {
10 
11  /********************************************************************************************************************/
12 
18  public:
22  TransferElementID() = default;
23 
27  TransferElementID(const TransferElementID& other) = default;
28 
32  bool operator==(const TransferElementID& other) const { return (_id != 0) && (_id == other._id); }
33  bool operator!=(const TransferElementID& other) const { return !(operator==(other)); }
34 
36  [[nodiscard]] bool isValid() const { return _id != 0; }
37 
39  TransferElementID& operator=(const TransferElementID& other) = default;
40 
41  protected:
45  void makeUnique();
46 
48  size_t _id{0};
49 
50  // Hash function for putting TransferElement::ID e.g. into an std::unordered_map
51  friend struct std::hash<TransferElementID>;
52 
53  // Comparison for putting TransferElement::ID e.g. into an std::map
54  friend struct std::less<TransferElementID>;
55 
56  friend std::ostream& operator<<(std::ostream& os, const TransferElementID& me);
57  friend class TransferElement;
58  };
59 
60  /********************************************************************************************************************/
61 
65  std::ostream& operator<<(std::ostream& os, const TransferElementID& me);
66 
67  /********************************************************************************************************************/
68 
69 } // namespace ChimeraTK
ChimeraTK::TransferElementID::operator=
TransferElementID & operator=(const TransferElementID &other)=default
Assign ID from another.
ChimeraTK::TransferElementID::isValid
bool isValid() const
Check whether the ID is valid.
Definition: TransferElementID.h:36
ChimeraTK::TransferElementID::makeUnique
void makeUnique()
Assign an ID to this instance.
Definition: TransferElementID.cc:14
ChimeraTK::TransferElementID::operator==
bool operator==(const TransferElementID &other) const
Compare ID with another.
Definition: TransferElementID.h:32
ChimeraTK::TransferElementID::_id
size_t _id
The actual ID value.
Definition: TransferElementID.h:48
ChimeraTK::TransferElementID::TransferElementID
TransferElementID()=default
Default constructor constructs an invalid ID, which may be assigned with another ID.
ChimeraTK::TransferElement
Base class for register accessors which can be part of a TransferGroup.
Definition: TransferElement.h:67
ChimeraTK::operator<<
std::ostream & operator<<(std::ostream &stream, const DataDescriptor::FundamentalType &fundamentalType)
Definition: DataDescriptor.cpp:195
ChimeraTK::TransferElementID::operator<<
friend std::ostream & operator<<(std::ostream &os, const TransferElementID &me)
Streaming operator to stream the TransferElementID e.g.
Definition: TransferElementID.cc:24
ChimeraTK::TransferElementID::operator!=
bool operator!=(const TransferElementID &other) const
Definition: TransferElementID.h:33
ChimeraTK::TransferElementID
Simple class holding a unique ID for a TransferElement.
Definition: TransferElementID.h:17
ChimeraTK
Definition: DummyBackend.h:16