Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Construction of MapObjects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
// Own
|
||||
#include "abstract_map_object.h"
|
||||
#include "situation_map_utils.h"
|
||||
#include <Common/ref_pointer.h>
|
||||
#include <situation_map_export.h>
|
||||
#include <Common/situation_map_logging.h>
|
||||
|
||||
|
||||
#include <typeindex>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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<AbstractMapObject> 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 <typename IMPL_TYPE>
|
||||
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<AbstractMapObject> makeObj(const QString &debugInfo = QString()) override
|
||||
{
|
||||
AbstractMapObject *obj = new IMPL_TYPE(debugInfo);
|
||||
return RefPointer<AbstractMapObject>(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
|
||||
|
||||
Reference in new issue
Block a user