 |
helics
3.0.1
|
9 #include "LocalFederateId.hpp"
22 constexpr IdentifierBaseType gGlobalBrokerIdShift{0x7000'0000};
32 constexpr
explicit GlobalBrokerId(BaseType val) noexcept: gid(val) {}
34 constexpr BaseType
baseValue()
const {
return gid; }
42 bool isFederate()
const
49 return (gid != invalid_global_broker_id && gid != detail::gInvalidInterfaceHandle);
54 BaseType gid = invalid_global_broker_id;
55 friend class GlobalFederateId;
56 static constexpr BaseType invalid_global_broker_id{-2
'010'000
'000};
60 constexpr GlobalBrokerId parent_broker_id{0};
62 constexpr GlobalBrokerId root_broker_id{1};
66 std::ostream& operator<<(std::ostream& os, GlobalBrokerId id);
68 class GlobalFederateId {
70 using BaseType = IdentifierBaseType;
72 constexpr GlobalFederateId() = default;
74 constexpr explicit GlobalFederateId(BaseType val) noexcept: gid(val) {}
76 constexpr GlobalFederateId(GlobalBrokerId id) noexcept: gid(id.gid) {} // NOLINT
78 constexpr operator GlobalBrokerId() const noexcept { return GlobalBrokerId{gid}; } // NOLINT
80 constexpr BaseType baseValue() const { return gid; }
82 bool operator==(GlobalFederateId id) const noexcept { return (gid == id.gid); }
84 bool operator!=(GlobalFederateId id) const noexcept { return (gid != id.gid); }
86 bool operator<(GlobalFederateId id) const noexcept { return (gid < id.gid); }
88 bool operator>(GlobalFederateId id) const noexcept { return (gid > id.gid); }
90 bool operator==(GlobalBrokerId id) const noexcept { return (gid == id.gid); }
92 bool operator!=(GlobalBrokerId id) const noexcept { return (gid != id.gid); }
94 bool operator<(GlobalBrokerId id) const noexcept { return (gid < id.gid); }
96 bool operator>(GlobalBrokerId id) const noexcept { return (gid > id.gid); }
98 bool isFederate() const
100 return ((gid >= gGlobalFederateIdShift) && (gid < gGlobalBrokerIdShift));
103 bool isBroker() const { return (gid >= gGlobalBrokerIdShift || gid == 1); }
107 return (gid != invalid_global_fed_id && gid != detail::gInvalidInterfaceHandle);
111 constexpr BaseType localIndex() const { return gid - gGlobalFederateIdShift; }
114 BaseType* getBaseTypePointer() { return &gid; }
117 static constexpr BaseType invalid_global_fed_id{-2'010
'000'000};
118 BaseType gid{invalid_global_fed_id};
125 std::ostream&
operator<<(std::ostream& os, GlobalFederateId
id);
138 explicit operator uint64_t()
const
141 key +=
static_cast<uint64_t
>(
handle.
baseValue()) & (0x0000
'0000'FFFF
'FFFF);
145 bool operator==(GlobalHandle id) const noexcept
147 return ((fed_id == id.fed_id) && (handle == id.handle));
150 bool operator!=(GlobalHandle id) const noexcept
152 return ((fed_id != id.fed_id) || (handle != id.handle));
155 bool operator<(GlobalHandle id) const noexcept
157 return (fed_id < id.fed_id) ? true : ((fed_id != id.fed_id) ? false : (handle < id.handle));
160 bool isValid() const { return fed_id.isValid() && handle.isValid(); }
165 std::ostream& operator<<(std::ostream& os, GlobalHandle id);
170 using BaseType = IdentifierBaseType;
172 constexpr route_id() = default;
174 constexpr explicit route_id(BaseType val) noexcept: rid(val) {}
176 constexpr BaseType baseValue() const { return rid; }
178 bool operator==(route_id id) const noexcept { return (rid == id.rid); }
180 bool operator!=(route_id id) const noexcept { return (rid != id.rid); }
182 bool operator<(route_id id) const noexcept { return (rid < id.rid); }
184 bool isValid() const { return (rid != invalid_route_id); }
187 static constexpr BaseType invalid_route_id{-1'295
'148'000};
188 BaseType rid{invalid_route_id};
191 constexpr route_id parent_route_id{0};
192 constexpr route_id control_route{-1};
194 constexpr route_id generateRouteId(int32_t route_type_code, int32_t index)
196 return route_id(route_type_code * 256 * 256 * 256 + index);
199 constexpr int32_t getRouteTypeCode(route_id rid)
201 return (rid.baseValue() >> 24);
204 constexpr int32_t normal_route_code{0};
205 constexpr int32_t json_route_code{10};
208 std::ostream&
operator<<(std::ostream& os, route_id
id);
222 return std::hash<helics::GlobalFederateId::BaseType>{}(key.baseValue());
235 return std::hash<helics::GlobalBrokerId::BaseType>{}(key.baseValue());
248 return std::hash<helics::route_id::BaseType>{}(key.baseValue());
262 return std::hash<uint64_t>{}(
static_cast<uint64_t
>(key));
constexpr BaseType baseValue() const
Definition: GlobalFederateId.hpp:80
std::ostream & operator<<(std::ostream &os, const ActionMessage &command)
Definition: ActionMessage.cpp:913
std::size_t result_type
typedef for output result
Definition: GlobalFederateId.hpp:231
constexpr GlobalBrokerId()=default
constexpr IdentifierBaseType gGlobalBrokerIdShift
Definition: GlobalFederateId.hpp:22
constexpr GlobalFederateId direct_core_id
Definition: GlobalFederateId.hpp:121
constexpr GlobalHandle(GlobalFederateId fed, InterfaceHandle hand)
Definition: GlobalFederateId.hpp:135
Definition: LocalFederateId.hpp:65
result_type operator()(argument_type const &key) const noexcept
Definition: GlobalFederateId.hpp:260
constexpr BaseType baseValue() const
Definition: GlobalFederateId.hpp:34
Definition: GlobalFederateId.hpp:68
std::size_t result_type
typedef for output result
Definition: GlobalFederateId.hpp:244
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:131
result_type operator()(argument_type const &key) const noexcept
Definition: GlobalFederateId.hpp:233
Definition: GlobalFederateId.hpp:168
std::size_t result_type
typedef for output result
Definition: GlobalFederateId.hpp:258
int32_t IdentifierBaseType
Definition: LocalFederateId.hpp:15
result_type operator()(argument_type const &key) const noexcept
Definition: GlobalFederateId.hpp:246
std::size_t result_type
typedef for output result
Definition: GlobalFederateId.hpp:218
bool operator!=(GlobalBrokerId id) const noexcept
Definition: GlobalFederateId.hpp:38
Definition: GlobalFederateId.hpp:26
bool operator<(GlobalBrokerId id) const noexcept
Definition: GlobalFederateId.hpp:40
bool operator==(GlobalBrokerId id) const noexcept
Definition: GlobalFederateId.hpp:36
constexpr BaseType baseValue() const
Definition: LocalFederateId.hpp:73
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
constexpr GlobalHandle()=default
constexpr IdentifierBaseType gGlobalFederateIdShift
Definition: GlobalFederateId.hpp:20
Definition: GlobalFederateId.hpp:128
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:130
result_type operator()(argument_type const &key) const noexcept
Definition: GlobalFederateId.hpp:220