herald  2.0.0
target_identifier.h
1 // Copyright 2020-2021 Herald Project Contributors
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #ifndef HERALD_TARGET_IDENTIFIER_H
6 #define HERALD_TARGET_IDENTIFIER_H
7 
8 #include "data.h"
9 
10 #include <string>
11 #include <memory>
12 #include <iosfwd>
13 
14 namespace herald {
15 namespace datatype {
16 
18 public:
20  TargetIdentifier(const Data& data);
21  TargetIdentifier(const TargetIdentifier& from); // copy ctor
22  TargetIdentifier& operator=(const TargetIdentifier& from); // copy assign
24 
25  bool operator==(const TargetIdentifier& other) const noexcept;
26  bool operator==(const Data& other) const noexcept;
27  bool operator!=(const TargetIdentifier& other) const noexcept;
28  bool operator!=(const Data& other) const noexcept;
29  bool operator<(const TargetIdentifier& other) const noexcept; // required for std::less
30  bool operator>(const TargetIdentifier& other) const noexcept; // required for std::less
31 
32  std::size_t hashCode() const;
33 
34  operator std::string() const;
35 
36  operator Data() const;
37 
38  Data underlyingData() const;
39 
40 private:
41  Data value;
42 
43 };
44 
45 } // end namespace
46 } // end namespace
47 
48 
49 
50 namespace std {
51  inline std::ostream& operator<<(std::ostream &os, const herald::datatype::TargetIdentifier& d)
52  {
53  return os << d.underlyingData().reversed().hexEncodedString();
54  }
55 
56  template<>
57  struct hash<herald::datatype::TargetIdentifier>
58  {
59  size_t operator()(const herald::datatype::TargetIdentifier& v) const
60  {
61  return v.hashCode();
62  }
63  };
64 } // end namespace
65 
66 #endif
The main data workhorse class of the Herald API.
Definition: data.h:33
std::string hexEncodedString() const noexcept
Returns a hex encoded string of this binary data.
Definition: data.h:443
DataRef reversed() const
Returns a new DataRef instance with the same data as this one, but in the reverse order.
Definition: data.h:405
Definition: target_identifier.h:17
DataRef<> Data
Defaults references to Data to equal the DataRef with the default Memory Arena dimensions,...
Definition: data.h:506
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15
Definition: data.h:562