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:
@@ -38,22 +38,56 @@
|
||||
#include "models.h"
|
||||
|
||||
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
|
||||
|
||||
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
Models::Models()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Models::~Models()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Models::Clear()
|
||||
{
|
||||
for(auto & map_item : models_map)
|
||||
{
|
||||
if( map_item.second->should_be_auto_removed() )
|
||||
{
|
||||
delete map_item.second;
|
||||
map_item.second = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
models_map.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, morm::Model & model)
|
||||
{
|
||||
models_map[name] = &model;
|
||||
morm::ModelWrapper * models_base = new morm::ModelWrapperModel(&model);
|
||||
models_map[name] = models_base;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, morm::Model * model)
|
||||
{
|
||||
models_map[name] = model;
|
||||
morm::ModelWrapper * models_base = new morm::ModelWrapperModel(model);
|
||||
models_map[name] = models_base;
|
||||
}
|
||||
|
||||
|
||||
morm::Model * Models::Find(const std::wstring & name)
|
||||
morm::ModelWrapper * Models::Find(const std::wstring & name)
|
||||
{
|
||||
auto iterator = models_map.find(name);
|
||||
|
||||
@@ -66,14 +100,9 @@ morm::Model * Models::Find(const std::wstring & name)
|
||||
}
|
||||
|
||||
|
||||
void Models::Clear()
|
||||
{
|
||||
models_map.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user