diff --git a/src/actions.cpp b/src/actions.cpp index 05783758..6d1632b7 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -161,27 +161,18 @@ namespace { // ***************************************************************************** // class member definitions namespace Action { - TaskFactory* TaskFactory::instance_ = nullptr; - TaskFactory& TaskFactory::instance() { - /// \todo move the static instance here. It is the "modern" way to implement a singleton - if (nullptr == instance_) { - instance_ = new TaskFactory; - } - return *instance_; - } // TaskFactory::instance + static TaskFactory instance_; + return instance_; + } void TaskFactory::cleanup() { - if (instance_ != nullptr) { - for (auto&& i : registry_) { - delete i.second; - } - delete instance_; - instance_ = nullptr; - } - } //TaskFactory::cleanup + for (auto&& i : registry_) { + delete i.second; + } + } void TaskFactory::registerTask(TaskType type, Task::UniquePtr task) { @@ -190,7 +181,7 @@ namespace Action { delete i->second; } registry_[type] = task.release(); - } // TaskFactory::registerTask + } TaskFactory::TaskFactory() { diff --git a/src/actions.hpp b/src/actions.hpp index 18095b3f..065f2044 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -140,12 +140,8 @@ namespace Action { //! Prevent construction other than through instance(). TaskFactory(); - //! Pointer to the one and only instance of this class. - static TaskFactory* instance_; - //! Type used to store Task prototype classes - using Registry = std::map; //! List of task types and corresponding prototypes. - Registry registry_; + std::map registry_; }; //! %Print the Exif (or other metadata) of a file to stdout