| helics 3.6.1

TypedBrokerServer.hpp
1 /*
2 Copyright (c) 2017-2025,
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 <memory>
13 #include <nlohmann/json_fwd.hpp>
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>>>;
24 class TypedBrokerServer {
25 public:
26 virtual ~TypedBrokerServer() = default;
28 virtual void startServer(const nlohmann::json* 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
helics::ActionMessage
Definition: ActionMessage.hpp:30
helics::apps::TypedBrokerServer
Definition: TypedBrokerServer.hpp:24
helics::apps::TypedBrokerServer::processArgs
virtual void processArgs(std::string_view args)
Definition: TypedBrokerServer.cpp:101
helics::apps::TypedBrokerServer::startServer
virtual void startServer(const nlohmann::json *val, const std::shared_ptr< TypedBrokerServer > &ptr)=0
helics::apps::TypedBrokerServer::getOpenPort
static int getOpenPort(portData &pd)
Definition: TypedBrokerServer.cpp:104
helics::apps::TypedBrokerServer::generateMessageResponse
static ActionMessage generateMessageResponse(const ActionMessage &rxcmd, portData &pdata, CoreType ctype)
Definition: TypedBrokerServer.cpp:67
helics::apps::TypedBrokerServer::stopServer
virtual void stopServer()=0
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::CoreType
CoreType
Definition: CoreTypes.hpp:46