9 #include "../../application_api/helicsTypes.hpp"
10 #include "../../common/GuardedTypes.hpp"
11 #include "../../core/core-data.hpp"
12 #include "../api-data.h"
13 #include "gmlc/concurrency/TripWire.hpp"
20 #include <string_view>
25 static constexpr
int gCoreValidationIdentifier = 0x3784'24EC;
26 static constexpr
int gBrokerValidationIdentifier = 0xA346'7D20;
33 class MessageFederate;
34 class CallbackFederate;
47 class TranslatorObject;
51 enum class FederateType : int { GENERIC, VALUE, MESSAGE, COMBINATION, CALLBACK, INVALID };
56 std::shared_ptr<Broker> brokerptr;
66 std::shared_ptr<Core> coreptr;
67 std::vector<std::unique_ptr<FilterObject>>
filters;
71 CoreObject() =
default;
82 std::shared_ptr<apps::App> app;
88 class PublicationObject;
93 std::vector<std::unique_ptr<Message>> messages;
94 std::vector<int> freeMessageSlots;
97 Message* addMessage(std::unique_ptr<Message>& mess);
99 std::unique_ptr<Message> extractMessage(
int index);
100 void freeMessage(
int index);
109 std::shared_ptr<Federate> fedptr;
111 std::vector<std::unique_ptr<InputObject>> inputs;
112 std::vector<std::unique_ptr<PublicationObject>> pubs;
113 std::vector<std::unique_ptr<EndpointObject>> epts;
114 std::vector<std::unique_ptr<FilterObject>> filters;
115 std::vector<std::unique_ptr<TranslatorObject>> translators;
116 std::pair<std::string, std::string> commandBuffer;
128 std::shared_ptr<ValueFederate> fedptr;
129 Input* inputPtr{
nullptr};
136 std::shared_ptr<ValueFederate> fedptr;
144 std::shared_ptr<MessageFederate> fedptr;
154 Filter* filtPtr{
nullptr};
155 std::unique_ptr<Filter> uFilter;
156 std::shared_ptr<Federate> fedptr;
157 std::shared_ptr<Core> corePtr;
166 Translator* transPtr{
nullptr};
167 std::unique_ptr<Translator> mTrans;
168 std::shared_ptr<Federate> fedptr;
169 std::shared_ptr<Core> corePtr;
179 bool activeAsync{
false};
188 #define HELICS_ERROR_CHECK(err, retval) \
190 if (((err) != nullptr) && ((err)->error_code != 0)) { \
196 inline void assignError(
HelicsError* err,
int error_code,
const char*
string)
198 if (err !=
nullptr) {
204 extern const std::string gHelicsEmptyStr;
205 constexpr
char gHelicsNullStringArgument[] =
"The supplied string argument is null and therefore invalid";
206 #define AS_STRING(str) ((str) != nullptr) ? std::string(str) : gHelicsEmptyStr
208 #define AS_STRING_VIEW(str) ((str) != nullptr) ? std::string_view(str) : std::string_view(gHelicsEmptyStr)
210 #define CHECK_NULL_STRING(str, retval) \
212 if ((str) == nullptr) { \
213 assignError(err, HELICS_ERROR_INVALID_ARGUMENT, gHelicsNullStringArgument); \
232 HelicsMessage createAPIMessage(std::unique_ptr<helics::Message>& mess);
247 void helicsErrorHandler(
HelicsError* err) noexcept;
254 bool checkOutputArgString(
const char* outputString,
int maxlen,
HelicsError* err);
259 guarded<std::deque<std::unique_ptr<helics::BrokerObject>>> brokers;
260 guarded<std::deque<std::unique_ptr<helics::CoreObject>>> cores;
261 guarded<std::deque<std::unique_ptr<helics::FedObject>>> feds;
262 guarded<std::deque<std::unique_ptr<helics::AppObject>>> apps;
263 gmlc::concurrency::TripWireDetector tripDetect;
264 guarded<std::deque<std::string>> errorStrings;
272 int addBroker(std::unique_ptr<helics::BrokerObject> broker);
274 int addCore(std::unique_ptr<helics::CoreObject> core);
276 int addFed(std::unique_ptr<helics::FedObject> fed);
278 bool removeFed(std::string_view name,
int validationCode);
280 int addApp(std::unique_ptr<helics::AppObject> app);
282 void clearBroker(
int index);
283 void clearCore(
int index);
284 void clearFed(
int index);
285 void clearApp(
int index);
287 void abortAll(
int errorCode, std::string_view error);
293 std::shared_ptr<MasterObjectHolder> getMasterHolder();
294 void clearAllObjects();
void * HelicsDataBuffer
Definition: api-data.h:88
void * HelicsFederateInfo
Definition: api-data.h:77
void * HelicsCore
Definition: api-data.h:54
void * HelicsApp
Definition: api-data.h:71
void * HelicsMessage
Definition: api-data.h:100
void * HelicsFederate
Definition: api-data.h:65
void * HelicsBroker
Definition: api-data.h:60
Definition: api_objects.h:257
const char * addErrorString(std::string_view newError)
Definition: helicsExport.cpp:1544
bool removeFed(std::string_view name, int validationCode)
Definition: helicsExport.cpp:1408
int addApp(std::unique_ptr< helics::AppObject > app)
Definition: helicsExport.cpp:1372
int addBroker(std::unique_ptr< helics::BrokerObject > broker)
Definition: helicsExport.cpp:1345
int addFed(std::unique_ptr< helics::FedObject > fed)
Definition: helicsExport.cpp:1363
int addCore(std::unique_ptr< helics::CoreObject > core)
Definition: helicsExport.cpp:1354
Definition: api_objects.h:79
std::string type
the target of the query
Definition: api_objects.h:81
Definition: api_objects.h:54
Definition: core/Broker.hpp:18
Definition: CallbackFederate.hpp:19
Definition: api_objects.h:64
std::vector< std::unique_ptr< FilterObject > > filters
list of filters created directly through the core
Definition: api_objects.h:67
std::vector< std::unique_ptr< TranslatorObject > > translators
list of filters created directly through the core
Definition: api_objects.h:68
Definition: core/Core.hpp:41
Definition: api_objects.h:140
Definition: Endpoints.hpp:21
Definition: api_objects.h:104
Definition: FederateInfo.hpp:28
Definition: application_api/Federate.hpp:48
Definition: api_objects.h:149
bool custom
indicator that the filter is a custom filter and requires a callback
Definition: api_objects.h:152
bool cloning
indicator that the filter is a cloning filter
Definition: api_objects.h:151
Definition: application_api/MessageFederate.hpp:24
Definition: api_objects.h:91
Definition: core-data.hpp:29
Definition: api_objects.h:133
Definition: Publications.hpp:25
Definition: api_objects.h:173
HelicsSequencingModes mode
the ordering mode used for the query
Definition: api_objects.h:180
std::string query
the actual query itself
Definition: api_objects.h:176
std::string target
the target of the query
Definition: api_objects.h:175
QueryId asyncIndexCode
the index to use for the queryComplete call
Definition: api_objects.h:181
std::string response
the response to the query
Definition: api_objects.h:177
std::shared_ptr< Federate > activeFed
pointer to the fed with the active Query
Definition: api_objects.h:178
Definition: SmallBuffer.hpp:25
Definition: api_objects.h:162
bool custom
indicator that the translator is a custom translator and requires callbacks
Definition: api_objects.h:164
Definition: application_api/ValueFederate.hpp:28
Definition: helicsApp.hpp:32
HelicsSequencingModes
Definition: helics_enums.h:427
@ HELICS_SEQUENCING_MODE_FAST
Definition: helics_enums.h:429
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
BrokerObject * getBrokerObject(HelicsBroker broker, HelicsError *err) noexcept
Definition: helicsExport.cpp:323
FederateType
Definition: api_objects.h:51
FedObject * getFedObject(HelicsFederate fed, HelicsError *err) noexcept
Definition: FederateExport.cpp:36
CoreObject * getCoreObject(HelicsCore core, HelicsError *err) noexcept
Definition: helicsExport.cpp:306
Definition: api-data.h:177
const char * message
Definition: api-data.h:179
int32_t error_code
Definition: api-data.h:178