helics
3.0.1
src
helics
apps
zmqBrokerServer.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 "TypedBrokerServer.hpp"
11
12
#include <atomic>
13
#include <memory>
14
#include <mutex>
15
#include <string>
16
#include <thread>
17
#include <utility>
18
19
#ifdef HELICS_ENABLE_ZMQ_CORE
20
namespace
zmq {
21
class
socket_t;
22
class
message_t;
23
class
context_t;
24
}
// namespace zmq
25
26
#endif
27
28
namespace
helics
{
29
class
Broker;
30
namespace
apps {
31
33
class
zmqBrokerServer
:
public
TypedBrokerServer
{
34
public
:
35
zmqBrokerServer
() =
default
;
36
explicit
zmqBrokerServer
(std::string server_name): name_(std::move(server_name)) {}
38
virtual
void
startServer
(
const
Json::Value* val)
override
;
40
virtual
void
stopServer
()
override
;
41
42
virtual
void
processArgs
(
const
std::string& args)
override
;
43
void
enableZmqServer(
bool
enabled) { zmq_enabled_ = enabled; }
44
void
enableZmqSsServer(
bool
enabled) { zmqss_enabled_ = enabled; }
45
46
private
:
47
struct
zmqServerData {
48
portData ports;
49
};
50
51
void
mainLoop();
52
#ifdef HELICS_ENABLE_ZMQ_CORE
53
std::pair<std::unique_ptr<zmq::socket_t>,
int
> loadZMQsocket(zmq::context_t& ctx);
54
std::pair<std::unique_ptr<zmq::socket_t>,
int
> loadZMQSSsocket(zmq::context_t& ctx);
55
56
static
zmqServerData generateServerData(
int
portNumber,
int
skip);
57
58
std::string generateResponseToMessage(zmq::message_t& msg, portData& pdata,
CoreType
ctype);
59
#endif
60
std::thread mainLoopThread;
61
std::mutex threadGuard;
62
const
Json::Value* config_{
nullptr
};
63
const
std::string name_;
64
bool
zmq_enabled_{
false
};
65
bool
zmqss_enabled_{
false
};
66
std::atomic_bool exitAll{
false
};
67
int
mZmqPort{0};
68
std::string mZmqInterface{
"tcp://127.0.0.1"
};
69
};
70
}
// namespace apps
71
}
// namespace helics
helics::apps::zmqBrokerServer::stopServer
virtual void stopServer() override
Definition:
zmqBrokerServer.cpp:64
helics::CoreType
CoreType
Definition:
CoreTypes.hpp:36
helics::CoreType::ZMQ
@ ZMQ
use the Zero MQ networking protocol
helics::apps::TypedBrokerServer::generateMessageResponse
static ActionMessage generateMessageResponse(const ActionMessage &rxcmd, portData &pdata, CoreType ctype)
Definition:
TypedBrokerServer.cpp:65
helics::CoreType::ZMQ_SS
@ ZMQ_SS
ZmqContextManager::getContextPointer
static std::shared_ptr< ZmqContextManager > getContextPointer(const std::string &contextName=std::string{})
Definition:
ZmqContextManager.cpp:37
helics::apps::zmqBrokerServer::processArgs
virtual void processArgs(const std::string &args) override
Definition:
zmqBrokerServer.cpp:30
helics::apps::zmqBrokerServer::startServer
virtual void startServer(const Json::Value *val) override
Definition:
zmqBrokerServer.cpp:49
helics::apps::zmqBrokerServer
Definition:
zmqBrokerServer.hpp:33
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::makePortAddress
std::string makePortAddress(const std::string &networkInterface, int portNumber)
Definition:
NetworkBrokerData.cpp:217
Generated by
1.8.17