helics 3.7.0
Loading...
Searching...
No Matches
CommsBroker.hpp
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-License-Identifier: BSD-3-Clause
6*/
7
8#pragma once
9#include "helics/core/ActionMessage.hpp"
10
11#include <atomic>
12#include <memory>
13#include <string>
14
15namespace helics {
16class CommsInterface;
17
20template<class COMMS, class BrokerT>
21class CommsBroker: public BrokerT {
22 protected:
23 std::atomic<int> disconnectionStage{0};
24 std::unique_ptr<COMMS> comms;
25 std::atomic<bool> brokerInitialized{false};
26 public:
28 CommsBroker() noexcept;
30 explicit CommsBroker(bool arg) noexcept;
32 explicit CommsBroker(std::string_view obj_name);
34 ~CommsBroker();
35
36 private:
37 virtual void brokerDisconnect() override;
38 virtual bool tryReconnect() override;
40 void commDisconnect();
42 void loadComms();
43
44 public:
45 virtual void transmit(route_id rid, const ActionMessage& cmd) override;
46 virtual void transmit(route_id rid, ActionMessage&& cmd) override;
47
48 virtual void addRoute(route_id rid, int interfaceId, std::string_view routeInfo) override;
49
50 virtual void removeRoute(route_id rid) override;
52 COMMS* getCommsObjectPointer();
53};
54} // namespace helics
Definition ActionMessage.hpp:30
Definition CommsBroker.hpp:21
std::atomic< bool > brokerInitialized
atomic protecting local initialization
Definition CommsBroker.hpp:25
COMMS * getCommsObjectPointer()
Definition CommsBroker_impl.hpp:123
std::atomic< int > disconnectionStage
the stage of disconnection
Definition CommsBroker.hpp:23
CommsBroker() noexcept
Definition CommsBroker_impl.hpp:21
std::unique_ptr< COMMS > comms
the actual comms object
Definition CommsBroker.hpp:24
Definition GlobalFederateId.hpp:187
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition AsyncFedCallInfo.hpp:14
STL namespace.