removed Wrapper class
This commit is contained in:
parent
4a8fa0c34c
commit
c14b0eb626
|
@ -2,62 +2,53 @@
|
||||||
|
|
||||||
baseexpression.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
baseexpression.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||||
baseexpression.o: cursorhelper.h queryresult.h finderhelper.h
|
baseexpression.o: cursorhelper.h queryresult.h finderhelper.h
|
||||||
baseexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h
|
baseexpression.o: fieldvaluehelper.h ft.h model.h modelconnector.h clearer.h
|
||||||
baseexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h model.h
|
baseexpression.o: dbconnector.h flatconnector.h dbexpression.h
|
||||||
baseexpression.o: modelconnector.h clearer.h dbconnector.h flatconnector.h
|
baseexpression.o: flatexpression.h modelcontainerwrapper.h
|
||||||
baseexpression.o: dbexpression.h flatexpression.h
|
baseexpression.o: baseobjectwrapper.h spacewrapper.h
|
||||||
clearer.o: clearer.h model.h modelconnector.h dbconnector.h queryresult.h
|
clearer.o: clearer.h model.h modelconnector.h dbconnector.h queryresult.h
|
||||||
clearer.o: ft.h flatconnector.h dbexpression.h baseexpression.h morm_types.h
|
clearer.o: ft.h flatconnector.h dbexpression.h baseexpression.h morm_types.h
|
||||||
clearer.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
clearer.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
||||||
clearer.o: fieldvaluehelper.h wrapper.h spacewrapper.h baseobjectwrapper.h
|
clearer.o: fieldvaluehelper.h flatexpression.h modelcontainerwrapper.h
|
||||||
clearer.o: modelcontainerwrapper.h flatexpression.h
|
clearer.o: baseobjectwrapper.h spacewrapper.h
|
||||||
dbconnector.o: dbconnector.h queryresult.h ft.h dbexpression.h
|
dbconnector.o: dbconnector.h queryresult.h ft.h dbexpression.h
|
||||||
dbconnector.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
dbconnector.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||||
dbconnector.o: cursorhelper.h finderhelper.h fieldvaluehelper.h wrapper.h
|
dbconnector.o: cursorhelper.h finderhelper.h fieldvaluehelper.h model.h
|
||||||
dbconnector.o: spacewrapper.h baseobjectwrapper.h modelcontainerwrapper.h
|
dbconnector.o: modelconnector.h clearer.h flatconnector.h flatexpression.h
|
||||||
dbconnector.o: model.h modelconnector.h clearer.h flatconnector.h
|
dbconnector.o: modelcontainerwrapper.h baseobjectwrapper.h spacewrapper.h
|
||||||
dbconnector.o: flatexpression.h
|
|
||||||
dbexpression.o: dbexpression.h baseexpression.h morm_types.h modelenv.h
|
dbexpression.o: dbexpression.h baseexpression.h morm_types.h modelenv.h
|
||||||
dbexpression.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h
|
dbexpression.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h
|
||||||
dbexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h
|
dbexpression.o: fieldvaluehelper.h ft.h
|
||||||
dbexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h
|
|
||||||
flatconnector.o: flatconnector.h flatexpression.h baseexpression.h
|
flatconnector.o: flatconnector.h flatexpression.h baseexpression.h
|
||||||
flatconnector.o: morm_types.h modelenv.h modeldata.h cursorhelper.h
|
flatconnector.o: morm_types.h modelenv.h modeldata.h cursorhelper.h
|
||||||
flatconnector.o: queryresult.h finderhelper.h fieldvaluehelper.h wrapper.h
|
flatconnector.o: queryresult.h finderhelper.h fieldvaluehelper.h ft.h model.h
|
||||||
flatconnector.o: spacewrapper.h baseobjectwrapper.h modelcontainerwrapper.h
|
flatconnector.o: modelconnector.h clearer.h dbconnector.h dbexpression.h
|
||||||
flatconnector.o: ft.h model.h modelconnector.h clearer.h dbconnector.h
|
flatconnector.o: modelcontainerwrapper.h baseobjectwrapper.h spacewrapper.h
|
||||||
flatconnector.o: dbexpression.h
|
|
||||||
flatexpression.o: flatexpression.h baseexpression.h morm_types.h modelenv.h
|
flatexpression.o: flatexpression.h baseexpression.h morm_types.h modelenv.h
|
||||||
flatexpression.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h
|
flatexpression.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h
|
||||||
flatexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h
|
flatexpression.o: fieldvaluehelper.h ft.h
|
||||||
flatexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h
|
|
||||||
jsonconnector.o: jsonconnector.h flatconnector.h jsonexpression.h
|
jsonconnector.o: jsonconnector.h flatconnector.h jsonexpression.h
|
||||||
jsonconnector.o: flatexpression.h baseexpression.h morm_types.h modelenv.h
|
jsonconnector.o: flatexpression.h baseexpression.h morm_types.h modelenv.h
|
||||||
jsonconnector.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h
|
jsonconnector.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h
|
||||||
jsonconnector.o: fieldvaluehelper.h wrapper.h spacewrapper.h
|
jsonconnector.o: fieldvaluehelper.h ft.h
|
||||||
jsonconnector.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h
|
|
||||||
jsonexpression.o: jsonexpression.h flatexpression.h baseexpression.h
|
jsonexpression.o: jsonexpression.h flatexpression.h baseexpression.h
|
||||||
jsonexpression.o: morm_types.h modelenv.h modeldata.h cursorhelper.h
|
jsonexpression.o: morm_types.h modelenv.h modeldata.h cursorhelper.h
|
||||||
jsonexpression.o: queryresult.h finderhelper.h fieldvaluehelper.h wrapper.h
|
jsonexpression.o: queryresult.h finderhelper.h fieldvaluehelper.h ft.h
|
||||||
jsonexpression.o: spacewrapper.h baseobjectwrapper.h modelcontainerwrapper.h
|
|
||||||
jsonexpression.o: ft.h
|
|
||||||
model.o: model.h modelconnector.h clearer.h dbconnector.h queryresult.h ft.h
|
model.o: model.h modelconnector.h clearer.h dbconnector.h queryresult.h ft.h
|
||||||
model.o: flatconnector.h dbexpression.h baseexpression.h morm_types.h
|
model.o: flatconnector.h dbexpression.h baseexpression.h morm_types.h
|
||||||
model.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
model.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
||||||
model.o: fieldvaluehelper.h wrapper.h spacewrapper.h baseobjectwrapper.h
|
model.o: fieldvaluehelper.h flatexpression.h modelcontainerwrapper.h
|
||||||
model.o: modelcontainerwrapper.h flatexpression.h
|
model.o: baseobjectwrapper.h spacewrapper.h
|
||||||
modelconnector.o: modelconnector.h clearer.h dbconnector.h queryresult.h ft.h
|
modelconnector.o: modelconnector.h clearer.h dbconnector.h queryresult.h ft.h
|
||||||
modelconnector.o: flatconnector.h
|
modelconnector.o: flatconnector.h
|
||||||
postgresqlconnector.o: postgresqlconnector.h dbconnector.h queryresult.h ft.h
|
postgresqlconnector.o: postgresqlconnector.h dbconnector.h queryresult.h ft.h
|
||||||
postgresqlconnector.o: postgresqlqueryresult.h postgresqlexpression.h
|
postgresqlconnector.o: postgresqlqueryresult.h postgresqlexpression.h
|
||||||
postgresqlconnector.o: dbexpression.h baseexpression.h morm_types.h
|
postgresqlconnector.o: dbexpression.h baseexpression.h morm_types.h
|
||||||
postgresqlconnector.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
postgresqlconnector.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h
|
||||||
postgresqlconnector.o: fieldvaluehelper.h wrapper.h spacewrapper.h
|
postgresqlconnector.o: fieldvaluehelper.h
|
||||||
postgresqlconnector.o: baseobjectwrapper.h modelcontainerwrapper.h
|
|
||||||
postgresqlexpression.o: postgresqlexpression.h dbexpression.h
|
postgresqlexpression.o: postgresqlexpression.h dbexpression.h
|
||||||
postgresqlexpression.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
postgresqlexpression.o: baseexpression.h morm_types.h modelenv.h modeldata.h
|
||||||
postgresqlexpression.o: cursorhelper.h queryresult.h finderhelper.h
|
postgresqlexpression.o: cursorhelper.h queryresult.h finderhelper.h
|
||||||
postgresqlexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h
|
postgresqlexpression.o: fieldvaluehelper.h ft.h
|
||||||
postgresqlexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h
|
|
||||||
postgresqlqueryresult.o: postgresqlqueryresult.h queryresult.h
|
postgresqlqueryresult.o: postgresqlqueryresult.h queryresult.h
|
||||||
queryresult.o: queryresult.h
|
queryresult.o: queryresult.h
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "finderhelper.h"
|
#include "finderhelper.h"
|
||||||
#include "fieldvaluehelper.h"
|
#include "fieldvaluehelper.h"
|
||||||
#include "morm_types.h"
|
#include "morm_types.h"
|
||||||
#include "wrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MORM_HAS_EZC_LIBRARY
|
#ifdef MORM_HAS_EZC_LIBRARY
|
||||||
|
|
|
@ -49,9 +49,15 @@ class SpaceWrapper : public BaseObjectWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
SpaceWrapper() = delete;
|
||||||
|
SpaceWrapper(const SpaceWrapper &) = delete;
|
||||||
|
SpaceWrapper & operator=(const SpaceWrapper &) = delete;
|
||||||
|
|
||||||
|
|
||||||
SpaceWrapper(pt::Space * space)
|
SpaceWrapper(pt::Space * space)
|
||||||
{
|
{
|
||||||
this->space = space;
|
this->space = space;
|
||||||
|
last_for_loop_status = false;
|
||||||
initialize_indices();
|
initialize_indices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,12 +105,22 @@ public:
|
||||||
return std::numeric_limits<size_t>::max();
|
return std::numeric_limits<size_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_last_for_loop_status(bool for_status)
|
||||||
|
{
|
||||||
|
last_for_loop_status = for_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_last_for_loop_status()
|
||||||
|
{
|
||||||
|
return last_for_loop_status;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
const size_t SPACE_INDICES_TABLE_SIZE = 32;
|
const size_t SPACE_INDICES_TABLE_SIZE = 32;
|
||||||
pt::Space * space;
|
pt::Space * space;
|
||||||
std::vector<size_t> indices;
|
std::vector<size_t> indices;
|
||||||
|
bool last_for_loop_status;
|
||||||
|
|
||||||
|
|
||||||
void initialize_indices()
|
void initialize_indices()
|
||||||
|
|
193
src/wrapper.h
193
src/wrapper.h
|
@ -1,193 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is a part of morm
|
|
||||||
* and is distributed under the 2-Clause BSD licence.
|
|
||||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2021, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfile_morm_wrapper
|
|
||||||
#define headerfile_morm_wrapper
|
|
||||||
|
|
||||||
#include "spacewrapper.h"
|
|
||||||
#include "date/date.h"
|
|
||||||
#include "modelcontainerwrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace morm
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
class Wrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Model * model;
|
|
||||||
ModelContainerWrapper * model_container_wrapper;
|
|
||||||
pt::Date * date;
|
|
||||||
SpaceWrapper * space_wrapper;
|
|
||||||
|
|
||||||
|
|
||||||
Wrapper()
|
|
||||||
{
|
|
||||||
model = nullptr;
|
|
||||||
model_container_wrapper = nullptr;
|
|
||||||
date = nullptr;
|
|
||||||
space_wrapper = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Wrapper(const Wrapper & wrapper)
|
|
||||||
{
|
|
||||||
model = nullptr;
|
|
||||||
model_container_wrapper = nullptr;
|
|
||||||
date = nullptr;
|
|
||||||
space_wrapper = nullptr;
|
|
||||||
|
|
||||||
copy(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Wrapper & operator=(const Wrapper & wrapper)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
copy(wrapper);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual ~Wrapper()
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual void clear()
|
|
||||||
{
|
|
||||||
if( model_container_wrapper )
|
|
||||||
{
|
|
||||||
model_container_wrapper->decrement_reference_counter();
|
|
||||||
|
|
||||||
if( model_container_wrapper->get_reference_counter() == 0 && model_container_wrapper->should_be_auto_removed() )
|
|
||||||
{
|
|
||||||
delete model_container_wrapper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( space_wrapper )
|
|
||||||
{
|
|
||||||
space_wrapper->decrement_reference_counter();
|
|
||||||
|
|
||||||
if( space_wrapper->get_reference_counter() == 0 && space_wrapper->should_be_auto_removed() )
|
|
||||||
{
|
|
||||||
delete space_wrapper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
model = nullptr;
|
|
||||||
model_container_wrapper = nullptr;
|
|
||||||
date = nullptr;
|
|
||||||
space_wrapper = nullptr;
|
|
||||||
|
|
||||||
clear_childs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual void clear_childs()
|
|
||||||
{
|
|
||||||
childs_map.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual Wrapper * add_child(const std::wstring & child_name, Wrapper & wrapper)
|
|
||||||
{
|
|
||||||
Wrapper & w = childs_map[child_name];
|
|
||||||
w.clear();
|
|
||||||
w = wrapper;
|
|
||||||
return &w;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual Wrapper * find_child(const std::wstring & child_name)
|
|
||||||
{
|
|
||||||
auto i = childs_map.find(child_name);
|
|
||||||
|
|
||||||
if( i != childs_map.end() )
|
|
||||||
{
|
|
||||||
return &i->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool has_object()
|
|
||||||
{
|
|
||||||
return model || model_container_wrapper || date || space_wrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool has_model_object()
|
|
||||||
{
|
|
||||||
return model || model_container_wrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::map<std::wstring, Wrapper> childs_map;
|
|
||||||
|
|
||||||
|
|
||||||
void copy(const Wrapper & wrapper)
|
|
||||||
{
|
|
||||||
model = wrapper.model;
|
|
||||||
model_container_wrapper = wrapper.model_container_wrapper;
|
|
||||||
date = wrapper.date;
|
|
||||||
space_wrapper = wrapper.space_wrapper;
|
|
||||||
|
|
||||||
if( model_container_wrapper )
|
|
||||||
{
|
|
||||||
model_container_wrapper->increment_reference_counter();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( space_wrapper )
|
|
||||||
{
|
|
||||||
space_wrapper->increment_reference_counter();
|
|
||||||
}
|
|
||||||
|
|
||||||
// childs_map don't need to be copied
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue