helics  3.3.0
NetworkBrokerData.hpp
1 /*
2 Copyright (c) 2017-2022,
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 
9 #include "gmlc/networking/addressOperations.hpp"
10 #include "gmlc/networking/interfaceOperations.hpp"
11 
12 #include <memory>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 namespace helics {
18 
19 class helicsCLI11App;
20 
24  public:
25  enum class ServerModeOptions : char {
26  UNSPECIFIED = 0,
27  SERVER_DEFAULT_ACTIVE = 1,
28  SERVER_DEFAULT_DEACTIVATED = 2,
29  SERVER_ACTIVE = 3,
30  SERVER_DEACTIVATED = 4,
31  };
32 
33  std::string brokerName;
34  std::string brokerAddress;
35  std::string localInterface;
36  std::string brokerInitString;
37  std::string connectionAddress;
38  int portNumber{-1};
39  int brokerPort{-1};
40  int connectionPort{-1};
41 
42  int portStart{-1};
43  int maxMessageSize{16 * 256};
44  int maxMessageCount{256};
45  int maxRetries{5};
46  gmlc::networking::InterfaceNetworks interfaceNetwork{
47  gmlc::networking::InterfaceNetworks::LOCAL};
48  bool reuse_address{false};
49  bool use_os_port{false};
51  bool autobroker{false};
52  bool appendNameToAddress{false};
54  bool noAckConnection{false};
55  bool useJsonSerialization{false};
57  bool observer{false};
58  ServerModeOptions server_mode{ServerModeOptions::UNSPECIFIED};
59  bool encrypted{false}; // enable encryption
60  bool forceConnection{false}; // force the connection and terminate existing connections
61  std::string encryptionConfig;
62 
63  public:
64  NetworkBrokerData() = default;
66  explicit NetworkBrokerData(gmlc::networking::InterfaceTypes type): allowedType(type) {}
67 
71  std::shared_ptr<helicsCLI11App> commandLineParser(std::string_view localAddress,
72  bool enableConfig = true);
75  void setInterfaceType(gmlc::networking::InterfaceTypes type) { allowedType = type; }
76 
77  private:
79  void checkAndUpdateBrokerAddress(std::string_view localAddress);
80  gmlc::networking::InterfaceTypes allowedType{gmlc::networking::InterfaceTypes::IP};
81 };
82 
83 } // namespace helics
helics::NetworkBrokerData::connectionPort
int connectionPort
the port number for connecting
Definition: NetworkBrokerData.hpp:40
helics::NetworkBrokerData::use_os_port
bool use_os_port
specify that any automatic port allocation should use operating system allocation
Definition: NetworkBrokerData.hpp:50
helics::NetworkBrokerData::maxMessageSize
int maxMessageSize
maximum message size
Definition: NetworkBrokerData.hpp:43
helics::NetworkBrokerData::localInterface
std::string localInterface
the interface to use for the local connection
Definition: NetworkBrokerData.hpp:35
helics::NetworkBrokerData::maxMessageCount
int maxMessageCount
maximum message count
Definition: NetworkBrokerData.hpp:44
helics::NetworkBrokerData::appendNameToAddress
bool appendNameToAddress
flag indicating that the name should be appended to the address
Definition: NetworkBrokerData.hpp:53
helics::NetworkBrokerData::autobroker
bool autobroker
Definition: NetworkBrokerData.hpp:51
helics::NetworkBrokerData::NetworkBrokerData
NetworkBrokerData(gmlc::networking::InterfaceTypes type)
Definition: NetworkBrokerData.hpp:66
helics::NetworkBrokerData
Definition: NetworkBrokerData.hpp:23
helics::NetworkBrokerData::observer
bool observer
specify that the network connection is used for observation only
Definition: NetworkBrokerData.hpp:57
helics::NetworkBrokerData::brokerPort
int brokerPort
the port number to use for the main broker interface
Definition: NetworkBrokerData.hpp:39
helics::BrokerFactory::findBroker
std::shared_ptr< Broker > findBroker(std::string_view brokerName)
Definition: BrokerFactory.cpp:183
helics::NetworkBrokerData::commandLineParser
std::shared_ptr< helicsCLI11App > commandLineParser(std::string_view localAddress, bool enableConfig=true)
Definition: NetworkBrokerData.cpp:19
helics::NetworkBrokerData::brokerInitString
std::string brokerInitString
a string containing arguments for the broker initialization
Definition: NetworkBrokerData.hpp:36
helics::NetworkBrokerData::brokerAddress
std::string brokerAddress
the address or domain name of the broker
Definition: NetworkBrokerData.hpp:34
helics::NetworkBrokerData::noAckConnection
bool noAckConnection
Definition: NetworkBrokerData.hpp:54
helics::NetworkBrokerData::reuse_address
bool reuse_address
Definition: NetworkBrokerData.hpp:48
helics::NetworkBrokerData::portStart
int portStart
the starting port for automatic port definitions
Definition: NetworkBrokerData.hpp:42
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::NetworkBrokerData::setInterfaceType
void setInterfaceType(gmlc::networking::InterfaceTypes type)
Definition: NetworkBrokerData.hpp:75
helics::NetworkBrokerData::server_mode
ServerModeOptions server_mode
setup a server mode
Definition: NetworkBrokerData.hpp:58
helics::NetworkBrokerData::connectionAddress
std::string connectionAddress
the address for connecting
Definition: NetworkBrokerData.hpp:37
helics::NetworkBrokerData::portNumber
int portNumber
the port number for the local interface
Definition: NetworkBrokerData.hpp:38
helics::NetworkBrokerData::useJsonSerialization
bool useJsonSerialization
for message serialization use JSON
Definition: NetworkBrokerData.hpp:56
helics::NetworkBrokerData::maxRetries
int maxRetries
the maximum number of retries to establish a network connection
Definition: NetworkBrokerData.hpp:45
helics::NetworkBrokerData::brokerName
std::string brokerName
the identifier for the broker
Definition: NetworkBrokerData.hpp:33
helics::addJsonConfig
HelicsConfigJSON * addJsonConfig(CLI::App *app)
Add the HELICS JSON configuration processor to the app.
Definition: helicsCLI11JsonConfig.cpp:96