3 #include "ShapesModule.h"
10 template <
typename TModel,
typename TCreateParams,
typename TFactory,
typename TRepository>
14 typedef TModel ModelType;
15 typedef TCreateParams CreateParamsType;
16 typedef TFactory ModelFactoryType;
17 typedef TRepository ModelRepositoryType;
21 virtual typename ModelType::IdType Create(
const CreateParamsType& polygonCreateParams) = 0;
23 virtual void Destroy(
typename ModelType::IdType modelId) = 0;
25 virtual bool Exists(
typename ModelType::IdType modelId)
const = 0;
27 virtual ModelType& Get(
typename ModelType::IdType modelId)
const = 0;
31 template <
typename TBase>
35 typedef typename TBase::ModelType ModelType;
36 typedef typename TBase::CreateParamsType CreateParamsType;
37 typedef typename TBase::ModelFactoryType ModelFactoryType;
38 typedef typename TBase::ModelRepositoryType ModelRepositoryType;
44 ModelRepositoryType& modelRepository)
45 : m_modelFactory(modelFactory)
46 , m_modelRepository(modelRepository)
53 virtual typename ModelType::IdType Create(
const CreateParamsType& createParams)
55 ModelType* pShapeModel = m_modelFactory.Create(createParams);
57 m_modelRepository.Add(pShapeModel->GetId(), pShapeModel);
59 return pShapeModel->GetId();
62 virtual void Destroy(
typename ModelType::IdType shapeModelId)
64 Eegeo_ASSERT(Exists(shapeModelId),
"Shape id %d does not exist", shapeModelId);
66 ModelType* pShapeModel = m_modelRepository.Get(shapeModelId);
68 m_modelRepository.Remove(shapeModelId);
70 Eegeo_DELETE pShapeModel;
73 virtual bool Exists(
typename ModelType::IdType shapeModelId)
const
75 return m_modelRepository.Contains(shapeModelId);
78 virtual ModelType& Get(
typename ModelType::IdType shapeModelId)
const
80 Eegeo_ASSERT(Exists(shapeModelId),
"Shape model id %d does not exist", shapeModelId);
81 return *m_modelRepository.Get(shapeModelId);
87 ModelFactoryType& m_modelFactory;
88 ModelRepositoryType& m_modelRepository;