/** * @RDE_HEADER@ * Construction of MapObjects * $Id$ * $HeadURL$ * $Author$ */ #pragma once // Own #include "abstract_map_object.h" #include "situation_map_utils.h" #include #include #include #include //---------------------------------------------------------------------------- namespace SituationMap { // forward class Map; class ObjectFactory; /** * @brief The GenericObjectFactoryBase class define the interface for GenericObjectFactory. */ class SITUATIONMAP_EXPORT GenericObjectFactoryBase { public: /*! \name Construction, Destruction */ //@{ /** * @brief Contructor. * (In case of base class for GenericObjectFactory, map stays null) */ GenericObjectFactoryBase() : m_logger(getLogger("GenericObjectFactoryBase")) {} /** * @brief Destruktor */ virtual ~GenericObjectFactoryBase() = default; //@} GenericObjectFactoryBase(const GenericObjectFactoryBase &other) = delete; GenericObjectFactoryBase &operator=(GenericObjectFactoryBase &other) = delete; virtual RefPointer makeObj(const QString &debugInfo = QString()) = 0; virtual std::type_index getTypeIndexOfImplementation() = 0; private: LOGGER_T m_logger; ///< Interface of the Logging-Facility }; //---------------------------------------------------------------------------- // Generic Object Factory //---------------------------------------------------------------------------- /** * @brief The GenericObjectFactory class to create concrete MapObjects */ template class GenericObjectFactory final : public GenericObjectFactoryBase { public: /*! \name Construction, Destruction */ //@{ /** * @brief Contructor. */ GenericObjectFactory() = default; /** * @brief Destructor. */ ~GenericObjectFactory() = default; //@} protected: /** * @brief Create MapObject. * @param debugInfo for the MapObject. * @return RefPointer with object. */ RefPointer makeObj(const QString &debugInfo = QString()) override { AbstractMapObject *obj = new IMPL_TYPE(debugInfo); return RefPointer(obj); } /** * @brief Get type_index of associated implementation. * @return type_index this GenericObjectFactory::makeObj() will create. * @internal Will be used within ObjectFactory::interfaceToImplementation. */ std::type_index getTypeIndexOfImplementation() override { return std::type_index(typeid(IMPL_TYPE)); } }; } // namespace SituationMap