| helics 3.6.1

flagOperations.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2025,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
12 #include <cstdint>
13
14 namespace helics {
16 enum GeneralFlags : uint16_t {
17 error_flag = 4,
18 indicator_flag = 5,
19 };
20
22 enum TimingFlags : uint16_t {
23 iteration_requested_flag = 0,
25 non_granting_flag = 7,
26
28 interrupted_flag = 8,
30 delayed_timing_flag = 10,
32 parent_flag = 13,
33
35 child_flag = 14
36 };
37
39 enum InterfaceFlags : uint16_t {
41 buffer_data_flag = 0,
43 destination_target = 1,
45 required_flag = 2,
47 single_connection_flag = 3,
49 only_update_on_change_flag = 6,
51 reconnectable_flag = 7,
53 optional_flag = 8,
54
55 // 9,10,11,13,14 are interface specific
56
58 only_transmit_on_change_flag = 12,
59
61 nameless_interface_flag = 15
62 };
63
65 enum EndpointFlags {
67 targeted_flag = 10,
68
70 has_source_filter_flag = 11,
72 source_only_flag = 13,
74 receive_only_flag = 14
75 };
76
78 enum FilterFlags {
80 clone_flag = 9,
82 has_dest_filter_flag = 13,
84 has_non_cloning_dest_filter_flag = 14,
85 };
86
88 enum ConnectionFlags : uint16_t {
90 core_flag = 3,
92 global_timing_flag = 5,
93
95 use_json_serialization_flag = 6,
97 async_timing_flag = 7,
99 observer_flag = 8,
101 dynamic_join_flag = 9,
103 reentrant_flag = 10,
105 global_disconnect_flag = 11,
107 disconnected_flag = 12,
109 test_connection_flag = 13,
111 slow_responding_flag = 14,
113 non_counting_flag = 15
114
115 };
116
118 enum MessageFlags : uint16_t {
120 filter_processing_required_flag = 7,
122 user_custom_message_flag1 = 10,
124 destination_processing_flag = 11,
127 user_custom_message_flag2 = 13,
129 user_custom_message_flag3 = 14,
130 empty_flag = 15,
131 };
132
134 enum OperationFlags : uint16_t {
136 cancel_flag = 13
137 };
138
139 // extra_flag1 = 7, //!< extra flag
140
141 // extra_flag2 = 10, //!< extra flag
142
143 // extra_flag3 = 13, //!< extra flag
144 // extra_flag4 = 14, //!< extra flag
145
152 template<class FlagContainer, class FlagIndex>
153 inline void setActionFlag(FlagContainer& M, FlagIndex flag)
154 {
155 M.flags |= (static_cast<decltype(M.flags)>((1U) << (static_cast<uint16_t>((flag)))));
156 }
157
160 template<class FlagIndex>
161 inline bool checkActionFlag(uint16_t flags, FlagIndex flag)
162 {
163 return ((flags & (static_cast<uint16_t>((1U) << (static_cast<uint16_t>((flag)))))) != 0U);
164 }
165
167 template<class FlagContainer, class FlagIndex>
168 inline bool checkActionFlag(const FlagContainer& M, FlagIndex flag)
169 {
170 return ((M.flags & (static_cast<decltype(M.flags)>((1U) << (static_cast<uint16_t>((flag)))))) !=
171 0U);
172 }
173
175 template<class FlagContainer, class FlagIndex>
176 inline void clearActionFlag(FlagContainer& M, FlagIndex flag)
177 {
178 M.flags &= static_cast<decltype(M.flags)>(~((1U) << (static_cast<uint16_t>((flag)))));
179 }
180
182 template<class FlagContainer, class FlagIndex>
183 inline void toggleActionFlag(FlagContainer& M, FlagIndex flag)
184 {
185 if (checkActionFlag(M, flag)) {
186 clearActionFlag(M, flag);
187 } else {
188 setActionFlag(M, flag);
189 }
190 }
191
193 inline constexpr uint16_t make_flags(unsigned int flag)
194 {
195 return static_cast<uint16_t>(1U << (flag));
196 }
197
199 inline constexpr uint16_t make_flags(unsigned int flag1, unsigned int flag2)
200 {
201 return make_flags(flag1) | make_flags(flag2);
202 }
203
205 inline constexpr uint16_t make_flags(unsigned int flag1, unsigned int flag2, unsigned int flag3)
206 {
207 return make_flags(flag1, flag2) | make_flags(flag3);
208 }
209
211 inline constexpr uint16_t toggle_flag(uint16_t base, unsigned int flag)
212 {
213 return base ^ make_flags(flag);
214 }
215 } // namespace helics
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::toggle_flag
constexpr uint16_t toggle_flag(uint16_t base, unsigned int flag)
Definition: flagOperations.hpp:211
helics::OperationFlags
OperationFlags
general flags used for other operations
Definition: flagOperations.hpp:134
helics::cancel_flag
@ cancel_flag
flag indicating an operation is canceled
Definition: flagOperations.hpp:136
helics::toggleActionFlag
void toggleActionFlag(FlagContainer &M, FlagIndex flag)
Definition: flagOperations.hpp:183
helics::setActionFlag
void setActionFlag(FlagContainer &M, FlagIndex flag)
Definition: flagOperations.hpp:153
helics::make_flags
constexpr uint16_t make_flags(unsigned int flag)
Definition: flagOperations.hpp:193
helics::ConnectionFlags
ConnectionFlags
flags used when connecting a federate/core/broker to a federation
Definition: flagOperations.hpp:88
helics::disconnected_flag
@ disconnected_flag
flag indicating that a broker/federate is disconnected
Definition: flagOperations.hpp:107
helics::global_disconnect_flag
@ global_disconnect_flag
flag indicating that global disconnect synchronize is in use
Definition: flagOperations.hpp:105
helics::dynamic_join_flag
@ dynamic_join_flag
flag indicating that the connection allows joining dynamically
Definition: flagOperations.hpp:101
helics::global_timing_flag
@ global_timing_flag
flag indicating to use global timing (overload of indicator flag)
Definition: flagOperations.hpp:92
helics::core_flag
@ core_flag
flag indicating that message comes from a core vs a broker
Definition: flagOperations.hpp:90
helics::async_timing_flag
@ async_timing_flag
flag indicating use of asynchronous timing on a global level
Definition: flagOperations.hpp:97
helics::observer_flag
@ observer_flag
flag indicating that the connection is an observer only
Definition: flagOperations.hpp:99
helics::test_connection_flag
@ test_connection_flag
flag indicating this is a test connection
Definition: flagOperations.hpp:109
helics::non_counting_flag
@ non_counting_flag
flag indicating that a federate should not count in any totals
Definition: flagOperations.hpp:113
helics::reentrant_flag
@ reentrant_flag
flag indicating that the connection may be reentrant
Definition: flagOperations.hpp:103
helics::slow_responding_flag
@ slow_responding_flag
flag indicating a federate, core or broker is slow responding
Definition: flagOperations.hpp:111
helics::use_json_serialization_flag
@ use_json_serialization_flag
flag to indicate it should use the json packetization
Definition: flagOperations.hpp:95
helics::MessageFlags
MessageFlags
flags used for messages
Definition: flagOperations.hpp:118
helics::filter_processing_required_flag
@ filter_processing_required_flag
flag indicating that the message requires processing for filters yet
Definition: flagOperations.hpp:120
helics::user_custom_message_flag2
@ user_custom_message_flag2
Definition: flagOperations.hpp:127
helics::user_custom_message_flag1
@ user_custom_message_flag1
custom message flag 1
Definition: flagOperations.hpp:122
helics::user_custom_message_flag3
@ user_custom_message_flag3
custom message flag 3
Definition: flagOperations.hpp:129
helics::destination_processing_flag
@ destination_processing_flag
flag indicating the message is for destination processing
Definition: flagOperations.hpp:124
helics::checkActionFlag
bool checkActionFlag(uint16_t flags, FlagIndex flag)
Definition: flagOperations.hpp:161
helics::clearActionFlag
void clearActionFlag(FlagContainer &M, FlagIndex flag)
Definition: flagOperations.hpp:176
helics::TimingFlags
TimingFlags
flags used in timing messages
Definition: flagOperations.hpp:22
helics::iteration_requested_flag
@ iteration_requested_flag
Definition: flagOperations.hpp:23
helics::non_granting_flag
@ non_granting_flag
flag to indicate the request is from a non-granting federate
Definition: flagOperations.hpp:25
helics::delayed_timing_flag
@ delayed_timing_flag
flag to indicate the request is from federate with delayed timing
Definition: flagOperations.hpp:30
helics::parent_flag
@ parent_flag
flag indicating the message is from a parent object
Definition: flagOperations.hpp:32
helics::child_flag
@ child_flag
flag indicating a message is from a child object
Definition: flagOperations.hpp:35
helics::interrupted_flag
@ interrupted_flag
flag to mark an interrupted event
Definition: flagOperations.hpp:28
helics::InterfaceFlags
InterfaceFlags
flags used on handles
Definition: flagOperations.hpp:39
helics::nameless_interface_flag
@ nameless_interface_flag
flag to indicate an interface is nameless
Definition: flagOperations.hpp:61
helics::only_transmit_on_change_flag
@ only_transmit_on_change_flag
indicator that the interface should only transmit on change
Definition: flagOperations.hpp:58
helics::only_update_on_change_flag
@ only_update_on_change_flag
flag indicating that the values should only be updated on change
Definition: flagOperations.hpp:49
helics::buffer_data_flag
@ buffer_data_flag
indicator that the interface should buffer data
Definition: flagOperations.hpp:41
helics::destination_target
@ destination_target
indicator that the target is a destination target
Definition: flagOperations.hpp:43
helics::single_connection_flag
@ single_connection_flag
flag indicating that the interface accepts only a single connection
Definition: flagOperations.hpp:47
helics::reconnectable_flag
@ reconnectable_flag
flag indicating that the target is mapped
Definition: flagOperations.hpp:51
helics::optional_flag
@ optional_flag
flag indicating that a connection is optional and may not be matched
Definition: flagOperations.hpp:53
helics::required_flag
@ required_flag
flag indicating that an action or match is required
Definition: flagOperations.hpp:45
helics::EndpointFlags
EndpointFlags
enumeration of endpoint specific flags
Definition: flagOperations.hpp:65
helics::receive_only_flag
@ receive_only_flag
indicator that an endpoint is receive only
Definition: flagOperations.hpp:74
helics::targeted_flag
@ targeted_flag
flag indicating an endpoint is targeted
Definition: flagOperations.hpp:67
helics::source_only_flag
@ source_only_flag
indicator that an endpoint is source only
Definition: flagOperations.hpp:72
helics::has_source_filter_flag
@ has_source_filter_flag
indicator that an endpoint or message has a source filter
Definition: flagOperations.hpp:70
helics::FilterFlags
FilterFlags
enumeration of filter specific flags
Definition: flagOperations.hpp:78
helics::has_non_cloning_dest_filter_flag
@ has_non_cloning_dest_filter_flag
indicator that the endpoint or filter has a destination filter that alters the message
Definition: flagOperations.hpp:84
helics::clone_flag
@ clone_flag
flag indicating the filter is a clone filter or the data needs to be cloned
Definition: flagOperations.hpp:80
helics::has_dest_filter_flag
@ has_dest_filter_flag
indicator that an endpoint or message has a destination filter
Definition: flagOperations.hpp:82
helics::GeneralFlags
GeneralFlags
Definition: flagOperations.hpp:16
helics::indicator_flag
@ indicator_flag
flag used for setting values
Definition: flagOperations.hpp:18
helics::error_flag
@ error_flag
flag indicating an error condition associated with the command
Definition: flagOperations.hpp:17