| helics 3.6.1

BasicHandleInfo.hpp
1 /*
2 Copyright (c) 2017-2025,
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
20 class BasicHandleInfo {
21 public:
23 BasicHandleInfo() noexcept: type_in(type), type_out(units) {}
25 BasicHandleInfo(GlobalFederateId federate_id,
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
37 BasicHandleInfo(GlobalFederateId federate_id,
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{};
50 LocalFederateId local_fed_id{};
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;
62 InterfaceHandle getInterfaceHandle() const { return handle.handle; }
64 GlobalFederateId getFederateId() const { return handle.fed_id; }
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
helics::BasicHandleInfo
Definition: BasicHandleInfo.hpp:20
helics::BasicHandleInfo::key
const std::string key
the name of the handle
Definition: BasicHandleInfo.hpp:56
helics::BasicHandleInfo::getTag
const std::string & getTag(std::string_view tag) const
Definition: BasicHandleInfo.cpp:27
helics::BasicHandleInfo::type
const std::string type
the type of data used by the handle
Definition: BasicHandleInfo.hpp:57
helics::BasicHandleInfo::getFederateId
GlobalFederateId getFederateId() const
Definition: BasicHandleInfo.hpp:64
helics::BasicHandleInfo::used
bool used
Definition: BasicHandleInfo.hpp:52
helics::BasicHandleInfo::tagCount
auto tagCount() const
Definition: BasicHandleInfo.hpp:75
helics::BasicHandleInfo::units
const std::string units
the units associated with the handle
Definition: BasicHandleInfo.hpp:58
helics::BasicHandleInfo::handle
const GlobalHandle handle
the global federate id for the creator of the handle
Definition: BasicHandleInfo.hpp:49
helics::BasicHandleInfo::setTag
void setTag(std::string_view tag, std::string_view value)
Definition: BasicHandleInfo.cpp:16
helics::BasicHandleInfo::type_in
const std::string & type_in
the input type of a filter
Definition: BasicHandleInfo.hpp:59
helics::BasicHandleInfo::getTagByIndex
const std::pair< std::string, std::string > & getTagByIndex(size_t index) const
Definition: BasicHandleInfo.hpp:70
helics::BasicHandleInfo::BasicHandleInfo
BasicHandleInfo() noexcept
Definition: BasicHandleInfo.hpp:23
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::flags
uint16_t flags
flags corresponding to the flags used in ActionMessages +some extra ones
Definition: BasicHandleInfo.hpp:54
helics::BasicHandleInfo::handleType
const InterfaceType handleType
the type of the handle
Definition: BasicHandleInfo.hpp:51
helics::BasicHandleInfo::local_fed_id
LocalFederateId local_fed_id
the local federate id of the handle
Definition: BasicHandleInfo.hpp:50
helics::BasicHandleInfo::type_out
const std::string & type_out
the output type of a filter
Definition: BasicHandleInfo.hpp:60
helics::BasicHandleInfo::getInterfaceHandle
InterfaceHandle getInterfaceHandle() const
Definition: BasicHandleInfo.hpp:62
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:75
helics::GlobalHandle
Definition: GlobalFederateId.hpp:147
helics::GlobalHandle::fed_id
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:149
helics::GlobalHandle::handle
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:150
helics::InterfaceHandle
Definition: LocalFederateId.hpp:65
helics::LocalFederateId
Definition: LocalFederateId.hpp:22
flagOperations.hpp
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::InterfaceType
InterfaceType
Definition: CoreTypes.hpp:112