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;
42 class TranslatorObject;
46 enum class FederateType : int { GENERIC, VALUE, MESSAGE, COMBINATION, CALLBACK, INVALID };
51 std::shared_ptr<Broker> brokerptr;
61 std::shared_ptr<Core> coreptr;
62 std::vector<std::unique_ptr<FilterObject>>
filters;
66 CoreObject() =
default;
74 class PublicationObject;
79 std::vector<std::unique_ptr<Message>> messages;
80 std::vector<int> freeMessageSlots;
83 Message* addMessage(std::unique_ptr<Message>& mess);
85 std::unique_ptr<Message> extractMessage(
int index);
86 void freeMessage(
int index);
95 std::shared_ptr<Federate> fedptr;
97 std::vector<std::unique_ptr<InputObject>> inputs;
98 std::vector<std::unique_ptr<PublicationObject>> pubs;
99 std::vector<std::unique_ptr<EndpointObject>> epts;
100 std::vector<std::unique_ptr<FilterObject>> filters;
101 std::vector<std::unique_ptr<TranslatorObject>> translators;
102 std::pair<std::string, std::string> commandBuffer;
114 std::shared_ptr<ValueFederate> fedptr;
115 Input* inputPtr{
nullptr};
122 std::shared_ptr<ValueFederate> fedptr;
130 std::shared_ptr<MessageFederate> fedptr;
140 Filter* filtPtr{
nullptr};
141 std::unique_ptr<Filter> uFilter;
142 std::shared_ptr<Federate> fedptr;
143 std::shared_ptr<Core> corePtr;
151 Translator* transPtr{
nullptr};
152 std::unique_ptr<Translator> mTrans;
153 std::shared_ptr<Federate> fedptr;
154 std::shared_ptr<Core> corePtr;
164 bool activeAsync{
false};
173 #define HELICS_ERROR_CHECK(err, retval) \
175 if (((err) != nullptr) && ((err)->error_code != 0)) { \
181 inline void assignError(
HelicsError* err,
int error_code,
const char*
string)
183 if (err !=
nullptr) {
189 extern const std::string gHelicsEmptyStr;
190 constexpr
char gHelicsNullStringArgument[] =
"The supplied string argument is null and therefore invalid";
191 #define AS_STRING(str) ((str) != nullptr) ? std::string(str) : gHelicsEmptyStr
193 #define AS_STRING_VIEW(str) ((str) != nullptr) ? std::string_view(str) : std::string_view(gHelicsEmptyStr)
195 #define CHECK_NULL_STRING(str, retval) \
197 if ((str) == nullptr) { \
198 assignError(err, HELICS_ERROR_INVALID_ARGUMENT, gHelicsNullStringArgument); \
213 HelicsMessage createAPIMessage(std::unique_ptr<helics::Message>& mess);
226 void helicsErrorHandler(
HelicsError* err) noexcept;
233 bool checkOutputArgString(
const char* outputString,
int maxlen,
HelicsError* err);
238 guarded<std::deque<std::unique_ptr<helics::BrokerObject>>> brokers;
239 guarded<std::deque<std::unique_ptr<helics::CoreObject>>> cores;
240 guarded<std::deque<std::unique_ptr<helics::FedObject>>> feds;
241 gmlc::concurrency::TripWireDetector tripDetect;
242 guarded<std::deque<std::string>> errorStrings;
250 int addBroker(std::unique_ptr<helics::BrokerObject> broker);
252 int addCore(std::unique_ptr<helics::CoreObject> core);
254 int addFed(std::unique_ptr<helics::FedObject> fed);
256 bool removeFed(std::string_view name,
int validationCode);
257 void clearBroker(
int index);
258 void clearCore(
int index);
259 void clearFed(
int index);
261 void abortAll(
int errorCode, std::string_view error);
267 std::shared_ptr<MasterObjectHolder> getMasterHolder();
268 void clearAllObjects();
void * HelicsDataBuffer
Definition: api-data.h:82
void * HelicsCore
Definition: api-data.h:54
void * HelicsMessage
Definition: api-data.h:94
void * HelicsFederate
Definition: api-data.h:65
void * HelicsBroker
Definition: api-data.h:60
Definition: api_objects.h:236
const char * addErrorString(std::string_view newError)
Definition: helicsExport.cpp:1503
bool removeFed(std::string_view name, int validationCode)
Definition: helicsExport.cpp:1391
int addBroker(std::unique_ptr< helics::BrokerObject > broker)
Definition: helicsExport.cpp:1337
int addFed(std::unique_ptr< helics::FedObject > fed)
Definition: helicsExport.cpp:1355
int addCore(std::unique_ptr< helics::CoreObject > core)
Definition: helicsExport.cpp:1346
Definition: api_objects.h:49
Definition: core/Broker.hpp:18
Definition: CallbackFederate.hpp:19
Definition: api_objects.h:59
std::vector< std::unique_ptr< FilterObject > > filters
list of filters created directly through the core
Definition: api_objects.h:62
std::vector< std::unique_ptr< TranslatorObject > > translators
list of filters created directly through the core
Definition: api_objects.h:63
Definition: core/Core.hpp:41
Definition: api_objects.h:126
Definition: Endpoints.hpp:21
Definition: api_objects.h:90
Definition: application_api/Federate.hpp:48
Definition: api_objects.h:135
bool custom
indicator that the filter is a custom filter and requires a callback
Definition: api_objects.h:138
bool cloning
indicator that the filter is a cloning filter
Definition: api_objects.h:137
Definition: application_api/MessageFederate.hpp:24
Definition: api_objects.h:77
Definition: core-data.hpp:29
Definition: api_objects.h:119
Definition: Publications.hpp:25
Definition: api_objects.h:158
HelicsSequencingModes mode
the ordering mode used for the query
Definition: api_objects.h:165
std::string query
the actual query itself
Definition: api_objects.h:161
std::string target
the target of the query
Definition: api_objects.h:160
QueryId asyncIndexCode
the index to use for the queryComplete call
Definition: api_objects.h:166
std::string response
the response to the query
Definition: api_objects.h:162
std::shared_ptr< Federate > activeFed
pointer to the fed with the active Query
Definition: api_objects.h:163
Definition: SmallBuffer.hpp:25
Definition: api_objects.h:147
bool custom
indicator that the translator is a custom translator and requires callbacks
Definition: api_objects.h:149
Definition: application_api/ValueFederate.hpp:28
HelicsSequencingModes
Definition: helics_enums.h:425
@ HELICS_SEQUENCING_MODE_FAST
Definition: helics_enums.h:427
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:316
FederateType
Definition: api_objects.h:46
FedObject * getFedObject(HelicsFederate fed, HelicsError *err) noexcept
Definition: FederateExport.cpp:29
CoreObject * getCoreObject(HelicsCore core, HelicsError *err) noexcept
Definition: helicsExport.cpp:299
Definition: api-data.h:171
const char * message
Definition: api-data.h:173
int32_t error_code
Definition: api-data.h:172