| helics 3.6.1

PublicationInfo.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 "helicsTime.hpp"
11
12 #include <cstdint>
13 #include <string>
14 #include <utility>
15 #include <vector>
16
17 namespace helics {
18
19 struct SubscriberInformation {
20 GlobalHandle id;
21 std::string key;
22 SubscriberInformation() = default;
23 SubscriberInformation(GlobalHandle gid, std::string_view key_): id(gid), key(key_) {}
24 };
25
27 class PublicationInfo {
28 public:
30 PublicationInfo(GlobalHandle pid,
31 std::string_view pkey,
32 std::string_view ptype,
33 std::string_view punits): id(pid), key(pkey), type(ptype), units(punits)
34 {
35 }
36 const GlobalHandle id;
38 std::vector<SubscriberInformation> subscribers;
39 const std::string key;
40 const std::string type;
41 const std::string units;
42 SmallBuffer data;
43 Time lastPublishTime{timeZero};
44 bool has_update{false};
45 bool only_update_on_change{false};
46 bool required{false};
47 bool buffer_data{false};
48 int32_t requiredConnections{0};
49 Time minTimeGap{timeZero};
51 bool CheckSetValue(const char* dataToCheck,
52 uint64_t len,
53 Time currentTime,
54 bool forceChangeCheck);
58 bool addSubscriber(GlobalHandle newSubscriber, std::string_view inputName);
59
61 void removeSubscriber(GlobalHandle subscriberToRemove);
63 void disconnectFederate(GlobalFederateId fedToDisconnect);
64 void setProperty(int32_t option, int32_t value);
65 int32_t getProperty(int32_t option) const;
66 const std::string& getTargets() const;
67
68 private:
69 mutable std::string destTargets;
70 };
71 } // namespace helics
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:75
helics::GlobalHandle
Definition: GlobalFederateId.hpp:147
helics::PublicationInfo
Definition: PublicationInfo.hpp:27
helics::PublicationInfo::minTimeGap
Time minTimeGap
a time restriction on amount of publishing
Definition: PublicationInfo.hpp:49
helics::PublicationInfo::id
const GlobalHandle id
Definition: PublicationInfo.hpp:36
helics::PublicationInfo::PublicationInfo
PublicationInfo(GlobalHandle pid, std::string_view pkey, std::string_view ptype, std::string_view punits)
Definition: PublicationInfo.hpp:30
helics::PublicationInfo::addSubscriber
bool addSubscriber(GlobalHandle newSubscriber, std::string_view inputName)
Definition: PublicationInfo.cpp:41
helics::PublicationInfo::has_update
bool has_update
indicator that the publication has updates
Definition: PublicationInfo.hpp:44
helics::PublicationInfo::requiredConnections
int32_t requiredConnections
the number of required connections 0 is no requirement
Definition: PublicationInfo.hpp:48
helics::PublicationInfo::buffer_data
bool buffer_data
indicator that the publication should buffer data
Definition: PublicationInfo.hpp:47
helics::PublicationInfo::data
SmallBuffer data
the most recent publication data
Definition: PublicationInfo.hpp:42
helics::PublicationInfo::type
const std::string type
the type of the publication data
Definition: PublicationInfo.hpp:40
helics::PublicationInfo::disconnectFederate
void disconnectFederate(GlobalFederateId fedToDisconnect)
Definition: PublicationInfo.cpp:52
helics::PublicationInfo::units
const std::string units
the units of the publication data
Definition: PublicationInfo.hpp:41
helics::PublicationInfo::lastPublishTime
Time lastPublishTime
the time of the last publication
Definition: PublicationInfo.hpp:43
helics::PublicationInfo::removeSubscriber
void removeSubscriber(GlobalHandle subscriberToRemove)
Definition: PublicationInfo.cpp:62
helics::PublicationInfo::required
bool required
indicator that it is required to be output someplace
Definition: PublicationInfo.hpp:46
helics::PublicationInfo::subscribers
std::vector< SubscriberInformation > subscribers
container for all the subscribers of a publication
Definition: PublicationInfo.hpp:38
helics::PublicationInfo::CheckSetValue
bool CheckSetValue(const char *dataToCheck, uint64_t len, Time currentTime, bool forceChangeCheck)
Definition: PublicationInfo.cpp:18
helics::PublicationInfo::key
const std::string key
the key identifier for the publication
Definition: PublicationInfo.hpp:39
helics::SmallBuffer
Definition: SmallBuffer.hpp:25
helicsTime.hpp
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::timeZero
constexpr Time timeZero
Definition: helicsTime.hpp:31
helics::Time
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
helics::SubscriberInformation
Definition: PublicationInfo.hpp:19