 |
helics
3.3.0
|
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;
41 class TranslatorObject;
45 enum class FederateType : int { GENERIC, VALUE, MESSAGE, COMBINATION, INVALID };
50 std::shared_ptr<Broker> brokerptr;
60 std::shared_ptr<Core> coreptr;
61 std::vector<std::unique_ptr<FilterObject>>
filters;
65 CoreObject() =
default;
73 class PublicationObject;
78 std::vector<std::unique_ptr<Message>> messages;
79 std::vector<int> freeMessageSlots;
82 Message* addMessage(std::unique_ptr<Message>& mess);
84 std::unique_ptr<Message> extractMessage(
int index);
85 void freeMessage(
int index);
94 std::shared_ptr<Federate> fedptr;
96 std::vector<std::unique_ptr<InputObject>> inputs;
97 std::vector<std::unique_ptr<PublicationObject>> pubs;
98 std::vector<std::unique_ptr<EndpointObject>> epts;
99 std::vector<std::unique_ptr<FilterObject>> filters;
100 std::vector<std::unique_ptr<TranslatorObject>> translators;
101 std::pair<std::string, std::string> commandBuffer;
113 std::shared_ptr<ValueFederate> fedptr;
114 Input* inputPtr{
nullptr};
121 std::shared_ptr<ValueFederate> fedptr;
129 std::shared_ptr<MessageFederate> fedptr;
139 Filter* filtPtr{
nullptr};
140 std::unique_ptr<Filter> uFilter;
141 std::shared_ptr<Federate> fedptr;
142 std::shared_ptr<Core> corePtr;
150 Translator* transPtr{
nullptr};
151 std::unique_ptr<Translator> mTrans;
152 std::shared_ptr<Federate> fedptr;
153 std::shared_ptr<Core> corePtr;
163 bool activeAsync{
false};
172 #define HELICS_ERROR_CHECK(err, retval) \
174 if (((err) != nullptr) && ((err)->error_code != 0)) { \
180 inline void assignError(
HelicsError* err,
int error_code,
const char*
string)
182 if (err !=
nullptr) {
188 extern const std::string gHelicsEmptyStr;
189 constexpr
char gHelicsNullStringArgument[] =
"The supplied string argument is null and therefore invalid";
190 #define AS_STRING(str) ((str) != nullptr) ? std::string(str) : gHelicsEmptyStr
192 #define AS_STRING_VIEW(str) ((str) != nullptr) ? std::string_view(str) : std::string_view(gHelicsEmptyStr)
194 #define CHECK_NULL_STRING(str, retval) \
196 if ((str) == nullptr) { \
197 assignError(err, HELICS_ERROR_INVALID_ARGUMENT, gHelicsNullStringArgument); \
211 HelicsMessage createAPIMessage(std::unique_ptr<helics::Message>& mess);
220 void helicsErrorHandler(
HelicsError* err) noexcept;
227 bool checkOutputArgString(
const char* outputString,
int maxlen,
HelicsError* err);
232 guarded<std::deque<std::unique_ptr<helics::BrokerObject>>> brokers;
233 guarded<std::deque<std::unique_ptr<helics::CoreObject>>> cores;
234 guarded<std::deque<std::unique_ptr<helics::FedObject>>> feds;
235 gmlc::concurrency::TripWireDetector tripDetect;
236 guarded<std::deque<std::string>> errorStrings;
244 int addBroker(std::unique_ptr<helics::BrokerObject> broker);
246 int addCore(std::unique_ptr<helics::CoreObject> core);
248 int addFed(std::unique_ptr<helics::FedObject> fed);
250 bool removeFed(std::string_view name,
int validationCode);
251 void clearBroker(
int index);
252 void clearCore(
int index);
253 void clearFed(
int index);
255 void abortAll(
int errorCode, std::string_view error);
261 std::shared_ptr<MasterObjectHolder> getMasterHolder();
262 void clearAllObjects();
Definition: api_objects.h:76
std::vector< std::unique_ptr< FilterObject > > filters
list of filters created directly through the core
Definition: api_objects.h:61
Definition: api_objects.h:125
std::string target
the target of the query
Definition: api_objects.h:159
FedObject * getFedObject(HelicsFederate fed, HelicsError *err) noexcept
Definition: FederateExport.cpp:29
Definition: application_api/ValueFederate.hpp:26
Definition: SmallBuffer.hpp:24
const char * message
Definition: api-data.h:171
QueryId asyncIndexCode
the index to use for the queryComplete call
Definition: api_objects.h:165
void * HelicsFederate
Definition: api-data.h:65
Definition: api_objects.h:157
bool custom
indicator that the filter is a custom filter and requires a callback
Definition: api_objects.h:137
Definition: Endpoints.hpp:21
Definition: application_api/MessageFederate.hpp:22
bool custom
indicator that the translator is a custom translator and requires callbacks
Definition: api_objects.h:148
Definition: api_objects.h:146
Definition: core/Core.hpp:41
BrokerObject * getBrokerObject(HelicsBroker broker, HelicsError *err) noexcept
Definition: helicsExport.cpp:316
void * HelicsBroker
Definition: api-data.h:60
int addBroker(std::unique_ptr< helics::BrokerObject > broker)
Definition: helicsExport.cpp:1229
std::string query
the actual query itself
Definition: api_objects.h:160
Definition: api_objects.h:89
Definition: api_objects.h:48
CoreObject * getCoreObject(HelicsCore core, HelicsError *err) noexcept
Definition: helicsExport.cpp:299
const char * addErrorString(std::string_view newError)
Definition: helicsExport.cpp:1395
HelicsSequencingModes
Definition: helics_enums.h:395
Definition: api_objects.h:230
Definition: api_objects.h:58
void * HelicsMessage
Definition: api-data.h:94
Definition: Publications.hpp:25
Definition: api-data.h:169
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
bool removeFed(std::string_view name, int validationCode)
Definition: helicsExport.cpp:1283
HelicsSequencingModes mode
the ordering mode used for the query
Definition: api_objects.h:164
bool cloning
indicator that the filter is a cloning filter
Definition: api_objects.h:136
@ HELICS_SEQUENCING_MODE_FAST
Definition: helics_enums.h:397
void * HelicsCore
Definition: api-data.h:54
Definition: api_objects.h:134
std::shared_ptr< Federate > activeFed
pointer to the fed with the active Query
Definition: api_objects.h:162
Definition: application_api/Federate.hpp:48
std::vector< std::unique_ptr< TranslatorObject > > translators
list of filters created directly through the core
Definition: api_objects.h:62
Definition: core/Broker.hpp:18
int addCore(std::unique_ptr< helics::CoreObject > core)
Definition: helicsExport.cpp:1238
std::string response
the response to the query
Definition: api_objects.h:161
Definition: api_objects.h:118
FederateType
Definition: api_objects.h:45
int32_t error_code
Definition: api-data.h:170
void * HelicsDataBuffer
Definition: api-data.h:82
Definition: core-data.hpp:29
int addFed(std::unique_ptr< helics::FedObject > fed)
Definition: helicsExport.cpp:1247