helics  3.5.2
NetworkBrokerData.hpp
1 /*
2 Copyright (c) 2017-2024,
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};
50  bool use_os_port{false};
51  bool autobroker{false};
53  bool appendNameToAddress{false};
54  bool noAckConnection{false};
56  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
Definition: NetworkBrokerData.hpp:23
bool appendNameToAddress
flag indicating that the name should be appended to the address
Definition: NetworkBrokerData.hpp:53
std::string localInterface
the interface to use for the local connection
Definition: NetworkBrokerData.hpp:35
std::string brokerAddress
the address or domain name of the broker
Definition: NetworkBrokerData.hpp:34
std::shared_ptr< helicsCLI11App > commandLineParser(std::string_view localAddress, bool enableConfig=true)
Definition: NetworkBrokerData.cpp:19
int maxRetries
the maximum number of retries to establish a network connection
Definition: NetworkBrokerData.hpp:45
int portNumber
the port number for the local interface
Definition: NetworkBrokerData.hpp:38
int maxMessageCount
maximum message count
Definition: NetworkBrokerData.hpp:44
bool use_os_port
specify that any automatic port allocation should use operating system allocation
Definition: NetworkBrokerData.hpp:50
int connectionPort
the port number for connecting
Definition: NetworkBrokerData.hpp:40
int portStart
the starting port for automatic port definitions
Definition: NetworkBrokerData.hpp:42
bool autobroker
Definition: NetworkBrokerData.hpp:51
std::string connectionAddress
the address for connecting
Definition: NetworkBrokerData.hpp:37
bool noAckConnection
Definition: NetworkBrokerData.hpp:54
bool useJsonSerialization
for message serialization use JSON
Definition: NetworkBrokerData.hpp:56
bool observer
specify that the network connection is used for observation only
Definition: NetworkBrokerData.hpp:57
int brokerPort
the port number to use for the main broker interface
Definition: NetworkBrokerData.hpp:39
void setInterfaceType(gmlc::networking::InterfaceTypes type)
Definition: NetworkBrokerData.hpp:75
ServerModeOptions server_mode
setup a server mode
Definition: NetworkBrokerData.hpp:58
int maxMessageSize
maximum message size
Definition: NetworkBrokerData.hpp:43
std::string brokerInitString
a string containing arguments for the broker initialization
Definition: NetworkBrokerData.hpp:36
NetworkBrokerData(gmlc::networking::InterfaceTypes type)
Definition: NetworkBrokerData.hpp:66
std::string brokerName
the identifier for the broker
Definition: NetworkBrokerData.hpp:33
bool reuse_address
Definition: NetworkBrokerData.hpp:48
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14