helics  3.5.2
TypedBrokerServer.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 
8 #pragma once
9 
10 #include "../core/ActionMessage.hpp"
11 
12 #include <json/forwards.h>
13 #include <memory>
14 #include <string>
15 #include <tuple>
16 #include <vector>
17 
18 namespace helics {
19 class Broker;
20 namespace apps {
21 
22  using portData = std::vector<std::tuple<int, bool, std::shared_ptr<Broker>>>;
25  public:
26  virtual ~TypedBrokerServer() = default;
28  virtual void startServer(const Json::Value* val,
29  const std::shared_ptr<TypedBrokerServer>& ptr) = 0;
31  virtual void stopServer() = 0;
33  virtual void processArgs(std::string_view args);
34 
35  protected:
37  static ActionMessage
38  generateMessageResponse(const ActionMessage& rxcmd, portData& pdata, CoreType ctype);
40  static int getOpenPort(portData& pd);
41  /* assign a port in the portData structure*/
42  static void assignPort(portData& pd, int pnumber, std::shared_ptr<Broker>& brk);
43  /* log a message to the console */
44  static void logMessage(std::string_view message);
45  };
46 } // namespace apps
47 } // namespace helics
Definition: ActionMessage.hpp:30
Definition: TypedBrokerServer.hpp:24
virtual void processArgs(std::string_view args)
Definition: TypedBrokerServer.cpp:99
static int getOpenPort(portData &pd)
Definition: TypedBrokerServer.cpp:102
virtual void startServer(const Json::Value *val, const std::shared_ptr< TypedBrokerServer > &ptr)=0
static ActionMessage generateMessageResponse(const ActionMessage &rxcmd, portData &pdata, CoreType ctype)
Definition: TypedBrokerServer.cpp:65
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
CoreType
Definition: CoreTypes.hpp:46