helics  3.5.2
BasicHandleInfo.hpp
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 
9 #include "basic_CoreTypes.hpp"
10 #include "flagOperations.hpp"
11 
12 #include <optional>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 namespace helics {
18 
21  public:
26  InterfaceHandle handle_id,
27  InterfaceType type_of_handle,
28  std::string_view key_name,
29  std::string_view type_name,
30  std::string_view unit_name):
31  handle{federate_id, handle_id}, handleType(type_of_handle), key(key_name), type(type_name),
32  units(unit_name), type_in(type), type_out(units)
33 
34  {
35  }
36 
38  InterfaceHandle handle_id,
39  InterfaceType type_of_handle) noexcept:
40  handle{federate_id, handle_id}, handleType(type_of_handle), type_in(type), type_out(units)
41  {
42  }
43 
44  BasicHandleInfo(GlobalHandle gHandle, InterfaceType type_of_handle) noexcept:
45  handle{gHandle}, handleType(type_of_handle), type_in(type), type_out(units)
46  {
47  }
48 
49  const GlobalHandle handle{};
51  const InterfaceType handleType{InterfaceType::UNKNOWN};
52  bool used{false};
54  uint16_t flags{0};
55 
56  const std::string key;
57  const std::string type;
58  const std::string units;
59  const std::string& type_in;
60  const std::string& type_out;
66  void setTag(std::string_view tag, std::string_view value);
68  const std::string& getTag(std::string_view tag) const;
70  const std::pair<std::string, std::string>& getTagByIndex(size_t index) const
71  {
72  return tags[index];
73  }
75  auto tagCount() const { return tags.size(); }
76 
77  private:
78  std::vector<std::pair<std::string, std::string>> tags;
79  static const std::string emptyString;
80 };
81 } // namespace helics
Definition: BasicHandleInfo.hpp:20
const std::string key
the name of the handle
Definition: BasicHandleInfo.hpp:56
const std::string & getTag(std::string_view tag) const
Definition: BasicHandleInfo.cpp:26
const std::string type
the type of data used by the handle
Definition: BasicHandleInfo.hpp:57
GlobalFederateId getFederateId() const
Definition: BasicHandleInfo.hpp:64
bool used
Definition: BasicHandleInfo.hpp:52
auto tagCount() const
Definition: BasicHandleInfo.hpp:75
const std::string units
the units associated with the handle
Definition: BasicHandleInfo.hpp:58
const GlobalHandle handle
the global federate id for the creator of the handle
Definition: BasicHandleInfo.hpp:49
void setTag(std::string_view tag, std::string_view value)
Definition: BasicHandleInfo.cpp:15
const std::string & type_in
the input type of a filter
Definition: BasicHandleInfo.hpp:59
const std::pair< std::string, std::string > & getTagByIndex(size_t index) const
Definition: BasicHandleInfo.hpp:70
BasicHandleInfo() noexcept
Definition: BasicHandleInfo.hpp:23
BasicHandleInfo(GlobalFederateId federate_id, InterfaceHandle handle_id, InterfaceType type_of_handle, std::string_view key_name, std::string_view type_name, std::string_view unit_name)
Definition: BasicHandleInfo.hpp:25
uint16_t flags
flags corresponding to the flags used in ActionMessages +some extra ones
Definition: BasicHandleInfo.hpp:54
const InterfaceType handleType
the type of the handle
Definition: BasicHandleInfo.hpp:51
LocalFederateId local_fed_id
the local federate id of the handle
Definition: BasicHandleInfo.hpp:50
const std::string & type_out
the output type of a filter
Definition: BasicHandleInfo.hpp:60
InterfaceHandle getInterfaceHandle() const
Definition: BasicHandleInfo.hpp:62
Definition: GlobalFederateId.hpp:75
Definition: GlobalFederateId.hpp:147
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:149
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:150
Definition: LocalFederateId.hpp:65
Definition: LocalFederateId.hpp:22
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
InterfaceType
Definition: CoreTypes.hpp:111