ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
Module.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include "EntityOwner.h"
6
7#include <ChimeraTK/ReadAnyGroup.h>
8#include <ChimeraTK/TransferElement.h>
9
10namespace ChimeraTK {
11
12 /********************************************************************************************************************/
13
14 class ApplicationModule;
15 class ConfigReader;
16
17 /********************************************************************************************************************/
18
21 class Module : public EntityOwner {
22 public:
25 Module(EntityOwner* owner, const std::string& name, const std::string& description,
26 const std::unordered_set<std::string>& tags = {});
27
35 Module() = default;
36
38 ~Module() override;
39
41 Module(Module&& other) noexcept { operator=(std::move(other)); }
42
44 Module& operator=(Module&& other) noexcept;
45
50 virtual void postConstruct() {}
51
55 virtual void prepare() {}
56
58 virtual void run();
59
62 virtual void terminate() {}
63
66 ChimeraTK::ReadAnyGroup readAnyGroup();
67
72 void readAll(bool includeReturnChannels = false);
73
76 void readAllNonBlocking(bool includeReturnChannels = false);
77
80 void readAllLatest(bool includeReturnChannels = false);
81
84 void writeAll(bool includeReturnChannels = false);
85
88 void writeAllDestructively(bool includeReturnChannels = false);
89
90 std::string getQualifiedName() const override;
91
92 virtual std::string getVirtualQualifiedName() const = 0;
93
94 std::string getFullDescription() const override;
95
100 void setOwner(EntityOwner* newOwner) { _owner = newOwner; }
101
102 EntityOwner* getOwner() const { return _owner; }
103
104 VersionNumber getCurrentVersionNumber() const override { return _owner->getCurrentVersionNumber(); }
105
107
108 DataValidity getDataValidity() const override { return _owner->getDataValidity(); }
109
111
113
114 std::list<EntityOwner*> getInputModulesRecursively(std::list<EntityOwner*> startList) override;
115
116 size_t getCircularNetworkHash() const override { return _owner->getCircularNetworkHash(); }
117
127
134 static ConfigReader& appConfig();
135
141 void disable();
142
143 protected:
146 };
147
148 /********************************************************************************************************************/
149
150} /* namespace ChimeraTK */
VersionNumber version
Generic module to read an XML config file and provide the defined values as constant variables.
Base class for owners of other EntityOwners (e.g.
Definition EntityOwner.h:38
virtual size_t getCircularNetworkHash() const =0
Get the ID of the circular dependency network (0 if none).
virtual void decrementDataFaultCounter()=0
Decrement the fault counter and set the data validity flag to ok if the counter has reached 0.
virtual void incrementDataFaultCounter()=0
Set the data validity flag to fault and increment the fault counter.
virtual void setCurrentVersionNumber(VersionNumber versionNumber)=0
Set the current version number.
virtual VersionNumber getCurrentVersionNumber() const =0
Return the current version number which has been received with the last push-type read operation.
virtual DataValidity getDataValidity() const =0
Return the data validity flag.
Base class for ApplicationModule and DeviceModule, to have a common interface for these module types.
Definition Module.h:21
void readAllLatest(bool includeReturnChannels=false)
Just call readLatest() on all readable variables in the group.
Definition Module.cc:138
std::string getQualifiedName() const override
Get the fully qualified name of the module instance, i.e.
Definition Module.cc:219
virtual void postConstruct()
Hook function called on all Modules of an Application after the Application constructor is complete b...
Definition Module.h:50
VersionNumber getCurrentVersionNumber() const override
Return the current version number which has been received with the last push-type read operation.
Definition Module.h:104
void setCurrentVersionNumber(VersionNumber version) override
Set the current version number.
Definition Module.h:106
void readAll(bool includeReturnChannels=false)
Read all readable variables in the group.
Definition Module.cc:72
void readAllNonBlocking(bool includeReturnChannels=false)
Just call readNonBlocking() on all readable variables in the group.
Definition Module.cc:106
void decrementDataFaultCounter() override
Decrement the fault counter and set the data validity flag to ok if the counter has reached 0.
Definition Module.h:112
EntityOwner * _owner
Owner of this instance.
Definition Module.h:145
void disable()
Disable the module such that it is not part of the Application.
Definition Module.cc:257
size_t getCircularNetworkHash() const override
Get the ID of the circular dependency network (0 if none).
Definition Module.h:116
void writeAllDestructively(bool includeReturnChannels=false)
Just call writeDestructively() on all writable variables in the group.
Definition Module.cc:177
DataValidity getDataValidity() const override
Return the data validity flag.
Definition Module.h:108
Module * findApplicationModule()
Find ApplicationModule owner.
Definition Module.cc:197
Module(Module &&other) noexcept
Move constructor.
Definition Module.h:41
std::list< EntityOwner * > getInputModulesRecursively(std::list< EntityOwner * > startList) override
Use pointer to the module as unique identifier.
Definition Module.cc:241
~Module() override
Destructor.
Definition Module.cc:23
Module & operator=(Module &&other) noexcept
Move assignment operator.
Definition Module.cc:31
static ConfigReader & appConfig()
Obtain the ConfigReader instance of the application.
Definition Module.cc:251
ChimeraTK::ReadAnyGroup readAnyGroup()
Create a ChimeraTK::ReadAnyGroup for all readable variables in this Module.
Definition Module.cc:54
void setOwner(EntityOwner *newOwner)
Set a new owner.
Definition Module.h:100
EntityOwner * getOwner() const
Definition Module.h:102
void writeAll(bool includeReturnChannels=false)
Just call write() on all writable variables in the group.
Definition Module.cc:157
std::string getFullDescription() const override
Obtain the full description including the full description of the owner.
Definition Module.cc:225
virtual void run()
Execute the module.
Definition Module.cc:48
Module()=default
Default constructor: Allows late initialisation of modules (e.g.
virtual void terminate()
Terminate the module.
Definition Module.h:62
void incrementDataFaultCounter() override
Set the data validity flag to fault and increment the fault counter.
Definition Module.h:110
virtual std::string getVirtualQualifiedName() const =0
virtual void prepare()
Prepare the execution of the module.
Definition Module.h:55
InvalidityTracer application module.