helics  2.8.1
InterfaceInfo.hpp
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 "InputInfo.hpp"
11 #include "PublicationInfo.hpp"
12 #include "federate_id_extra.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 
23 namespace helics {
26  public:
27  InterfaceInfo() = default;
28  const PublicationInfo* getPublication(const std::string& pubName) const;
29  const PublicationInfo* getPublication(interface_handle handle) const;
30  PublicationInfo* getPublication(const std::string& pubName);
31  PublicationInfo* getPublication(interface_handle handle);
32  const InputInfo* getInput(const std::string& inputName) const;
33  const InputInfo* getInput(interface_handle handle) const;
34  InputInfo* getInput(const std::string& inputName);
35  InputInfo* getInput(interface_handle handle);
36  const EndpointInfo* getEndpoint(const std::string& endpointName) const;
37  const EndpointInfo* getEndpoint(interface_handle handle) const;
38  EndpointInfo* getEndpoint(const std::string& endpointName);
39  EndpointInfo* getEndpoint(interface_handle handle);
40 
41  void createPublication(interface_handle handle,
42  const std::string& key,
43  const std::string& type,
44  const std::string& units);
45  void createInput(interface_handle handle,
46  const std::string& key,
47  const std::string& type,
48  const std::string& units);
49  void createEndpoint(interface_handle handle,
50  const std::string& endpointName,
51  const std::string& type);
52 
53  auto getEndpoints() { return endpoints.lock(); }
54  auto getPublications() { return publications.lock(); }
55  auto getInputs() { return inputs.lock(); }
56  auto getEndpoints() const { return endpoints.lock_shared(); }
57  auto getPublications() const { return publications.lock_shared(); }
58  auto getInputs() const { return inputs.lock_shared(); }
59  auto cgetEndpoints() const { return endpoints.lock_shared(); }
60  auto cgetPublications() const { return publications.lock_shared(); }
61  auto cgetInputs() const { return inputs.lock_shared(); }
63  void setGlobalId(global_federate_id newglobalId) { global_id = newglobalId; }
65  void setChangeUpdateFlag(bool updateFlag);
67  bool getChangeUpdateFlag() const { return only_update_on_change; }
69  bool setInputProperty(interface_handle id, int32_t option, int32_t value);
70  bool setPublicationProperty(interface_handle id, int32_t option, int32_t value);
71  bool setEndpointProperty(interface_handle id, int32_t option, int32_t value);
73  int32_t getInputProperty(interface_handle id, int32_t option) const;
74  int32_t getPublicationProperty(interface_handle id, int32_t option) const;
75  int32_t getEndpointProperty(interface_handle id, int32_t option) const;
76 
78  std::vector<std::pair<int, std::string>> checkInterfacesForIssues();
80  void generateInferfaceConfig(Json::Value& base) const;
82  void GenerateDataFlowGraph(Json::Value& base) const;
83 
84  private:
85  std::atomic<global_federate_id> global_id;
86  bool only_update_on_change{
87  false};
89  gmlc::containers::DualMappedPointerVector<PublicationInfo, std::string, interface_handle>>
90  publications;
92  gmlc::containers::DualMappedPointerVector<EndpointInfo, std::string, interface_handle>>
93  endpoints;
95  gmlc::containers::DualMappedPointerVector<InputInfo, std::string, interface_handle>>
96  inputs;
97 };
98 } // namespace helics
helics::InputInfo
Definition: InputInfo.hpp:19
connections
@ connections
print summary+ federate level connection information
Definition: loggingHelper.hpp:25
helics::InterfaceInfo
Definition: InterfaceInfo.hpp:25
helics::EndpointInfo
Definition: EndpointInfo.hpp:19
helics::InterfaceInfo::getInputProperty
int32_t getInputProperty(interface_handle id, int32_t option) const
Definition: InterfaceInfo.cpp:221
helics_definitions.hpp
base helics enumerations for C++ API's, a namespace wrapper for the definitions defined in helics_enu...
helics::global_federate_id
Definition: global_federate_id.hpp:68
helics::InterfaceInfo::GenerateDataFlowGraph
void GenerateDataFlowGraph(Json::Value &base) const
Definition: InterfaceInfo.cpp:463
helics::InterfaceInfo::setInputProperty
bool setInputProperty(interface_handle id, int32_t option, int32_t value)
Definition: InterfaceInfo.cpp:116
helics::InterfaceInfo::getChangeUpdateFlag
bool getChangeUpdateFlag() const
Definition: InterfaceInfo.hpp:67
helics::interface_handle
Definition: federate_id.hpp:65
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
gmlc::libguarded::shared_guarded
Definition: application_api/Federate.hpp:26
helics::InterfaceInfo::checkInterfacesForIssues
std::vector< std::pair< int, std::string > > checkInterfacesForIssues()
Definition: InterfaceInfo.cpp:317
helics::interface_type::ip
@ ip
using both types of ports (tcp/or udp) for communication
helics::InterfaceInfo::setGlobalId
void setGlobalId(global_federate_id newglobalId)
Definition: InterfaceInfo.hpp:63