 |
helics
2.8.1
|
9 #include "federate_id.hpp"
22 constexpr identififier_base_type global_broker_id_shift{0x7000'0000};
34 constexpr base_type
baseValue()
const {
return gid; }
42 bool isFederate()
const
49 return (gid != invalid_global_broker_id && gid != detail::invalid_interface_handle);
54 base_type gid = invalid_global_broker_id;
55 friend class global_federate_id;
56 static constexpr base_type invalid_global_broker_id{-2
'010'000
'000};
60 constexpr global_broker_id parent_broker_id{0};
62 constexpr global_broker_id root_broker_id{1};
66 std::ostream& operator<<(std::ostream& os, global_broker_id id);
68 class global_federate_id {
70 using base_type = identififier_base_type;
72 constexpr global_federate_id() = default;
74 constexpr explicit global_federate_id(base_type val) noexcept: gid(val) {}
76 constexpr global_federate_id(global_broker_id id) noexcept: gid(id.gid) {} // NOLINT
78 constexpr operator global_broker_id() const noexcept
80 return global_broker_id{gid};
83 constexpr base_type baseValue() const { return gid; }
85 bool operator==(global_federate_id id) const noexcept { return (gid == id.gid); }
87 bool operator!=(global_federate_id id) const noexcept { return (gid != id.gid); }
89 bool operator<(global_federate_id id) const noexcept { return (gid < id.gid); }
91 bool operator>(global_federate_id id) const noexcept { return (gid > id.gid); }
93 bool operator==(global_broker_id id) const noexcept { return (gid == id.gid); }
95 bool operator!=(global_broker_id id) const noexcept { return (gid != id.gid); }
97 bool operator<(global_broker_id id) const noexcept { return (gid < id.gid); }
99 bool operator>(global_broker_id id) const noexcept { return (gid > id.gid); }
101 bool isFederate() const
103 return ((gid >= global_federate_id_shift) && (gid < global_broker_id_shift));
106 bool isBroker() const { return (gid >= global_broker_id_shift || gid == 1); }
110 return (gid != invalid_global_fed_id && gid != detail::invalid_interface_handle);
114 constexpr base_type localIndex() const { return gid - global_federate_id_shift; }
117 static constexpr base_type invalid_global_fed_id{-2'010
'000'000};
118 base_type gid{invalid_global_fed_id};
125 std::ostream&
operator<<(std::ostream& os, global_federate_id
id);
141 explicit operator uint64_t()
const
144 key +=
static_cast<uint64_t
>(
handle.
baseValue()) & (0x0000
'0000'FFFF
'FFFF);
148 bool operator==(global_handle id) const noexcept
150 return ((fed_id == id.fed_id) && (handle == id.handle));
153 bool operator!=(global_handle id) const noexcept
155 return ((fed_id != id.fed_id) || (handle != id.handle));
158 bool operator<(global_handle id) const noexcept
160 return (fed_id < id.fed_id) ? true : ((fed_id != id.fed_id) ? false : (handle < id.handle));
163 bool isValid() const { return fed_id.isValid() && handle.isValid(); }
168 std::ostream& operator<<(std::ostream& os, global_handle id);
173 using base_type = identififier_base_type;
175 constexpr route_id() = default;
177 constexpr explicit route_id(base_type val) noexcept: rid(val) {}
179 constexpr base_type baseValue() const { return rid; }
181 bool operator==(route_id id) const noexcept { return (rid == id.rid); }
183 bool operator!=(route_id id) const noexcept { return (rid != id.rid); }
185 bool operator<(route_id id) const noexcept { return (rid < id.rid); }
187 bool isValid() const { return (rid != invalid_route_id); }
190 static constexpr base_type invalid_route_id{-1'295
'148'000};
191 base_type rid{invalid_route_id};
194 constexpr route_id parent_route_id{0};
195 constexpr route_id control_route{-1};
197 constexpr route_id generateRouteId(int32_t route_type_code, int32_t index)
199 return route_id(route_type_code * 256 * 256 * 256 + index);
202 constexpr int32_t getRouteTypeCode(route_id rid)
204 return (rid.baseValue() >> 24);
207 constexpr int32_t normal_route_code{0};
208 constexpr int32_t json_route_code{10};
211 std::ostream&
operator<<(std::ostream& os, route_id
id);
219 struct hash<
helics::global_federate_id> {
225 return std::hash<helics::global_federate_id::base_type>{}(key.baseValue());
238 return std::hash<helics::global_broker_id::base_type>{}(key.baseValue());
251 return std::hash<helics::route_id::base_type>{}(key.baseValue());
265 return std::hash<uint64_t>{}(
static_cast<uint64_t
>(key));
bool operator==(global_broker_id id) const noexcept
Definition: global_federate_id.hpp:36
std::ostream & operator<<(std::ostream &os, const ActionMessage &command)
Definition: ActionMessage.cpp:933
constexpr base_type baseValue() const
Definition: federate_id.hpp:73
std::size_t result_type
typedef for output result
Definition: global_federate_id.hpp:234
constexpr identififier_base_type global_broker_id_shift
Definition: global_federate_id.hpp:22
Definition: global_federate_id.hpp:26
Definition: global_federate_id.hpp:68
std::size_t result_type
typedef for output result
Definition: global_federate_id.hpp:247
constexpr base_type baseValue() const
Definition: global_federate_id.hpp:34
global_federate_id fed_id
the federate id component
Definition: global_federate_id.hpp:130
interface_handle handle
the interface handle component
Definition: global_federate_id.hpp:131
constexpr global_broker_id()=default
Definition: global_federate_id.hpp:171
std::size_t result_type
typedef for output result
Definition: global_federate_id.hpp:221
int32_t identififier_base_type
Definition: federate_id.hpp:15
Definition: global_federate_id.hpp:128
constexpr base_type baseValue() const
Definition: global_federate_id.hpp:83
constexpr global_federate_id direct_core_id
Definition: global_federate_id.hpp:121
result_type operator()(argument_type const &key) const noexcept
Definition: global_federate_id.hpp:249
@ fed
special logging command for message coming from a fed
Definition: loggingHelper.hpp:32
Definition: federate_id.hpp:65
bool operator!=(global_broker_id id) const noexcept
Definition: global_federate_id.hpp:38
result_type operator()(argument_type const &key) const noexcept
Definition: global_federate_id.hpp:236
bool operator<(global_broker_id id) const noexcept
Definition: global_federate_id.hpp:40
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
constexpr global_handle(global_federate_id fed, interface_handle hand)
Definition: global_federate_id.hpp:135
result_type operator()(argument_type const &key) const noexcept
Definition: global_federate_id.hpp:223
std::size_t result_type
typedef for output result
Definition: global_federate_id.hpp:261
constexpr global_handle()=default
result_type operator()(argument_type const &key) const noexcept
Definition: global_federate_id.hpp:263
constexpr identififier_base_type global_federate_id_shift
Definition: global_federate_id.hpp:20