helics  3.0.1
BasicHandleInfo.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 
9 #include "basic_CoreTypes.hpp"
10 #include "flagOperations.hpp"
11 
12 #include <string>
13 #include <utility>
14 #include <vector>
15 
16 namespace helics {
17 
20  mapped_flag = extra_flag1,
22  extra_flag2,
24  extra_flag3,
26 };
28 
31  public:
36  InterfaceHandle handle_id,
37  InterfaceType type_of_handle,
38  const std::string& key_name,
39  const std::string& type_name,
40  const std::string& unit_name):
41  handle{federate_id, handle_id},
42  handleType(type_of_handle), key(key_name), type(type_name), units(unit_name), type_in(type),
44 
45  {
46  /* NOTE:: all current cases already have std::string they are passing into the function and
47  most are short,so we are taking by reference to avoid a copy then move and just have a
48  copy*/
49  }
50 
51  const GlobalHandle handle{};
53  const InterfaceType handleType{InterfaceType::UNKNOWN};
54  bool used{false};
55  uint16_t flags{
56  0};
57 
58  const std::string key;
59  const std::string type;
60  const std::string units;
61  const std::string& type_in;
62  const std::string& type_out;
63 
68  void setTag(const std::string& tag, const std::string& value);
70  const std::string& getTag(const std::string& tag) const;
72  const std::pair<std::string, std::string>& getTagByIndex(size_t index) const
73  {
74  return tags[index];
75  }
77  auto tagCount() const { return tags.size(); }
78 
79  private:
80  std::vector<std::pair<std::string, std::string>> tags;
81 };
82 } // namespace helics
extra_flag3
@ extra_flag3
extra flag
Definition: flagOperations.hpp:31
helics::BasicHandleInfo::getTag
const std::string & getTag(const std::string &tag) const
Definition: BasicHandleInfo.cpp:25
helics::InterfaceType
InterfaceType
Definition: CoreTypes.hpp:96
helics::BasicHandleInfo::type_out
const std::string & type_out
the output type of a filter
Definition: BasicHandleInfo.hpp:62
helics::InterfaceHandle
Definition: LocalFederateId.hpp:65
extra_flag2
@ extra_flag2
extra flag
Definition: flagOperations.hpp:27
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:68
helics::handle_flag_definitions
handle_flag_definitions
Definition: BasicHandleInfo.hpp:19
helics::GlobalHandle::handle
InterfaceHandle handle
the interface handle component
Definition: GlobalFederateId.hpp:131
helics::BasicHandleInfo::handle
const GlobalHandle handle
the global federate id for the creator of the handle
Definition: BasicHandleInfo.hpp:51
helics::has_source_filter_flag
@ has_source_filter_flag
indicator that an endpoint or message has a source filter
Definition: BasicHandleInfo.hpp:21
helics::BasicHandleInfo::getFederateId
GlobalFederateId getFederateId() const
Definition: BasicHandleInfo.hpp:66
extra_flag1
@ extra_flag1
extra flag
Definition: flagOperations.hpp:23
helics::BasicHandleInfo
Definition: BasicHandleInfo.hpp:30
helics::BasicHandleInfo::type_in
const std::string & type_in
the input type of a filter
Definition: BasicHandleInfo.hpp:61
helics::BasicHandleInfo::setTag
void setTag(const std::string &tag, const std::string &value)
Definition: BasicHandleInfo.cpp:12
helics::BasicHandleInfo::getInterfaceHandle
InterfaceHandle getInterfaceHandle() const
Definition: BasicHandleInfo.hpp:64
helics::has_non_cloning_dest_filter_flag
@ has_non_cloning_dest_filter_flag
Definition: BasicHandleInfo.hpp:25
helics::BasicHandleInfo::local_fed_id
LocalFederateId local_fed_id
the local federate id of the handle
Definition: BasicHandleInfo.hpp:52
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:55
extra_flag4
@ extra_flag4
extra flag
Definition: flagOperations.hpp:32
helics::BasicHandleInfo::handleType
const InterfaceType handleType
the type of the handle
Definition: BasicHandleInfo.hpp:53
helics::LocalFederateId
Definition: LocalFederateId.hpp:22
helics::BasicHandleInfo::BasicHandleInfo
BasicHandleInfo() noexcept
Definition: BasicHandleInfo.hpp:33
helics::BasicHandleInfo::type
const std::string type
the type of data used by the handle
Definition: BasicHandleInfo.hpp:59
helics::BasicHandleInfo::units
const std::string units
the units associated with the handle
Definition: BasicHandleInfo.hpp:60
helics::GlobalHandle
Definition: GlobalFederateId.hpp:128
helics::BasicHandleInfo::used
bool used
indicator that the handle is being used to link with another federate
Definition: BasicHandleInfo.hpp:54
helics::BasicHandleInfo::getTagByIndex
const std::pair< std::string, std::string > & getTagByIndex(size_t index) const
Definition: BasicHandleInfo.hpp:72
helics::BasicHandleInfo::BasicHandleInfo
BasicHandleInfo(GlobalFederateId federate_id, InterfaceHandle handle_id, InterfaceType type_of_handle, const std::string &key_name, const std::string &type_name, const std::string &unit_name)
Definition: BasicHandleInfo.hpp:35
flagOperations.hpp
helics::BasicHandleInfo::key
const std::string key
the name of the handle
Definition: BasicHandleInfo.hpp:58
helics::BasicHandleInfo::tagCount
auto tagCount() const
Definition: BasicHandleInfo.hpp:77
helics::GlobalHandle::fed_id
GlobalFederateId fed_id
the federate id component
Definition: GlobalFederateId.hpp:130
helics::has_dest_filter_flag
@ has_dest_filter_flag
indicator that an endpoint or message has a destination filter
Definition: BasicHandleInfo.hpp:23