helics  3.5.2
InterfaceInfo.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2024,
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 #include "../common/GuardedTypes.hpp"
9 #include "EndpointInfo.hpp"
10 #include "FederateIdExtra.hpp"
11 #include "InputInfo.hpp"
12 #include "PublicationInfo.hpp"
13 #include "gmlc/containers/DualMappedPointerVector.hpp"
14 
15 #include "json/forwards.h"
16 #include <atomic>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
24 namespace helics {
27  public:
28  InterfaceInfo() = default;
29  const PublicationInfo* getPublication(const std::string& pubName) const;
30  const PublicationInfo* getPublication(InterfaceHandle handle) const;
31  PublicationInfo* getPublication(const std::string& pubName);
32  PublicationInfo* getPublication(InterfaceHandle handle);
33  const InputInfo* getInput(const std::string& inputName) const;
34  const InputInfo* getInput(InterfaceHandle handle) const;
35  InputInfo* getInput(const std::string& inputName);
36  InputInfo* getInput(InterfaceHandle handle);
37  const EndpointInfo* getEndpoint(const std::string& endpointName) const;
38  const EndpointInfo* getEndpoint(InterfaceHandle handle) const;
39  EndpointInfo* getEndpoint(const std::string& endpointName);
40  EndpointInfo* getEndpoint(InterfaceHandle handle);
41 
42  void createPublication(InterfaceHandle handle,
43  std::string_view key,
44  std::string_view type,
45  std::string_view units,
46  std::uint16_t flags);
47  void createInput(InterfaceHandle handle,
48  std::string_view key,
49  std::string_view type,
50  std::string_view units,
51  std::uint16_t flags);
52  void createEndpoint(InterfaceHandle handle,
53  std::string_view endpointName,
54  std::string_view type,
55  std::uint16_t flags);
56 
57  auto getEndpoints() { return endpoints.lock(); }
58  auto getPublications() { return publications.lock(); }
59  auto getInputs() { return inputs.lock(); }
60  auto getEndpoints() const { return endpoints.lock_shared(); }
61  auto getPublications() const { return publications.lock_shared(); }
62  auto getInputs() const { return inputs.lock_shared(); }
63  auto cgetEndpoints() const { return endpoints.lock_shared(); }
64  auto cgetPublications() const { return publications.lock_shared(); }
65  auto cgetInputs() const { return inputs.lock_shared(); }
67  void setGlobalId(GlobalFederateId newglobalId) { global_id = newglobalId; }
69  void setChangeUpdateFlag(bool updateFlag);
71  bool getChangeUpdateFlag() const { return only_update_on_change; }
73  bool setInputProperty(InterfaceHandle hid, int32_t option, int32_t value);
74  bool setPublicationProperty(InterfaceHandle hid, int32_t option, int32_t value);
75  bool setEndpointProperty(InterfaceHandle hid, int32_t option, int32_t value);
77  int32_t getInputProperty(InterfaceHandle hid, int32_t option) const;
78  int32_t getPublicationProperty(InterfaceHandle hid, int32_t option) const;
79  int32_t getEndpointProperty(InterfaceHandle hid, int32_t option) const;
80 
82  std::vector<std::pair<int, std::string>> checkInterfacesForIssues();
84  void generateInferfaceConfig(Json::Value& base) const;
86  void generateDataFlowGraph(Json::Value& base) const;
88  void getUnconnectedInterfaces(Json::Value& base) const;
90  void reset();
92  void disconnectFederate(GlobalFederateId fedToDisconnect, Time disconnectTime);
93 
94  private:
95  std::atomic<GlobalFederateId> global_id;
97  bool only_update_on_change{false};
99  gmlc::containers::DualMappedPointerVector<PublicationInfo, std::string, InterfaceHandle>>
100  publications;
102  gmlc::containers::DualMappedPointerVector<EndpointInfo, std::string, InterfaceHandle>>
103  endpoints;
105  gmlc::containers::DualMappedPointerVector<InputInfo, std::string, InterfaceHandle>>
106  inputs;
107 };
108 } // namespace helics
Definition: application_api/Federate.hpp:27
Definition: EndpointInfo.hpp:32
Definition: GlobalFederateId.hpp:75
Definition: InputInfo.hpp:20
Definition: LocalFederateId.hpp:65
Definition: InterfaceInfo.hpp:26
std::vector< std::pair< int, std::string > > checkInterfacesForIssues()
Definition: InterfaceInfo.cpp:235
bool getChangeUpdateFlag() const
Definition: InterfaceInfo.hpp:71
void getUnconnectedInterfaces(Json::Value &base) const
Definition: InterfaceInfo.cpp:329
int32_t getInputProperty(InterfaceHandle hid, int32_t option) const
Definition: InterfaceInfo.cpp:208
void disconnectFederate(GlobalFederateId fedToDisconnect, Time disconnectTime)
Definition: InterfaceInfo.cpp:513
void generateInferfaceConfig(Json::Value &base) const
Definition: InterfaceInfo.cpp:388
void setGlobalId(GlobalFederateId newglobalId)
Definition: InterfaceInfo.hpp:67
void generateDataFlowGraph(Json::Value &base) const
Definition: InterfaceInfo.cpp:445
void reset()
Definition: InterfaceInfo.cpp:21
bool setInputProperty(InterfaceHandle hid, int32_t option, int32_t value)
Definition: InterfaceInfo.cpp:177
void setChangeUpdateFlag(bool updateFlag)
Definition: InterfaceInfo.cpp:106
Definition: PublicationInfo.hpp:27
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27