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:
2021-06-16 14:16:49 +02:00
parent e6fd9aad37
commit 9022d4a5fc
4 changed files with 339 additions and 184 deletions

View File

@@ -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