| helics 3.6.1

FederateInfo.hpp
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
8 #include "../core/CoreFederateInfo.hpp"
9 #include "../core/CoreTypes.hpp"
10 #include "helics_cxx_export.h"
11
12 #include <memory>
13 #include <string>
14 #include <vector>
15
16 namespace CLI {
17 class App;
18 }
19
20 namespace helics {
21 class helicsCLI11App;
22
23 namespace fileops {
24 class JsonBuffer;
25 }
28 class HELICS_CXX_EXPORT FederateInfo: public CoreFederateInfo {
29 public:
30 int uniqueKey{0};
31 char separator{'/'};
32 bool autobroker{
33 false};
36 bool debugging{false};
37 bool observer{false};
38 CoreType coreType{CoreType::DEFAULT};
39 int brokerPort{-1};
40
41 bool forceNewCore{false};
43 bool useJsonSerialization{false};
45 bool encrypted{false};
48 std::string profilerFileName;
49 std::string encryptionConfig;
50 std::string defName;
51 std::string coreName;
52 std::string coreInitString;
53 std::string brokerInitString;
54 std::string broker;
55 std::string key;
56 std::string localport;
58
59 std::string configString;
60 bool fileInUse{false};
62 FederateInfo();
65 explicit FederateInfo(CoreType cType);
70 explicit FederateInfo(const std::string& args);
76 FederateInfo(int argc, char* argv[]);
82 explicit FederateInfo(std::vector<std::string>& args);
87 std::vector<std::string> loadInfoFromArgs(const std::string& args);
93 std::vector<std::string> loadInfoFromArgs(int argc, char* argv[]);
98 void loadInfoFromArgs(std::vector<std::string>& args);
102 void loadInfoFromArgsIgnoreOutput(const std::string& args);
107 void loadInfoFromArgsIgnoreOutput(int argc, char* argv[]);
108
112 void loadInfoFromToml(const std::string& toml, bool runArgParser = true);
113
117 void loadInfoFromJson(const std::string& json, bool runArgParser = true);
118
120 Time checkTimeProperty(int propId, Time defVal) const;
121 bool checkFlagProperty(int propId, bool defVal) const;
122 int checkIntProperty(int propId, int defVal) const;
123
125 void injectParser(CLI::App* app);
126
127 private:
128 std::unique_ptr<helicsCLI11App> makeCLIApp();
130 void config_additional(CLI::App* app);
132 void loadJsonConfig(const fileops::JsonBuffer& json);
133 };
134
137 HELICS_CXX_EXPORT FederateInfo loadFederateInfo(const std::string& configString);
138
140 HELICS_CXX_EXPORT std::string generateFullCoreInitString(const FederateInfo& fedInfo);
141
147 HELICS_CXX_EXPORT int getPropertyIndex(std::string val);
148
154 HELICS_CXX_EXPORT int getFlagIndex(std::string val);
155
161 HELICS_CXX_EXPORT int getOptionIndex(std::string val);
162
167 HELICS_CXX_EXPORT int getOptionValue(std::string val);
168
169 } // namespace helics
helics::CoreFederateInfo
Definition: CoreFederateInfo.hpp:16
helics::FederateInfo
Definition: FederateInfo.hpp:28
helics::FederateInfo::broker
std::string broker
connection information for the broker
Definition: FederateInfo.hpp:54
helics::FederateInfo::defName
std::string defName
a default name to use for a federate
Definition: FederateInfo.hpp:50
helics::FederateInfo::configString
std::string configString
storage for config file name or string
Definition: FederateInfo.hpp:59
helics::FederateInfo::brokerInitString
std::string brokerInitString
an initialization string for the broker if auto generated
Definition: FederateInfo.hpp:53
helics::FederateInfo::profilerFileName
std::string profilerFileName
Definition: FederateInfo.hpp:48
helics::FederateInfo::key
std::string key
key for the broker
Definition: FederateInfo.hpp:55
helics::FederateInfo::encryptionConfig
std::string encryptionConfig
encryption configuration string or file
Definition: FederateInfo.hpp:49
helics::FederateInfo::localport
std::string localport
Definition: FederateInfo.hpp:56
helics::FederateInfo::coreName
std::string coreName
the name of the core
Definition: FederateInfo.hpp:51
helics::FederateInfo::coreInitString
std::string coreInitString
an initialization string for the core API object
Definition: FederateInfo.hpp:52
helics::fileops::JsonBuffer
Definition: JsonProcessingFunctions.hpp:25
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::loadFederateInfo
FederateInfo loadFederateInfo(const std::string &configString)
Definition: FederateInfo.cpp:783
helics::CoreType
CoreType
Definition: CoreTypes.hpp:46
helics::CoreType::DEFAULT
@ DEFAULT
ZMQ if available or UDP.
helics::getFlagIndex
int getFlagIndex(std::string val)
Definition: FederateInfo.cpp:412
helics::getOptionIndex
int getOptionIndex(std::string val)
Definition: FederateInfo.cpp:431
helics::getOptionValue
int getOptionValue(std::string val)
Definition: FederateInfo.cpp:450
helics::generateFullCoreInitString
std::string generateFullCoreInitString(const FederateInfo &fedInfo)
Definition: FederateInfo.cpp:1014
helics::getPropertyIndex
int getPropertyIndex(std::string val)
Definition: FederateInfo.cpp:389
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27