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