helics  3.0.1
BrokerServer.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 
8 #pragma once
9 #include "../core/Broker.hpp"
10 
11 #include <atomic>
12 #include <memory>
13 #include <string>
14 #include <thread>
15 #include <tuple>
16 #include <vector>
17 
18 namespace Json {
19 class Value;
20 }
21 
22 namespace helics {
23 class ActionMessage;
24 class helicsCLI11App;
25 
26 using portData = std::vector<std::tuple<int, bool, std::shared_ptr<Broker>>>;
27 
28 namespace apps {
29  class TypedBrokerServer;
32  class BrokerServer {
33  protected:
34  public:
36  BrokerServer() noexcept;
41  BrokerServer(int argc, char* argv[]);
45  explicit BrokerServer(std::vector<std::string> args);
49  explicit BrokerServer(const std::string& configFile);
51  ~BrokerServer();
53  void startServers();
55  static bool hasActiveBrokers();
57  void forceTerminate();
59  void closeServers();
60 
61  private:
63  std::unique_ptr<helicsCLI11App> generateArgProcessing();
64 
65  private:
66  bool zmq_server{false};
67  bool zmq_ss_server{false};
68  bool tcp_server{false};
69  bool udp_server{false};
70  // bool mpi_server{false}; //!< activate the MPI broker server
71  bool http_server{false};
72  bool websocket_server{false};
73  std::atomic<bool> exitall{false};
74  std::vector<std::unique_ptr<TypedBrokerServer>> servers;
75  std::string configFile_;
76  std::string server_name_;
77  std::unique_ptr<Json::Value> config_;
78  std::string mHttpArgs;
79  std::string mWebSocketArgs;
80  std::string mZmqArgs;
81  std::string mTcpArgs;
82  std::string mUdpArgs;
83  std::string mMpiArgs;
84 
85  public:
86  };
87 } // namespace apps
88 } // namespace helics
helics::apps::BrokerServer::closeServers
void closeServers()
Definition: BrokerServer.cpp:133
helics::BrokerFactory::getAllBrokers
std::vector< std::shared_ptr< Broker > > getAllBrokers()
Definition: BrokerFactory.cpp:220
helics::apps::BrokerServer::~BrokerServer
~BrokerServer()
Definition: BrokerServer.cpp:47
helics::apps::BrokerServer::hasActiveBrokers
static bool hasActiveBrokers()
Definition: BrokerServer.cpp:114
helics::apps::BrokerServer::startServers
void startServers()
Definition: BrokerServer.cpp:52
helics::BrokerFactory::brokersActive
bool brokersActive()
Definition: BrokerFactory.cpp:225
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::apps::BrokerServer::forceTerminate
void forceTerminate()
Definition: BrokerServer.cpp:119
helics::apps::BrokerServer
Definition: BrokerServer.hpp:32
helics::apps::BrokerServer::BrokerServer
BrokerServer() noexcept
Definition: BrokerServer.cpp:24