helics  3.3.0
InterfaceInfo.hpp
Go to the documentation of this file.
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 #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 id, int32_t option, int32_t value);
74  bool setPublicationProperty(InterfaceHandle id, int32_t option, int32_t value);
75  bool setEndpointProperty(InterfaceHandle id, int32_t option, int32_t value);
77  int32_t getInputProperty(InterfaceHandle id, int32_t option) const;
78  int32_t getPublicationProperty(InterfaceHandle id, int32_t option) const;
79  int32_t getEndpointProperty(InterfaceHandle id, 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;
87 
88  private:
89  std::atomic<GlobalFederateId> global_id;
90  bool only_update_on_change{
91  false};
93  gmlc::containers::DualMappedPointerVector<PublicationInfo, std::string, InterfaceHandle>>
94  publications;
96  gmlc::containers::DualMappedPointerVector<EndpointInfo, std::string, InterfaceHandle>>
97  endpoints;
99  gmlc::containers::DualMappedPointerVector<InputInfo, std::string, InterfaceHandle>>
100  inputs;
101 };
102 } // namespace helics
helics::InputInfo
Definition: InputInfo.hpp:20
helics::targeted_flag
@ targeted_flag
flag indicating an endpoint is targeted
Definition: flagOperations.hpp:57
helics::optional_flag
@ optional_flag
flag indicating that a connection is optional and may not be matched
Definition: flagOperations.hpp:53
helics::InterfaceInfo
Definition: InterfaceInfo.hpp:26
helics::EndpointInfo
Definition: EndpointInfo.hpp:32
helics_definitions.hpp
base helics enumerations for C++ API's, a namespace wrapper for the definitions defined in helics_enu...
helics::InterfaceHandle
Definition: LocalFederateId.hpp:65
helics::InterfaceInfo::GenerateDataFlowGraph
void GenerateDataFlowGraph(Json::Value &base) const
Definition: InterfaceInfo.cpp:371
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:72
helics::only_transmit_on_change_flag
@ only_transmit_on_change_flag
indicator that the interface should only transmit on change
Definition: flagOperations.hpp:62
helics::InterfaceInfo::getInputProperty
int32_t getInputProperty(InterfaceHandle id, int32_t option) const
Definition: InterfaceInfo.cpp:193
helics::only_update_on_change_flag
@ only_update_on_change_flag
flag indicating that the values should only be updated on change
Definition: flagOperations.hpp:49
helics::InterfaceInfo::getChangeUpdateFlag
bool getChangeUpdateFlag() const
Definition: InterfaceInfo.hpp:71
helics::single_connection_flag
@ single_connection_flag
flag indicating that the interface accepts only a single connection
Definition: flagOperations.hpp:47
helics::InterfaceInfo::setGlobalId
void setGlobalId(GlobalFederateId newglobalId)
Definition: InterfaceInfo.hpp:67
InterfaceInfo.hpp
helics::InterfaceInfo::setChangeUpdateFlag
void setChangeUpdateFlag(bool updateFlag)
Definition: InterfaceInfo.cpp:91
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::InterfaceInfo::generateInferfaceConfig
void generateInferfaceConfig(Json::Value &base) const
Definition: InterfaceInfo.cpp:314
helics::PublicationInfo
Definition: PublicationInfo.hpp:18
helics::buffer_data_flag
@ buffer_data_flag
indicator that the target is a destination target
Definition: flagOperations.hpp:41
helics::checkActionFlag
bool checkActionFlag(uint16_t flags, FlagIndex flag)
Definition: flagOperations.hpp:138
helics::InterfaceInfo::setInputProperty
bool setInputProperty(InterfaceHandle id, int32_t option, int32_t value)
Definition: InterfaceInfo.cpp:162
helics::required_flag
@ required_flag
flag indicating that an action or match is required
Definition: flagOperations.hpp:45
gmlc::libguarded::shared_guarded
Definition: application_api/Federate.hpp:28
helics::InterfaceInfo::checkInterfacesForIssues
std::vector< std::pair< int, std::string > > checkInterfacesForIssues()
Definition: InterfaceInfo.cpp:220
flagOperations.hpp