| helics 3.6.1

ConnectorFederateManager.hpp
1 /*
2 Copyright (c) 2017-2025,
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 "../common/GuardedTypes.hpp"
10 #include "Filters.hpp"
11 #include "Translator.hpp"
12 #include "gmlc/containers/StringMappedVector.hpp"
13
14 #include <memory>
15 #include <string>
16
17 namespace helics {
18 class Core;
19 class Federate;
24 class ConnectorFederateManager {
25 public:
28 ConnectorFederateManager(Core* coreObj,
29 Federate* fFed,
30 LocalFederateId fid,
31 bool singleThreaded);
33 ~ConnectorFederateManager();
34
41 Filter&
42 registerFilter(std::string_view name, std::string_view type_in, std::string_view type_out);
43
50 CloningFilter& registerCloningFilter(std::string_view name,
51 std::string_view type_in,
52 std::string_view type_out);
53
59 Filter& registerFilter(FilterTypes type, std::string_view name);
60
66 CloningFilter& registerCloningFilter(FilterTypes type, std::string_view name);
67
71 Filter& getFilter(std::string_view name);
72 const Filter& getFilter(std::string_view name) const;
73 Filter& getFilter(int index);
74 const Filter& getFilter(int index) const;
75
82 Translator& registerTranslator(std::string_view name,
83 std::string_view endpointType,
84 std::string_view units);
85
89 Translator& getTranslator(std::string_view name);
90 const Translator& getTranslator(std::string_view name) const;
91 Translator& getTranslator(int index);
92 const Translator& getTranslator(int index) const;
93
95 int getFilterCount() const;
97 int getTranslatorCount() const;
99 void closeAllConnectors();
101 void disconnectAllConnectors();
103 void disconnect();
104
105 private:
106 Core* coreObject{nullptr};
107 shared_guarded_opt<gmlc::containers::StringMappedVector<std::unique_ptr<Filter>>> filters;
108 shared_guarded_opt<gmlc::containers::StringMappedVector<Translator>> translators;
109 Federate* fed = nullptr;
110 const LocalFederateId fedID;
111 };
112 } // namespace helics
helics::CloningFilter
Definition: Filters.hpp:111
helics::ConnectorFederateManager
Definition: ConnectorFederateManager.hpp:24
helics::ConnectorFederateManager::ConnectorFederateManager
ConnectorFederateManager(Core *coreObj, Federate *fFed, LocalFederateId fid, bool singleThreaded)
Definition: ConnectorFederateManager.cpp:18
helics::ConnectorFederateManager::registerTranslator
Translator & registerTranslator(std::string_view name, std::string_view endpointType, std::string_view units)
Definition: ConnectorFederateManager.cpp:47
helics::ConnectorFederateManager::getFilterCount
int getFilterCount() const
Definition: ConnectorFederateManager.cpp:131
helics::ConnectorFederateManager::disconnectAllConnectors
void disconnectAllConnectors()
Definition: ConnectorFederateManager.cpp:188
helics::ConnectorFederateManager::disconnect
void disconnect()
Definition: ConnectorFederateManager.cpp:199
helics::ConnectorFederateManager::getTranslator
Translator & getTranslator(std::string_view name)
Definition: ConnectorFederateManager.cpp:136
helics::ConnectorFederateManager::registerCloningFilter
CloningFilter & registerCloningFilter(std::string_view name, std::string_view type_in, std::string_view type_out)
Definition: ConnectorFederateManager.cpp:64
helics::ConnectorFederateManager::getFilter
Filter & getFilter(std::string_view name)
Definition: ConnectorFederateManager.cpp:100
helics::ConnectorFederateManager::~ConnectorFederateManager
~ConnectorFederateManager()
helics::ConnectorFederateManager::closeAllConnectors
void closeAllConnectors()
Definition: ConnectorFederateManager.cpp:171
helics::ConnectorFederateManager::getTranslatorCount
int getTranslatorCount() const
Definition: ConnectorFederateManager.cpp:167
helics::ConnectorFederateManager::registerFilter
Filter & registerFilter(std::string_view name, std::string_view type_in, std::string_view type_out)
Definition: ConnectorFederateManager.cpp:28
helics::Core
Definition: core/Core.hpp:41
helics::Federate
Definition: application_api/Federate.hpp:48
helics::Filter
Definition: Filters.hpp:39
helics::LocalFederateId
Definition: LocalFederateId.hpp:22
helics::Translator
Definition: application_api/Translator.hpp:35
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::FilterTypes
FilterTypes
Definition: Filters.hpp:21