12#include <ChimeraTK/NDRegisterAccessorAbstractor.h>
14#include <boost/shared_ptr.hpp>
18#include <unordered_map>
19#include <unordered_set>
27 struct VariableNetworkNode_data;
48 const std::string& description,
const std::type_info* valueType,
49 const std::unordered_set<std::string>& tags = {});
52 VariableNetworkNode(
const std::string& name,
const std::string& devAlias,
const std::string& regName,
54 size_t nElements = 0);
58 const std::type_info& valTyp =
typeid(
AnyType),
size_t nElements = 0);
80 void setMetaData(
const std::optional<std::string>& name,
const std::optional<std::string>& unit = {},
81 const std::optional<std::string>& description = {},
82 const std::optional<std::unordered_set<std::string>>& tags = {});
104 void dump(std::ostream& stream = std::cout)
const;
110 void addTag(
const std::string& tag)
const;
129 [[nodiscard]]
const std::type_info&
getValueType()
const;
130 [[nodiscard]] std::string
getName()
const;
132 [[nodiscard]]
const std::string&
getUnit()
const;
138 [[nodiscard]]
const std::unordered_set<std::string>&
getTags()
const;
150 template<
typename UserType>
151 ChimeraTK::NDRegisterAccessorAbstractor<UserType>&
getAppAccessor()
const;
153 template<
typename UserType>
171 template<
typename UserType>
174 template<
typename UserType>
181 boost::shared_ptr<VariableNetworkNode_data>
pdata;
217 std::string
unit{ChimeraTK::TransferElement::unitNotSet};
223 ChimeraTK::TransferElementAbstractor*
appNode{
nullptr};
249 std::unordered_set<std::string>
tags;
272 template<
typename UserType>
276 auto accessor =
static_cast<ChimeraTK::NDRegisterAccessorAbstractor<UserType>*
>(
pdata->appNode);
277 assert(accessor !=
nullptr);
283 template<
typename UserType>
288 decorated->disableDataValidityPropagation();
291 decorated->disableVersionNumberPropagation();
294 getAppAccessor<UserType>().replace(decorated);
295 auto flagProvider = boost::dynamic_pointer_cast<MetaDataPropagationFlagProvider>(decorated);
296 assert(flagProvider);
301 template<
typename UserType>
304 boost::fusion::at_key<UserType>(
pdata->constantValue) = value;
309 template<
typename UserType>
312 return boost::fusion::at_key<UserType>(
pdata->constantValue);
Pseudo type to identify nodes which can have arbitrary types.
Base class for owners of other EntityOwners (e.g.
Proxy class which does not keep the ownership of the model.
Class describing a node of a variable network.
void dump(std::ostream &stream=std::cout) const
Print node information to specified stream.
void setValueType(const std::type_info &newType) const
Set the value type for this node.
boost::shared_ptr< VariableNetworkNode_data > pdata
ChimeraTK::TransferElementAbstractor & getAppAccessorNoType() const
NodeType getType() const
Getter for the properties.
void clearOwner()
Clear the owner network of this node.
void setAppAccessorImplementation(boost::shared_ptr< ChimeraTK::NDRegisterAccessor< UserType > > impl) const
const std::string & getRegisterName() const
void setConstantValue(UserType value)
const std::unordered_set< std::string > & getTags() const
Model::ProcessVariableProxy getModel() const
std::string getQualifiedName() const
std::string getName() const
void setDirection(VariableDirection newDirection) const
Set the direction for this node.
const std::string & getPublicName() const
bool isCircularInput() const
Returns true if a circular dependency has been detected and the node is a consumer.
void setAppAccessorPointer(ChimeraTK::TransferElementAbstractor *accessor) const
Change pointer to the accessor.
const std::type_info & getValueType() const
bool operator<(const VariableNetworkNode &other) const
void setOwningModule(EntityOwner *newOwner) const
const std::string & getDescription() const
void setModel(const Model::ProcessVariableProxy &model) const
size_t getNumberOfElements() const
VariableNetworkNode & operator=(const VariableNetworkNode &rightHandSide)
Copy by assignment operator: Just copy the pointer to the data storage object.
void setNumberOfElements(size_t nElements) const
bool operator==(const VariableNetworkNode &other) const
Compare two nodes.
UpdateMode getMode() const
bool hasImplementation() const
Function checking if the node requires a fixed implementation.
VariableNetworkNode()
Default constructor for an invalid node.
size_t getCircularNetworkHash() const
Get the unique ID of the circular network.
void setPublicName(const std::string &name) const
const void * getUniqueId() const
Return the unique ID of this node (will change every time the application is started).
VariableDirection getDirection() const
void setAppAccessorConstImplementation(const VariableNetworkNode &feeder) const
ChimeraTK::NDRegisterAccessorAbstractor< UserType > & getAppAccessor() const
bool operator!=(const VariableNetworkNode &other) const
std::list< EntityOwner * > scanForCircularDepencency() const
Scan the networks and set the isCircularInput() flags if circular dependencies are detected.
void accept(Visitor< VariableNetworkNode > &visitor) const
void addTag(const std::string &tag) const
Add a tag.
VariableNetworkNode getNodeToTrigger() const
VariableNetworkNode(const VariableNetworkNode &other)
Copy-constructor: Just copy the pointer to the data storage object.
EntityOwner * getOwningModule() const
const std::string & getDeviceAlias() const
const std::string & getUnit() const
UserType getConstantValue() const
void setMetaData(const std::optional< std::string > &name, const std::optional< std::string > &unit={}, const std::optional< std::string > &description={}, const std::optional< std::unordered_set< std::string > > &tags={})
Change meta data (name, unit, description and optionally tags).
InvalidityTracer application module.
constexpr auto explicitDataValidityTag
Special tag to designate that a node should not automatically take over DataValidity of its owning mo...
constexpr auto independentVersionTag
Special tag to designate that a push-input should not propagate VersionNumber updates to its owning m...
UpdateMode
Enum to define the update mode of variables.
NodeType
Enum to define types of VariableNetworkNode.
Struct to define the direction of variables.
We use a pimpl pattern so copied instances of VariableNetworkNode refer to the same instance of the d...
std::string qualifiedName
std::string deviceAlias
Device information if type == Device.
Model::NonOwningProxy< Model::ProcessVariableProxy > model
Model representation of this variable.
UpdateMode mode
Update mode: poll or push.
size_t nElements
Number of elements in the variable.
VariableNetworkNode nodeToTrigger
Pointer to network which should be triggered by this node.
std::string name
Accessor name if type == Application.
std::string unit
Engineering unit.
VariableNetworkNode_data()=default
const std::type_info * valueType
Value type of this node.
ChimeraTK::TransferElementAbstractor * appNode
Pointer to implementation if type == Application.
EntityOwner * owningModule
Pointer to the module owning this node.
size_t circularNetworkHash
Hash which identifies a circular network.
std::string publicName
Public name if type == ControlSystem.
std::unordered_set< std::string > tags
Set of tags if type == Application || type == Device.
userTypeMap constantValue
Value in case of a constant.
NodeType type
Type of the node (Application, Device, ControlSystem, Trigger)
std::string description
Description.
std::map< VariableNetworkNode, VariableNetworkNode > nodeWithTrigger
Map to store triggered versions of this node.
VariableNetworkNode externalTrigger
Pointer to the network providing the external trigger.
VariableDirection direction
Node direction: feeding or consuming.