helics  3.3.0
TypedBrokerServer.hpp
1 /*
2 Copyright (c) 2017-2022,
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
helics::CoreType
CoreType
Definition: CoreTypes.hpp:36
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::BrokerFactory::create
std::shared_ptr< Broker > create(CoreType type, std::string_view configureString)
Definition: BrokerFactory.cpp:99
helics::apps::TypedBrokerServer::startServer
virtual void startServer(const Json::Value *val, const std::shared_ptr< TypedBrokerServer > &ptr)=0
helics::apps::TypedBrokerServer::getOpenPort
static int getOpenPort(portData &pd)
Definition: TypedBrokerServer.cpp:102
helics::BrokerFactory::findBroker
std::shared_ptr< Broker > findBroker(std::string_view brokerName)
Definition: BrokerFactory.cpp:183
helics::ActionMessage::messageID
int32_t messageID
8 – message ID for a variety of purposes
Definition: ActionMessage.hpp:36
helics::apps::TypedBrokerServer::processArgs
virtual void processArgs(std::string_view args)
Definition: TypedBrokerServer.cpp:99
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::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:211
helics::apps::TypedBrokerServer::stopServer
virtual void stopServer()=0