helics  3.3.0
IpcComms.h
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 #pragma once
8 
9 #include "../CommsInterface.hpp"
10 
11 #include <atomic>
12 #include <string>
13 
14 namespace helics {
15 namespace ipc {
17  class IpcComms final: public CommsInterface {
18  public:
20  IpcComms();
22  ~IpcComms();
23 
24  virtual void loadNetworkInfo(const NetworkBrokerData& netInfo) override;
25 
26  private:
27  std::atomic<int> ipcbackchannel{
28  0};
29  virtual void queue_rx_function() override;
30  virtual void queue_tx_function() override;
31  virtual void closeReceiver() override;
32 
33  public:
35  int getPort() const { return -1; }
36 
37  std::string getAddress() const;
38  };
39 
40 #define IPC_BACKCHANNEL_TRY_RESET 2
41 #define IPC_BACKCHANNEL_DISCONNECT 4
42 
43 } // namespace ipc
44 } // namespace helics
helics::CommsInterface::brokerTargetAddress
std::string brokerTargetAddress
the base for the broker address
Definition: CommsInterface.hpp:125
helics::CommsInterface::propertyLock
bool propertyLock()
Definition: CommsInterface.cpp:153
helics::ipc::IpcComms::~IpcComms
~IpcComms()
Definition: IpcComms.cpp:37
helics::ipc::IpcComms
Definition: IpcComms.h:17
helics::CommsInterface::name
std::string name
the name of the object
Definition: CommsInterface.hpp:123
helics::CommsInterface::disconnecting
std::atomic< bool > disconnecting
flag indicating that the comm system is in the process of disconnecting
Definition: CommsInterface.hpp:158
helics::ipc::IpcComms::IpcComms
IpcComms()
Definition: IpcComms.cpp:31
helics::ipc::IpcComms::getPort
int getPort() const
Definition: IpcComms.h:35
helics::ipc::OwnedQueue
Definition: IpcQueueHelper.h:90
helics::ipc::IpcComms::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: IpcComms.cpp:42
helics::NetworkBrokerData
Definition: NetworkBrokerData.hpp:23
helics::CommsInterface::connectionTimeout
std::chrono::milliseconds connectionTimeout
Definition: CommsInterface.hpp:146
helics::ActionMessage
Definition: ActionMessage.hpp:30
helics::CommsInterface::logError
void logError(std::string_view message) const
Definition: CommsInterface.cpp:581
helics::CommsInterface::txQueue
gmlc::containers::BlockingPriorityQueue< std::pair< route_id, ActionMessage > > txQueue
set of messages waiting to be transmitted
Definition: CommsInterface.hpp:155
helics::CommsInterface::ActionCallback
std::function< void(ActionMessage &&)> ActionCallback
the callback for what to do with a received message
Definition: CommsInterface.hpp:151
helics::CommsInterface::ConnectionStatus::ERRORED
@ ERRORED
some ERRORED occurred on the connection
helics::CommsInterface::disconnect
void disconnect()
Definition: CommsInterface.cpp:385
helics::CommsInterface::transmit
void transmit(route_id rid, const ActionMessage &cmd)
Definition: CommsInterface.cpp:170
helics::CommsInterface::ConnectionStatus::TERMINATED
@ TERMINATED
the connection has been TERMINATED
helics::CommsInterface::localTargetAddress
std::string localTargetAddress
the base for the receive address
Definition: CommsInterface.hpp:124
helics::CommsInterface
Definition: CommsInterface.hpp:25
helics::isProtocolCommand
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:226
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::CommsInterface::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo)
Definition: CommsInterface.cpp:104
helics::CommsInterface::serverMode
bool serverMode
some comms have a server mode and non-server mode
Definition: CommsInterface.hpp:141
helics::CommsInterface::maxMessageSize
int maxMessageSize
the maximum message size for the queues (if needed)
Definition: CommsInterface.hpp:147
helics::isPriorityCommand
bool isPriorityCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:232
helics::CommsInterface::ConnectionStatus::CONNECTED
@ CONNECTED
we are CONNECTED
helics::CommsInterface::maxMessageCount
int maxMessageCount
the maximum number of message to buffer (if needed)
Definition: CommsInterface.hpp:148