diff --git a/include/ApplicationModule.h b/include/ApplicationModule.h index 19a914a3b030830d277c3754db508b23a1714553..5e0cf48fb09138fb6f1b0984aa958ff2ae08c60f 100644 --- a/include/ApplicationModule.h +++ b/include/ApplicationModule.h @@ -39,7 +39,12 @@ namespace ChimeraTK { * See this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054 */ ApplicationModule() : Module(nullptr, "invalid", "invalid ApplicationModule") {} + /** Move operation with the move constructor */ + ApplicationModule(ApplicationModule &&other) : Module(std::move(other)) {} + /** Inherit assignment */ + using Module::operator=; + /** Destructor */ virtual ~ApplicationModule(); @@ -53,16 +58,6 @@ namespace ChimeraTK { VariableNetworkNode operator()(const std::string& variableName) const override; Module& operator[](const std::string& moduleName) const override; - - /** Move operation with the assignment operator */ - ApplicationModule& operator=(ApplicationModule &&rhs) { - moduleThread = std::move(rhs.moduleThread); - _name = std::move(rhs._name); - _owner = std::move(rhs._owner); - accessorList = std::move(rhs.accessorList); - moduleList = std::move(rhs.moduleList); - return *this; - } ModuleType getModuleType() const override { return ModuleType::ApplicationModule; } diff --git a/include/ControlSystemModule.h b/include/ControlSystemModule.h index 417b767797c715c43d3c699484458e14befc525a..6ecc4911e4178190fdb7cda518fd876c0b011504 100644 --- a/include/ControlSystemModule.h +++ b/include/ControlSystemModule.h @@ -25,6 +25,17 @@ namespace ChimeraTK { * (separated by a slash). */ ControlSystemModule(const std::string& variableNamePrefix=""); + /** Move operation with the move constructor */ + ControlSystemModule(ControlSystemModule &&other) + : Module(std::move(other)), + variableNamePrefix(std::move(other.variableNamePrefix)), + subModules(std::move(other.subModules)), + variables(std::move(other.variables)) + {} + + /** Inherit assignment */ + using Module::operator=; + /** The function call operator returns a VariableNetworkNode which can be used in the Application::initialise() * function to connect the control system variable with another variable. */ VariableNetworkNode operator()(const std::string& variableName, const std::type_info &valueType, diff --git a/include/DeviceModule.h b/include/DeviceModule.h index e40eaa718f100d906cb0d52c2e5b5a1e0f3cc76c..8fd7d907a8176c6ad5822a4bef8a060f6905251b 100644 --- a/include/DeviceModule.h +++ b/include/DeviceModule.h @@ -28,6 +28,17 @@ namespace ChimeraTK { /** Default constructor: create dysfunctional device module */ DeviceModule() {} + /** Move operation with the move constructor */ + DeviceModule(DeviceModule &&other) + : Module(std::move(other)), + deviceAliasOrURI(std::move(other.deviceAliasOrURI)), + registerNamePrefix(std::move(other.registerNamePrefix)), + subModules(std::move(other.subModules)) + {} + + /** Inherit assignment */ + using Module::operator=; + /** The subscript operator returns a VariableNetworkNode which can be used in the Application::initialise() * function to connect the register with another variable. */ VariableNetworkNode operator()(const std::string& registerName, UpdateMode mode, diff --git a/include/EntityOwner.h b/include/EntityOwner.h index adf3e4d448b5a72bd6b9f7f44b72585b1739c63a..148dfbb1f388f5bd579b6beffdc41e845e573dce 100644 --- a/include/EntityOwner.h +++ b/include/EntityOwner.h @@ -34,6 +34,33 @@ namespace ChimeraTK { /** Virtual destructor to make the type polymorphic */ virtual ~EntityOwner(); + + /** Move constructor */ + EntityOwner(EntityOwner &&other) + : _name(std::move(other._name)), + _description(std::move(other._description)), + _owner(other._owner), + accessorList(std::move(other.accessorList)), + moduleList(std::move(other.moduleList)), + _eliminateHierarchy(other._eliminateHierarchy), + _tags(std::move(other._tags)) + {} + + /** Move operation with the assignment operator */ + EntityOwner& operator=(EntityOwner &&other) { + _name = std::move(other._name); + _description = std::move(other._description); + _owner = std::move(other._owner); + accessorList = std::move(other.accessorList); + moduleList = std::move(other.moduleList); + _eliminateHierarchy = other._eliminateHierarchy; + _tags = std::move(other._tags); + return *this; + } + + /** Delete other assignment operators */ + EntityOwner& operator=(EntityOwner &other) = delete; + EntityOwner& operator=(const EntityOwner &other) = delete; /** Get the name of the module instance */ const std::string& getName() const { return _name; } diff --git a/include/Module.h b/include/Module.h index ecb02403bca79fdbbd9252117a98cc5ec071515b..2286fb9b700f140e4f287c541369140a6fe966b9 100644 --- a/include/Module.h +++ b/include/Module.h @@ -35,6 +35,12 @@ namespace ChimeraTK { /** Destructor */ virtual ~Module(); + + /** Move operation with the move constructor */ + Module(Module &&rhs) : EntityOwner(std::move(rhs)) {} + + /** Inherit assignment */ + using EntityOwner::operator=; /** Prepare the execution of the module. This function is called before any module is started (including internal * modules like FanOuts) and before the initial values of the variables are pushed into the queues. */ diff --git a/include/ModuleGroup.h b/include/ModuleGroup.h index c37582bf884c5227c65bf0e3d3b1b495b3143ec7..098618e70a896fd541713f6c1d14a06198212228 100644 --- a/include/ModuleGroup.h +++ b/include/ModuleGroup.h @@ -37,36 +37,14 @@ namespace ChimeraTK { * See this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054 */ ModuleGroup() : Module(nullptr, "invalid", "invalid VariableGroup") {} - /** Destructor */ - virtual ~ModuleGroup() {}; + /** Move operation with the move constructor */ + ModuleGroup(ModuleGroup &&other) : Module(std::move(other)) {} - /** Move operation with the move constructor - @todo should be in the base class!? */ - ModuleGroup(ModuleGroup &&rhs) { - _name = std::move(rhs._name); - _owner = std::move(rhs._owner); - _description = std::move(rhs._description); - accessorList = std::move(rhs.accessorList); - moduleList = std::move(rhs.moduleList); - _eliminateHierarchy = rhs._eliminateHierarchy; - _tags = std::move(rhs._tags); - } + /** Inherit assignment */ + using Module::operator=; - /** Move operation with the assignment operator - @todo should be in the base class!? */ - ModuleGroup& operator=(ModuleGroup &&rhs) { - _name = std::move(rhs._name); - _owner = std::move(rhs._owner); - _description = std::move(rhs._description); - accessorList = std::move(rhs.accessorList); - moduleList = std::move(rhs.moduleList); - _eliminateHierarchy = rhs._eliminateHierarchy; - _tags = std::move(rhs._tags); - return *this; - } - - ModuleGroup& operator=(ModuleGroup &rhs) = delete; - ModuleGroup& operator=(const ModuleGroup &rhs) = delete; + /** Destructor */ + virtual ~ModuleGroup() {}; ModuleType getModuleType() const override { return ModuleType::ModuleGroup; } diff --git a/include/VariableGroup.h b/include/VariableGroup.h index 381df7ddc744820daee60dc9d8f05c1e4f2feb5e..93d7f44588129fede20423ec597c84ce34c9359b 100644 --- a/include/VariableGroup.h +++ b/include/VariableGroup.h @@ -41,18 +41,12 @@ namespace ChimeraTK { /** Destructor */ virtual ~VariableGroup() {}; + + /** Move operation with the move constructor */ + VariableGroup(VariableGroup &&other) : Module(std::move(other)) {} - /** Move operation with the assignment operator - @todo should be in the base class!? */ - VariableGroup& operator=(VariableGroup &&rhs) { - _name = std::move(rhs._name); - _owner = std::move(rhs._owner); - accessorList = std::move(rhs.accessorList); - moduleList = std::move(rhs.moduleList); - return *this; - } - - VariableGroup& operator=(VariableGroup &rhs) = delete; + /** Inherit assignment */ + using Module::operator=; ModuleType getModuleType() const override { return ModuleType::VariableGroup; } diff --git a/src/ControlSystemModule.cc b/src/ControlSystemModule.cc index aa15d31fa08d60bfd36f0feb801a4315e141af39..804c2a27ef90e514fe5d6a038b70b45110e4fd5a 100644 --- a/src/ControlSystemModule.cc +++ b/src/ControlSystemModule.cc @@ -29,7 +29,7 @@ namespace ChimeraTK { Module& ControlSystemModule::operator[](const std::string& moduleName) const { if(subModules.count(moduleName) == 0) { - subModules[moduleName] = {variableNamePrefix/moduleName}; + subModules.emplace(std::pair<std::string, ControlSystemModule>(moduleName, ControlSystemModule(variableNamePrefix/moduleName))); } return subModules[moduleName]; } diff --git a/src/DeviceModule.cc b/src/DeviceModule.cc index 5bc05cded0384157b0f5b63103455924de1977f1..a0e77881a2dff536b4a394436e4999e39f6e1a4e 100644 --- a/src/DeviceModule.cc +++ b/src/DeviceModule.cc @@ -29,7 +29,7 @@ namespace ChimeraTK { Module& DeviceModule::operator[](const std::string& moduleName) const { if(subModules.count(moduleName) == 0) { - subModules[moduleName] = {deviceAliasOrURI, registerNamePrefix/moduleName}; + subModules.emplace(std::pair<std::string, DeviceModule>(moduleName, DeviceModule(deviceAliasOrURI, registerNamePrefix/moduleName))); } return subModules[moduleName]; }