helics  3.0.1
InterfaceInfo.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017-2021,
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  const std::string& key,
44  const std::string& type,
45  const std::string& units);
46  void createInput(InterfaceHandle handle,
47  const std::string& key,
48  const std::string& type,
49  const std::string& units);
50  void createEndpoint(InterfaceHandle handle,
51  const std::string& endpointName,
52  const std::string& type);
53 
54  auto getEndpoints() { return endpoints.lock(); }
55  auto getPublications() { return publications.lock(); }
56  auto getInputs() { return inputs.lock(); }
57  auto getEndpoints() const { return endpoints.lock_shared(); }
58  auto getPublications() const { return publications.lock_shared(); }
59  auto getInputs() const { return inputs.lock_shared(); }
60  auto cgetEndpoints() const { return endpoints.lock_shared(); }
61  auto cgetPublications() const { return publications.lock_shared(); }
62  auto cgetInputs() const { return inputs.lock_shared(); }
64  void setGlobalId(GlobalFederateId newglobalId) { global_id = newglobalId; }
66  void setChangeUpdateFlag(bool updateFlag);
68  bool getChangeUpdateFlag() const { return only_update_on_change; }
70  bool setInputProperty(InterfaceHandle id, int32_t option, int32_t value);
71  bool setPublicationProperty(InterfaceHandle id, int32_t option, int32_t value);
72  bool setEndpointProperty(InterfaceHandle id, int32_t option, int32_t value);
74  int32_t getInputProperty(InterfaceHandle id, int32_t option) const;
75  int32_t getPublicationProperty(InterfaceHandle id, int32_t option) const;
76  int32_t getEndpointProperty(InterfaceHandle id, int32_t option) const;
77 
79  std::vector<std::pair<int, std::string>> checkInterfacesForIssues();
81  void generateInferfaceConfig(Json::Value& base) const;
83  void GenerateDataFlowGraph(Json::Value& base) const;
84 
85  private:
86  std::atomic<GlobalFederateId> global_id;
87  bool only_update_on_change{
88  false};
90  gmlc::containers::DualMappedPointerVector<PublicationInfo, std::string, InterfaceHandle>>
91  publications;
93  gmlc::containers::DualMappedPointerVector<EndpointInfo, std::string, InterfaceHandle>>
94  endpoints;
96  gmlc::containers::DualMappedPointerVector<InputInfo, std::string, InterfaceHandle>>
97  inputs;
98 };
99 } // namespace helics
helics::InputInfo
Definition: InputInfo.hpp:19
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:463
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:68
helics::InterfaceInfo::getInputProperty
int32_t getInputProperty(InterfaceHandle id, int32_t option) const
Definition: InterfaceInfo.cpp:221
CONNECTIONS
@ CONNECTIONS
print summary+ federate level connection information
Definition: loggingHelper.hpp:26
helics::InterfaceInfo::getChangeUpdateFlag
bool getChangeUpdateFlag() const
Definition: InterfaceInfo.hpp:68
helics::InterfaceInfo::setGlobalId
void setGlobalId(GlobalFederateId newglobalId)
Definition: InterfaceInfo.hpp:64
InterfaceInfo.hpp
helics::InterfaceInfo::setChangeUpdateFlag
void setChangeUpdateFlag(bool updateFlag)
Definition: InterfaceInfo.cpp:45
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:406
helics::PublicationInfo
Definition: PublicationInfo.hpp:17
helics::InterfaceInfo::setInputProperty
bool setInputProperty(InterfaceHandle id, int32_t option, int32_t value)
Definition: InterfaceInfo.cpp:116
gmlc::libguarded::shared_guarded
Definition: application_api/Federate.hpp:28
helics::InterfaceInfo::checkInterfacesForIssues
std::vector< std::pair< int, std::string > > checkInterfacesForIssues()
Definition: InterfaceInfo.cpp:317