helics  3.0.1
TypedBrokerServer.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 
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) = 0;
30  virtual void stopServer() = 0;
32  virtual void processArgs(const std::string& args);
33 
34  protected:
36  static ActionMessage
37  generateMessageResponse(const ActionMessage& rxcmd, portData& pdata, CoreType ctype);
39  static int getOpenPort(portData& pd);
40  /* assign a port in the portData structure*/
41  static void assignPort(portData& pd, int pnumber, std::shared_ptr<Broker>& brk);
42  /* log a message to the console */
43  static void logMessage(const std::string& message);
44  };
45 } // namespace apps
46 } // namespace helics
helics::apps::TypedBrokerServer::processArgs
virtual void processArgs(const std::string &args)
Definition: TypedBrokerServer.cpp:99
helics::extractInterfaceandPortString
std::pair< std::string, std::string > extractInterfaceandPortString(const std::string &address)
Definition: NetworkBrokerData.cpp:251
helics::CoreType
CoreType
Definition: CoreTypes.hpp:36
helics::BrokerFactory::findBroker
std::shared_ptr< Broker > findBroker(const std::string &brokerName)
Definition: BrokerFactory.cpp:182
helics::apps::TypedBrokerServer::startServer
virtual void startServer(const Json::Value *val)=0
helics::apps::TypedBrokerServer::generateMessageResponse
static ActionMessage generateMessageResponse(const ActionMessage &rxcmd, portData &pdata, CoreType ctype)
Definition: TypedBrokerServer.cpp:65
helics::ActionMessage
Definition: ActionMessage.hpp:30
helics::apps::TypedBrokerServer::getOpenPort
static int getOpenPort(portData &pd)
Definition: TypedBrokerServer.cpp:102
helics::ActionMessage::messageID
int32_t messageID
8 – message ID for a variety of purposes
Definition: ActionMessage.hpp:36
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::apps::TypedBrokerServer
Definition: TypedBrokerServer.hpp:24
helics::BrokerFactory::create
std::shared_ptr< Broker > create(CoreType type, const std::string &configureString)
Definition: BrokerFactory.cpp:98
helics::ActionMessage::action
action_message_def::action_t action() const noexcept
Definition: ActionMessage.hpp:88
helics::BrokerFactory::findJoinableBrokerOfType
std::shared_ptr< Broker > findJoinableBrokerOfType(CoreType type)
Definition: BrokerFactory.cpp:214
helics::apps::TypedBrokerServer::stopServer
virtual void stopServer()=0