helics  2.8.1
FederateInfo.hpp
1 /*
2 Copyright (c) 2017-2021,
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/core-types.hpp"
10 #include "helics_cxx_export.h"
11 
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 namespace helics {
17 class helicsCLI11App;
20 class HELICS_CXX_EXPORT FederateInfo: public CoreFederateInfo {
21  public:
22  int uniqueKey{0};
23  char separator{'/'};
24  bool autobroker{
25  false};
26 
28  bool debugging{false};
30  int brokerPort{-1};
31 
32  bool forceNewCore{false};
33 
34  bool useJsonSerialization{false};
37  std::string profilerFileName;
38 
39  std::string defName;
40  std::string coreName;
41  std::string coreInitString;
42  std::string brokerInitString;
43  std::string broker;
44  std::string key;
45  std::string localport;
46  std::string fileInUse;
48 
49  FederateInfo();
52  explicit FederateInfo(core_type cType);
57  explicit FederateInfo(const std::string& args);
63  FederateInfo(int argc, char* argv[]);
69  explicit FederateInfo(std::vector<std::string>& args);
74  std::vector<std::string> loadInfoFromArgs(const std::string& args);
80  std::vector<std::string> loadInfoFromArgs(int argc, char* argv[]);
85  void loadInfoFromArgs(std::vector<std::string>& args);
89  void loadInfoFromArgsIgnoreOutput(const std::string& args);
94  void loadInfoFromArgsIgnoreOutput(int argc, char* argv[]);
95 
99  void loadInfoFromToml(const std::string& toml, bool runArgParser = true);
100 
104  void loadInfoFromJson(const std::string& json, bool runArgParser = true);
105 
107  Time checkTimeProperty(int propId, Time defVal) const;
108  bool checkFlagProperty(int propId, bool defVal) const;
109  int checkIntProperty(int propId, int defVal) const;
110 
111  private:
112  std::unique_ptr<helicsCLI11App> makeCLIApp();
114  void config_additional(helicsCLI11App* app);
115 };
116 
119 HELICS_CXX_EXPORT FederateInfo loadFederateInfo(const std::string& configString);
120 
122 HELICS_CXX_EXPORT std::string generateFullCoreInitString(const FederateInfo& fi);
123 
129 HELICS_CXX_EXPORT int getPropertyIndex(std::string val);
130 
136 HELICS_CXX_EXPORT int getFlagIndex(std::string val);
137 
143 HELICS_CXX_EXPORT int getOptionIndex(std::string val);
144 
149 HELICS_CXX_EXPORT int getOptionValue(std::string val);
150 
151 } // namespace helics
helics::FederateInfo::localport
std::string localport
Definition: FederateInfo.hpp:45
helics_flag_use_json_serialization
@ helics_flag_use_json_serialization
Definition: helics_enums.h:121
hasJsonExtension
bool hasJsonExtension(const std::string &jsonString)
Definition: JsonProcessingFunctions.cpp:18
helics_property_time_offset
@ helics_property_time_offset
Definition: helics_enums.h:219
helics::FederateInfo::profilerFileName
std::string profilerFileName
Definition: FederateInfo.hpp:37
helics_property_int_max_iterations
@ helics_property_int_max_iterations
Definition: helics_enums.h:234
helics::core_type
core_type
Definition: core-types.hpp:37
helics_multi_input_max_operation
@ helics_multi_input_max_operation
Definition: helics_enums.h:264
helics_flag_single_thread_federate
@ helics_flag_single_thread_federate
Definition: helics_enums.h:114
helics::ValueFederate
Definition: application_api/ValueFederate.hpp:25
helics_flag_event_triggered
@ helics_flag_event_triggered
Definition: helics_enums.h:124
helics_property_time_rt_lag
@ helics_property_time_rt_lag
Definition: helics_enums.h:222
helics::loadFederateInfo
FederateInfo loadFederateInfo(const std::string &configString)
Definition: FederateInfo.cpp:639
helics_property_time_input_delay
@ helics_property_time_input_delay
Definition: helics_enums.h:230
helics::FederateInfo::loadInfoFromToml
void loadInfoFromToml(const std::string &toml, bool runArgParser=true)
Definition: FederateInfo.cpp:737
helics_handle_option_multiple_connections_allowed
@ helics_handle_option_multiple_connections_allowed
Definition: helics_enums.h:283
helics::FederateInfo::loadInfoFromArgs
std::vector< std::string > loadInfoFromArgs(const std::string &args)
Definition: FederateInfo.cpp:571
helics::InvalidIdentifier
Definition: core-exceptions.hpp:39
helics::FederateInfo::debugging
bool debugging
Definition: FederateInfo.hpp:28
helics_error_invalid_object
@ helics_error_invalid_object
Definition: helics_enums.h:206
helics::FederateInfo::loadInfoFromArgsIgnoreOutput
void loadInfoFromArgsIgnoreOutput(const std::string &args)
Definition: FederateInfo.cpp:593
helics::FederateInfo::forceNewCore
bool forceNewCore
indicator that the federate should not use an existing core
Definition: FederateInfo.hpp:32
helics_handle_option_connection_required
@ helics_handle_option_connection_required
Definition: helics_enums.h:276
helics_log_level_summary
@ helics_log_level_summary
Definition: helics_enums.h:171
helics::to_string
std::string to_string(core_type type)
Definition: typeOperations.cpp:12
helics_handle_option_clear_priority_list
@ helics_handle_option_clear_priority_list
Definition: helics_enums.h:302
helics_property_time_output_delay
@ helics_property_time_output_delay
Definition: helics_enums.h:232
helics_handle_option_strict_type_checking
@ helics_handle_option_strict_type_checking
Definition: helics_enums.h:287
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helics-time.hpp:27
loadToml
toml::value loadToml(const std::string &tomlString)
Definition: TomlProcessingFunctions.cpp:22
helics.h
Common functions for the HELICS C api.
helics_property_time_rt_lead
@ helics_property_time_rt_lead
Definition: helics_enums.h:225
helics_flag_force_logging_flush
@ helics_flag_force_logging_flush
Definition: helics_enums.h:155
helics::FederateInfo::brokerPort
int brokerPort
broker port information
Definition: FederateInfo.hpp:30
helics::MessageFederate
Definition: application_api/MessageFederate.hpp:20
helics_log_level_warning
@ helics_log_level_warning
Definition: helics_enums.h:169
helics::helicsCLI11App
Definition: helicsCLI11.hpp:41
helics_flag_dumplog
@ helics_flag_dumplog
Definition: helics_enums.h:157
helics::core_type::UNRECOGNIZED
@ UNRECOGNIZED
unknown
helics::FederateInfo::key
std::string key
key for the broker
Definition: FederateInfo.hpp:44
helics_log_level_trace
@ helics_log_level_trace
Definition: helics_enums.h:182
helics::getOptionIndex
int getOptionIndex(std::string val)
Definition: FederateInfo.cpp:356
helics_handle_option_buffer_data
@ helics_handle_option_buffer_data
Definition: helics_enums.h:285
helics_flag_debugging
@ helics_flag_debugging
Definition: helics_enums.h:151
helics_flag_ignore_time_mismatch_warnings
@ helics_flag_ignore_time_mismatch_warnings
Definition: helics_enums.h:116
helics_property_int_console_log_level
@ helics_property_int_console_log_level
Definition: helics_enums.h:242
helics::getOptionValue
int getOptionValue(std::string val)
Definition: FederateInfo.cpp:375
helics_handle_option_multi_input_handling_method
@ helics_handle_option_multi_input_handling_method
Definition: helics_enums.h:298
helics::InvalidParameter
Definition: core-exceptions.hpp:48
helics::FederateInfo::autobroker
bool autobroker
specify that the core should generate a broker if not found otherwise
Definition: FederateInfo.hpp:24
helics::core_type::DEFAULT
@ DEFAULT
ZMQ if available or UDP.
helics_log_level_connections
@ helics_log_level_connections
Definition: helics_enums.h:174
helics_log_level_error
@ helics_log_level_error
Definition: helics_enums.h:167
helics_handle_option_single_connection_only
@ helics_handle_option_single_connection_only
Definition: helics_enums.h:281
helics::FederateInfo::coreInitString
std::string coreInitString
an initialization string for the core API object
Definition: FederateInfo.hpp:41
helics_property_time_delta
@ helics_property_time_delta
Definition: helics_enums.h:215
helics_handle_option_connection_optional
@ helics_handle_option_connection_optional
Definition: helics_enums.h:279
helics_flag_enable_init_entry
@ helics_flag_enable_init_entry
Definition: helics_enums.h:137
helics::FederateInfo::checkTimeProperty
Time checkTimeProperty(int propId, Time defVal) const
Definition: FederateInfo.cpp:661
helics_property_time_rt_tolerance
@ helics_property_time_rt_tolerance
Definition: helics_enums.h:228
helics::FederateInfo
Definition: FederateInfo.hpp:20
helics_log_level_interfaces
@ helics_log_level_interfaces
Definition: helics_enums.h:176
helics_multi_input_diff_operation
@ helics_multi_input_diff_operation
Definition: helics_enums.h:262
helics_flag_profiling
@ helics_flag_profiling
Definition: helics_enums.h:159
helics::FederateInfo::coreType
core_type coreType
the type of the core
Definition: FederateInfo.hpp:29
helics_multi_input_or_operation
@ helics_multi_input_or_operation
Definition: helics_enums.h:257
helics_flag_wait_for_current_time_update
@ helics_flag_wait_for_current_time_update
Definition: helics_enums.h:101
helics::CoreFederateInfo::setProperty
void setProperty(int propId, double propVal)
Definition: CoreFederateInfo.hpp:24
loadJson
Json::Value loadJson(const std::string &jsonString)
Definition: JsonProcessingFunctions.cpp:24
helics::FederateInfo::brokerInitString
std::string brokerInitString
an initialization string for the broker if auto generated
Definition: FederateInfo.hpp:42
helics::FedObject
Definition: api_objects.h:82
helics_handle_option_only_transmit_on_change
@ helics_handle_option_only_transmit_on_change
Definition: helics_enums.h:292
helics_flag_source_only
@ helics_flag_source_only
Definition: helics_enums.h:92
helics::FederateInfo::useJsonSerialization
bool useJsonSerialization
Definition: FederateInfo.hpp:34
helics::getFlagIndex
int getFlagIndex(std::string val)
Definition: FederateInfo.cpp:337
helics_log_level_data
@ helics_log_level_data
Definition: helics_enums.h:180
helics::CoreFederateInfo::intProps
std::vector< std::pair< int, int > > intProps
container for the integer properties
Definition: CoreFederateInfo.hpp:19
helics_handle_option_only_update_on_change
@ helics_handle_option_only_update_on_change
Definition: helics_enums.h:294
helics_property_int_file_log_level
@ helics_property_int_file_log_level
Definition: helics_enums.h:239
fed
@ fed
special logging command for message coming from a fed
Definition: loggingHelper.hpp:32
helics::FederateInfo::FederateInfo
FederateInfo()
Definition: FederateInfo.cpp:26
helics_flag_restrictive_time_policy
@ helics_flag_restrictive_time_policy
Definition: helics_enums.h:106
helics_property_int_log_level
@ helics_property_int_log_level
Definition: helics_enums.h:236
helics_flag_forward_compute
@ helics_flag_forward_compute
Definition: helics_enums.h:110
helics_flag_strict_config_checking
@ helics_flag_strict_config_checking
Definition: helics_enums.h:119
helics_handle_option_ignore_unit_mismatch
@ helics_handle_option_ignore_unit_mismatch
Definition: helics_enums.h:289
helics::FederateInfo::fileInUse
std::string fileInUse
string containing a configuration file that was used
Definition: FederateInfo.hpp:47
helics::CoreFederateInfo::timeProps
std::vector< std::pair< int, Time > > timeProps
container for the timeProperties
Definition: CoreFederateInfo.hpp:18
helics_flag_interruptible
@ helics_flag_interruptible
Definition: helics_enums.h:90
helics_error
Definition: api-data.h:166
helics_log_level_no_print
@ helics_log_level_no_print
Definition: helics_enums.h:165
helics_flag_uninterruptible
@ helics_flag_uninterruptible
Definition: helics_enums.h:88
helics_flag_local_profiling_capture
@ helics_flag_local_profiling_capture
Definition: helics_enums.h:129
helics_flag_slow_responding
@ helics_flag_slow_responding
Definition: helics_enums.h:147
helics::FederateInfo::broker
std::string broker
connection information for the broker
Definition: FederateInfo.hpp:43
helics_log_level_timing
@ helics_log_level_timing
Definition: helics_enums.h:178
helics_flag_delay_init_entry
@ helics_flag_delay_init_entry
Definition: helics_enums.h:135
helics::FederateInfo::coreName
std::string coreName
the name of the core
Definition: FederateInfo.hpp:40
helics_multi_input_average_operation
@ helics_multi_input_average_operation
Definition: helics_enums.h:268
helics::getFedObject
FedObject * getFedObject(helics_federate fed, helics_error *err) noexcept
Definition: FederateExport.cpp:27
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics_flag_only_update_on_change
@ helics_flag_only_update_on_change
Definition: helics_enums.h:98
helics::getPropertyIndex
int getPropertyIndex(std::string val)
Definition: FederateInfo.cpp:314
helics_flag_only_transmit_on_change
@ helics_flag_only_transmit_on_change
Definition: helics_enums.h:95
helics::FederateInfo::separator
char separator
separator for global name of localFederates
Definition: FederateInfo.hpp:23
helics::CoreFederateInfo
Definition: CoreFederateInfo.hpp:16
helics_flag_realtime
@ helics_flag_realtime
Definition: helics_enums.h:112
helics_flag_terminate_on_error
@ helics_flag_terminate_on_error
Definition: helics_enums.h:153
helics::coreTypeFromString
core_type coreTypeFromString(std::string type) noexcept
Definition: typeOperations.cpp:17
helics::FederateInfo::loadInfoFromJson
void loadInfoFromJson(const std::string &json, bool runArgParser=true)
Definition: FederateInfo.cpp:691
helics_flag_observer
@ helics_flag_observer
Definition: helics_enums.h:86
helics::generateFullCoreInitString
std::string generateFullCoreInitString(const FederateInfo &fi)
Definition: FederateInfo.cpp:785
helics_multi_input_min_operation
@ helics_multi_input_min_operation
Definition: helics_enums.h:266
helics::CoreFederateInfo::setFlagOption
void setFlagOption(int flagId, bool propVal=true)
Definition: CoreFederateInfo.hpp:28
helics::Federate
Definition: application_api/Federate.hpp:44
helics_handle_option_ignore_interrupts
@ helics_handle_option_ignore_interrupts
Definition: helics_enums.h:296
helics::CoreFederateInfo::flagProps
std::vector< std::pair< int, bool > > flagProps
container for the binary flag options
Definition: CoreFederateInfo.hpp:20
helics_multi_input_vectorize_operation
@ helics_multi_input_vectorize_operation
Definition: helics_enums.h:253
helics_multi_input_no_op
@ helics_multi_input_no_op
Definition: helics_enums.h:251
helics_flag_rollback
@ helics_flag_rollback
Definition: helics_enums.h:108
helics_multi_input_sum_operation
@ helics_multi_input_sum_operation
Definition: helics_enums.h:259
helics_handle_option_input_priority_location
@ helics_handle_option_input_priority_location
Definition: helics_enums.h:300
helics::addJsonConfig
HelicsConfigJSON * addJsonConfig(CLI::App *app)
Add the HELICS JSON configuration processor to the app.
Definition: helicsCLI11JsonConfig.cpp:96
helics_multi_input_and_operation
@ helics_multi_input_and_operation
Definition: helics_enums.h:255
helics_property_time_period
@ helics_property_time_period
Definition: helics_enums.h:217
helics_handle_option_connections
@ helics_handle_option_connections
Definition: helics_enums.h:304
helics::FederateInfo::defName
std::string defName
a default name to use for a federate
Definition: FederateInfo.hpp:39
helics_federate
void * helics_federate
Definition: api-data.h:56
helics_flag_profiling_marker
@ helics_flag_profiling_marker
Definition: helics_enums.h:126