helics  3.3.0
BasicHandleInfo.hpp
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 
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},
32  handleType(type_of_handle), key(key_name), type(type_name), units(unit_name), type_in(type),
34 
35  {
36  }
37 
38  const GlobalHandle handle{};
40  const InterfaceType handleType{InterfaceType::UNKNOWN};
41  bool used{false};
42  uint16_t flags{0};
44 
45  const std::string key;
46  const std::string type;
47  const std::string units;
48  const std::string& type_in;
49  const std::string& type_out;
50 
55  void setTag(std::string_view tag, std::string_view value);
57  const std::string& getTag(std::string_view tag) const;
59  const std::pair<std::string, std::string>& getTagByIndex(size_t index) const
60  {
61  return tags[index];
62  }
64  auto tagCount() const { return tags.size(); }
65 
66  private:
67  std::vector<std::pair<std::string, std::string>> tags;
68  static const std::string emptyString;
69 };
70 } // namespace helics
helics::InterfaceType
InterfaceType
Definition: CoreTypes.hpp:99
helics::BasicHandleInfo::type_out
const std::string & type_out
the output type of a filter
Definition: BasicHandleInfo.hpp:49
helics::InterfaceHandle
Definition: LocalFederateId.hpp:65
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:72
helics::GlobalHandle::handle
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:147
helics::BasicHandleInfo::handle
const GlobalHandle handle
the global federate id for the creator of the handle
Definition: BasicHandleInfo.hpp:38
helics::BasicHandleInfo::getFederateId
GlobalFederateId getFederateId() const
Definition: BasicHandleInfo.hpp:53
helics::BasicHandleInfo
Definition: BasicHandleInfo.hpp:20
helics::BasicHandleInfo::type_in
const std::string & type_in
the input type of a filter
Definition: BasicHandleInfo.hpp:48
helics::BasicHandleInfo::setTag
void setTag(std::string_view tag, std::string_view value)
Definition: BasicHandleInfo.cpp:15
helics::BasicHandleInfo::getInterfaceHandle
InterfaceHandle getInterfaceHandle() const
Definition: BasicHandleInfo.hpp:51
helics::BasicHandleInfo::BasicHandleInfo
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
helics::BasicHandleInfo::local_fed_id
LocalFederateId local_fed_id
the local federate id of the handle
Definition: BasicHandleInfo.hpp:39
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::BasicHandleInfo::flags
uint16_t flags
flags corresponding to the flags used in ActionMessages +some extra ones
Definition: BasicHandleInfo.hpp:43
helics::BasicHandleInfo::handleType
const InterfaceType handleType
the type of the handle
Definition: BasicHandleInfo.hpp:40
helics::LocalFederateId
Definition: LocalFederateId.hpp:22
helics::BasicHandleInfo::getTag
const std::string & getTag(std::string_view tag) const
Definition: BasicHandleInfo.cpp:26
helics::BasicHandleInfo::BasicHandleInfo
BasicHandleInfo() noexcept
Definition: BasicHandleInfo.hpp:23
helics::BasicHandleInfo::type
const std::string type
the type of data used by the handle
Definition: BasicHandleInfo.hpp:46
helics::BasicHandleInfo::units
const std::string units
the units associated with the handle
Definition: BasicHandleInfo.hpp:47
helics::GlobalHandle
Definition: GlobalFederateId.hpp:144
helics::BasicHandleInfo::used
bool used
Definition: BasicHandleInfo.hpp:41
helics::BasicHandleInfo::getTagByIndex
const std::pair< std::string, std::string > & getTagByIndex(size_t index) const
Definition: BasicHandleInfo.hpp:59
flagOperations.hpp
helics::BasicHandleInfo::key
const std::string key
the name of the handle
Definition: BasicHandleInfo.hpp:45
helics::BasicHandleInfo::tagCount
auto tagCount() const
Definition: BasicHandleInfo.hpp:64
helics::GlobalHandle::fed_id
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:146