changed how models from morm library are used
now we are using morm::ModelWrapper... classes as wrappers on models and list/vector of models and Models class is using these wrappers this allows us to iterate through list/vectors in [for...] statements
This commit is contained in:
46
src/models.h
46
src/models.h
@@ -38,35 +38,69 @@
|
||||
#ifndef headerfile_ezc_models
|
||||
#define headerfile_ezc_models
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
|
||||
// put some macros
|
||||
#include "model.h"
|
||||
#include "modelwrapper.h"
|
||||
#include "funinfo.h"
|
||||
|
||||
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
class Models
|
||||
{
|
||||
public:
|
||||
|
||||
Models();
|
||||
~Models();
|
||||
|
||||
void Add(const std::wstring & name, morm::Model & model);
|
||||
void Add(const std::wstring & name, morm::Model * model);
|
||||
|
||||
morm::Model * Find(const std::wstring & name);
|
||||
template<typename VectorType>
|
||||
void Add(const std::wstring & name, std::vector<VectorType> & container)
|
||||
{
|
||||
morm::ModelWrapper * models_base = new morm::ModelWrapperVector<VectorType>(&container);
|
||||
models_map[name] = models_base;
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
void Add(const std::wstring & name, std::vector<VectorType> * container)
|
||||
{
|
||||
morm::ModelWrapper * models_base = new morm::ModelWrapperVector<VectorType>(container);
|
||||
models_map[name] = models_base;
|
||||
}
|
||||
|
||||
template<typename ListType>
|
||||
void Add(const std::wstring & name, std::list<ListType> & container)
|
||||
{
|
||||
morm::ModelWrapper * models_base = new morm::ModelWrapperList<ListType>(&container);
|
||||
models_map[name] = models_base;
|
||||
}
|
||||
|
||||
template<typename ListType>
|
||||
void Add(const std::wstring & name, std::list<ListType> * container)
|
||||
{
|
||||
morm::ModelWrapper * models_base = new morm::ModelWrapperList<ListType>(container);
|
||||
models_map[name] = models_base;
|
||||
}
|
||||
|
||||
|
||||
morm::ModelWrapper * Find(const std::wstring & name);
|
||||
void Clear();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
std::map<std::wstring, morm::ModelWrapper*> models_map;
|
||||
|
||||
std::map<std::wstring, morm::Model*> models_map;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user