9 #include "../core/core-exceptions.hpp"
10 #include "Federate.hpp"
15 #include <string_view>
29 int referenceIndex{-1};
30 void* dataReference{
nullptr};
34 bool changeDetectionEnabled{
false};
35 bool disableAssign{
false};
37 size_t customTypeHash{
39 mutable defV prevValue;
41 std::shared_ptr<units::precise_unit>
44 Publication() =
default;
51 Publication(ValueFederate* valueFed,
54 std::string_view type,
55 std::string_view units);
62 Publication(ValueFederate* valueFed,
64 std::string_view type,
65 std::string_view units = std::string_view{});
73 template<
class FedPtr>
76 std::string_view type = std::string_view(),
77 std::string_view units = std::string_view()):
78 Publication(std::addressof(*valueFed), key, type, units)
81 std::is_base_of<
ValueFederate, std::remove_reference_t<decltype(*valueFed)>>::value,
82 "first argument must be a pointer to a ValueFederate");
94 std::string_view type,
95 std::string_view units = std::string_view());
104 template<
class FedPtr>
107 std::string_view key,
108 std::string_view type,
109 std::string_view units = std::string_view()):
110 Publication(locality, std::addressof(*valueFed), key, type, units)
113 std::is_base_of<
ValueFederate, std::remove_reference_t<decltype(*valueFed)>>::value,
114 "first argument must be a pointer to a ValueFederate");
124 std::string_view key,
126 std::string_view units = std::string_view()):
136 template<
class FedPtr>
138 std::string_view key,
140 std::string_view units = std::string_view()):
153 std::string_view key,
155 std::string_view units = std::string_view()):
167 template<
class FedPtr>
170 std::string_view key,
172 std::string_view units = std::string_view()):
178 const std::string&
getType()
const {
return getExtractionType(); }
180 const std::string&
getUnits()
const {
return pubUnits; }
182 void addTarget(std::string_view target) { addDestinationTarget(target); }
192 void publish(
const std::vector<std::string>& val);
193 void publish(
const std::vector<double>& val);
194 void publish(
const double* vals,
int size);
195 void publish(
const std::vector<std::complex<double>>& val);
197 void publishComplex(
const double* vals,
int size);
198 void publish(std::complex<double> val);
204 void publish(std::string_view field,
double val);
210 void publish(
double val,
const std::string& units);
211 void publish(
double val,
const units::precise_unit& units);
215 std::enable_if_t<(std::is_constructible_v<std::string_view, X>),
void>
publish(
const X& val)
222 std::enable_if_t<(std::is_same_v<defV, remove_cv_ref<X>>),
void>
publish(
const X& val)
229 std::enable_if_t<(std::is_integral_v<X> && !std::is_same_v<remove_cv_ref<X>,
char>),
void>
232 publishInt(
static_cast<int64_t
>(val));
240 changeDetectionEnabled =
true;
244 changeDetectionEnabled =
false;
261 void publishInt(int64_t val);
262 void publishString(std::string_view val);
263 void publishDefV(
const defV& val);
naming a set of types that are interchangeable and recognizable inside the HELICS application API and...
Definition: application_api/Federate.hpp:875
Definition: helicsTypes.hpp:110
Definition: Publications.hpp:25
virtual const std::string & getDisplayName() const override
Definition: Publications.hpp:253
const std::string & getType() const
Definition: Publications.hpp:178
std::enable_if_t<(std::is_integral_v< X > &&!std::is_same_v< remove_cv_ref< X >, char >), void > publish(X val)
Definition: Publications.hpp:230
Publication(FedPtr &valueFed, std::string_view key, DataType type, std::string_view units=std::string_view())
Definition: Publications.hpp:137
Publication(ValueFederate *valueFed, std::string_view key, DataType type, std::string_view units=std::string_view())
Definition: Publications.hpp:123
void addInputTarget(std::string_view target)
Definition: Publications.hpp:184
const std::string & getUnits() const
Definition: Publications.hpp:180
Publication(InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, DataType type, std::string_view units=std::string_view())
Definition: Publications.hpp:151
void setMinimumChange(double deltaV) noexcept
Definition: Publications.hpp:237
std::enable_if_t<(std::is_constructible_v< std::string_view, X >), void > publish(const X &val)
Definition: Publications.hpp:215
std::enable_if_t<(std::is_same_v< defV, remove_cv_ref< X >>), void > publish(const X &val)
Definition: Publications.hpp:222
void addTarget(std::string_view target)
Definition: Publications.hpp:182
Publication(FedPtr valueFed, std::string_view key, std::string_view type=std::string_view(), std::string_view units=std::string_view())
Definition: Publications.hpp:74
Publication(InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, std::string_view type, std::string_view units=std::string_view())
Definition: Publications.hpp:105
Publication(InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, DataType type, std::string_view units=std::string_view())
Definition: Publications.hpp:168
void enableChangeDetection(bool enabled=true) noexcept
Definition: Publications.hpp:251
Definition: ValueFederateManager.hpp:64
Definition: application_api/ValueFederate.hpp:28
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
DataType
Definition: helicsTypes.hpp:273
const std::string & typeNameStringRef(DataType type)
Definition: helicsTypes.cpp:58
InterfaceVisibility
Definition: helicsTypes.hpp:40
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
std::variant< double, int64_t, std::string, std::complex< double >, std::vector< double >, std::vector< std::complex< double > >, NamedPoint > defV
Definition: HelicsPrimaryTypes.hpp:37
void publish(ValueFederate &fed, std::string_view pubName, Us... pargs)
Definition: application_api/ValueFederate.hpp:571