ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
ModuleGroup.cc
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#include "ModuleGroup.h"
4
5#include "ApplicationModule.h"
6#include "DeviceModule.h"
7
8namespace ChimeraTK {
9
10 /********************************************************************************************************************/
11
12 ModuleGroup::ModuleGroup(ModuleGroup* owner, const std::string& name, const std::string& description,
13 const std::unordered_set<std::string>& tags)
14 : Module(owner, name, description, tags) {
15 if(!owner) {
16 throw ChimeraTK::logic_error("ModuleGroup owner cannot be nullptr");
17 }
18
19 if(owner->getModel().isValid()) {
20 _model = owner->getModel().add(*this);
21 }
22 }
23
24 /********************************************************************************************************************/
26 ModuleGroup::ModuleGroup(ModuleGroup* owner, const std::string& name) : Module(owner, name, "") {}
27
28 /********************************************************************************************************************/
29
31 _model = std::move(other._model);
32 other._model = {};
33 if(_model.isValid()) {
34 _model.informMove(*this);
35 }
36 Module::operator=(std::move(other));
37 return *this;
38 }
39
40 /********************************************************************************************************************/
41
43 return _model.getFullyQualifiedPath();
44 }
45
46 /********************************************************************************************************************/
47
50
51 // unregister from model
52 if(_model.isValid()) {
53 auto* mg = dynamic_cast<ModuleGroup*>(module);
54 if(mg) {
55 _model.remove(*mg);
56 return;
57 }
58 auto* am = dynamic_cast<ApplicationModule*>(module);
59 if(am) {
60 _model.remove(*am);
61 return;
62 }
63 auto* dm = dynamic_cast<DeviceModule*>(module);
64 if(dm) {
65 _model.remove(*dm);
66 return;
67 }
68
69 // ModuleGroups own either other ModuleGroups or ApplicationModules, but during destruction unregisterModule
70 // is called from the base class destructor where the dynamic_cast already fails.
71 return;
72 }
73 }
74
75 /********************************************************************************************************************/
76
77} /* namespace ChimeraTK */
virtual void unregisterModule(Module *module)
Unregister another module as a sub-module.
ModuleGroupProxy add(ModuleGroup &module)
Definition Model.cc:164
void remove(ApplicationModule &module)
Definition Model.cc:188
bool isValid() const
Check if the model is valid.
Definition Model.cc:31
std::string getFullyQualifiedPath() const
Return the fully qualified path.
Definition Model.cc:25
void unregisterModule(Module *module) override
Unregister another module as a sub-module.
ModuleGroup & operator=(ModuleGroup &&other) noexcept
Move assignment.
ChimeraTK::Model::ModuleGroupProxy getModel()
Return the application model proxy representing this module.
Definition ModuleGroup.h:40
ModuleGroup()=default
Default constructor to allow late initialisation of module groups.
std::string getVirtualQualifiedName() const override
Base class for ApplicationModule and DeviceModule, to have a common interface for these module types.
Definition Module.h:21
Module & operator=(Module &&other) noexcept
Move assignment operator.
Definition Module.cc:31
InvalidityTracer application module.