From c14b0eb62690bced4c0c22afc166d3b4c2c1c9f6 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Mon, 22 Nov 2021 15:45:44 +0100 Subject: [PATCH] removed Wrapper class --- src/Makefile.dep | 49 +++++------- src/modelenv.h | 1 - src/spacewrapper.h | 16 ++++ src/wrapper.h | 193 --------------------------------------------- 4 files changed, 36 insertions(+), 223 deletions(-) delete mode 100644 src/wrapper.h diff --git a/src/Makefile.dep b/src/Makefile.dep index a63305e..6eee666 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -2,62 +2,53 @@ baseexpression.o: baseexpression.h morm_types.h modelenv.h modeldata.h baseexpression.o: cursorhelper.h queryresult.h finderhelper.h -baseexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h -baseexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h model.h -baseexpression.o: modelconnector.h clearer.h dbconnector.h flatconnector.h -baseexpression.o: dbexpression.h flatexpression.h +baseexpression.o: fieldvaluehelper.h ft.h model.h modelconnector.h clearer.h +baseexpression.o: dbconnector.h flatconnector.h dbexpression.h +baseexpression.o: flatexpression.h modelcontainerwrapper.h +baseexpression.o: baseobjectwrapper.h spacewrapper.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: modelenv.h modeldata.h cursorhelper.h finderhelper.h -clearer.o: fieldvaluehelper.h wrapper.h spacewrapper.h baseobjectwrapper.h -clearer.o: modelcontainerwrapper.h flatexpression.h +clearer.o: fieldvaluehelper.h flatexpression.h modelcontainerwrapper.h +clearer.o: baseobjectwrapper.h spacewrapper.h dbconnector.o: dbconnector.h queryresult.h ft.h dbexpression.h dbconnector.o: baseexpression.h morm_types.h modelenv.h modeldata.h -dbconnector.o: cursorhelper.h finderhelper.h fieldvaluehelper.h wrapper.h -dbconnector.o: spacewrapper.h baseobjectwrapper.h modelcontainerwrapper.h -dbconnector.o: model.h modelconnector.h clearer.h flatconnector.h -dbconnector.o: flatexpression.h +dbconnector.o: cursorhelper.h finderhelper.h fieldvaluehelper.h model.h +dbconnector.o: modelconnector.h clearer.h flatconnector.h flatexpression.h +dbconnector.o: modelcontainerwrapper.h baseobjectwrapper.h spacewrapper.h dbexpression.o: dbexpression.h baseexpression.h morm_types.h modelenv.h dbexpression.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h -dbexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h -dbexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h +dbexpression.o: fieldvaluehelper.h ft.h flatconnector.o: flatconnector.h flatexpression.h baseexpression.h flatconnector.o: morm_types.h modelenv.h modeldata.h cursorhelper.h -flatconnector.o: queryresult.h finderhelper.h fieldvaluehelper.h wrapper.h -flatconnector.o: spacewrapper.h baseobjectwrapper.h modelcontainerwrapper.h -flatconnector.o: ft.h model.h modelconnector.h clearer.h dbconnector.h -flatconnector.o: dbexpression.h +flatconnector.o: queryresult.h finderhelper.h fieldvaluehelper.h ft.h model.h +flatconnector.o: modelconnector.h clearer.h dbconnector.h dbexpression.h +flatconnector.o: modelcontainerwrapper.h baseobjectwrapper.h spacewrapper.h flatexpression.o: flatexpression.h baseexpression.h morm_types.h modelenv.h flatexpression.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h -flatexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h -flatexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h +flatexpression.o: fieldvaluehelper.h ft.h jsonconnector.o: jsonconnector.h flatconnector.h jsonexpression.h jsonconnector.o: flatexpression.h baseexpression.h morm_types.h modelenv.h jsonconnector.o: modeldata.h cursorhelper.h queryresult.h finderhelper.h -jsonconnector.o: fieldvaluehelper.h wrapper.h spacewrapper.h -jsonconnector.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h +jsonconnector.o: fieldvaluehelper.h ft.h jsonexpression.o: jsonexpression.h flatexpression.h baseexpression.h jsonexpression.o: morm_types.h modelenv.h modeldata.h cursorhelper.h -jsonexpression.o: queryresult.h finderhelper.h fieldvaluehelper.h wrapper.h -jsonexpression.o: spacewrapper.h baseobjectwrapper.h modelcontainerwrapper.h -jsonexpression.o: ft.h +jsonexpression.o: queryresult.h finderhelper.h fieldvaluehelper.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: modelenv.h modeldata.h cursorhelper.h finderhelper.h -model.o: fieldvaluehelper.h wrapper.h spacewrapper.h baseobjectwrapper.h -model.o: modelcontainerwrapper.h flatexpression.h +model.o: fieldvaluehelper.h flatexpression.h modelcontainerwrapper.h +model.o: baseobjectwrapper.h spacewrapper.h modelconnector.o: modelconnector.h clearer.h dbconnector.h queryresult.h ft.h modelconnector.o: flatconnector.h postgresqlconnector.o: postgresqlconnector.h dbconnector.h queryresult.h ft.h postgresqlconnector.o: postgresqlqueryresult.h postgresqlexpression.h postgresqlconnector.o: dbexpression.h baseexpression.h morm_types.h postgresqlconnector.o: modelenv.h modeldata.h cursorhelper.h finderhelper.h -postgresqlconnector.o: fieldvaluehelper.h wrapper.h spacewrapper.h -postgresqlconnector.o: baseobjectwrapper.h modelcontainerwrapper.h +postgresqlconnector.o: fieldvaluehelper.h postgresqlexpression.o: postgresqlexpression.h dbexpression.h postgresqlexpression.o: baseexpression.h morm_types.h modelenv.h modeldata.h postgresqlexpression.o: cursorhelper.h queryresult.h finderhelper.h -postgresqlexpression.o: fieldvaluehelper.h wrapper.h spacewrapper.h -postgresqlexpression.o: baseobjectwrapper.h modelcontainerwrapper.h ft.h +postgresqlexpression.o: fieldvaluehelper.h ft.h postgresqlqueryresult.o: postgresqlqueryresult.h queryresult.h queryresult.o: queryresult.h diff --git a/src/modelenv.h b/src/modelenv.h index 482f9cf..ec36c8d 100644 --- a/src/modelenv.h +++ b/src/modelenv.h @@ -40,7 +40,6 @@ #include "finderhelper.h" #include "fieldvaluehelper.h" #include "morm_types.h" -#include "wrapper.h" #ifdef MORM_HAS_EZC_LIBRARY diff --git a/src/spacewrapper.h b/src/spacewrapper.h index e42fb40..f133d76 100644 --- a/src/spacewrapper.h +++ b/src/spacewrapper.h @@ -49,9 +49,15 @@ class SpaceWrapper : public BaseObjectWrapper { public: + SpaceWrapper() = delete; + SpaceWrapper(const SpaceWrapper &) = delete; + SpaceWrapper & operator=(const SpaceWrapper &) = delete; + + SpaceWrapper(pt::Space * space) { this->space = space; + last_for_loop_status = false; initialize_indices(); } @@ -99,12 +105,22 @@ public: return std::numeric_limits::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: const size_t SPACE_INDICES_TABLE_SIZE = 32; pt::Space * space; std::vector indices; + bool last_for_loop_status; void initialize_indices() diff --git a/src/wrapper.h b/src/wrapper.h deleted file mode 100644 index 5697526..0000000 --- a/src/wrapper.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * This file is a part of morm - * and is distributed under the 2-Clause BSD licence. - * Author: Tomasz Sowa - */ - -/* - * 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 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