137 lines
3.5 KiB
C++
137 lines
3.5 KiB
C++
/*
|
|
* 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) 2019, 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_modelenv
|
|
#define headerfile_morm_modelenv
|
|
|
|
#include "modeldata.h"
|
|
#include "cursorhelper.h"
|
|
#include "finderhelper.h"
|
|
#include "fieldvaluehelper.h"
|
|
#include "morm_types.h"
|
|
|
|
|
|
namespace morm
|
|
{
|
|
|
|
|
|
class ModelEnv
|
|
{
|
|
public:
|
|
|
|
// global objects to the whole models tree
|
|
// (values are copied to child models)
|
|
ModelData * model_data;
|
|
FinderHelper * finder_helper;
|
|
CursorHelper * cursor_helper;
|
|
int model_work_mode;
|
|
int model_work_submode;
|
|
bool dump_mode;
|
|
|
|
PT::TextStream table_name; // CHECK ME may it should be PT::WTextStream?
|
|
PT::TextStream table_name_short;
|
|
int table_index;
|
|
int field_index;
|
|
bool all_fields_are_null;
|
|
|
|
std::vector<const wchar_t *> * set_field_name_helper;
|
|
std::vector<FieldValueHelper> * field_value_helper_tab;
|
|
|
|
|
|
ModelEnv()
|
|
{
|
|
clear();
|
|
}
|
|
|
|
|
|
~ModelEnv()
|
|
{
|
|
}
|
|
|
|
|
|
ModelEnv(const ModelEnv & e)
|
|
{
|
|
model_data = e.model_data;
|
|
finder_helper = e.finder_helper;
|
|
cursor_helper = e.cursor_helper;
|
|
model_work_mode = e.model_work_mode;
|
|
model_work_submode = e.model_work_submode;
|
|
dump_mode = e.dump_mode;
|
|
table_index = e.table_index;
|
|
set_field_name_helper = e.set_field_name_helper;
|
|
field_value_helper_tab = e.field_value_helper_tab;
|
|
field_index = e.field_index;
|
|
all_fields_are_null = e.all_fields_are_null;
|
|
|
|
// table_name and table_name_short don't have to bo copied
|
|
}
|
|
|
|
|
|
void copy_global_objects(const ModelEnv & e)
|
|
{
|
|
model_data = e.model_data;
|
|
finder_helper = e.finder_helper;
|
|
cursor_helper = e.cursor_helper;
|
|
|
|
model_work_mode = e.model_work_mode;
|
|
model_work_submode = e.model_work_submode;
|
|
dump_mode = e.dump_mode;
|
|
}
|
|
|
|
|
|
void clear()
|
|
{
|
|
model_data = nullptr;
|
|
finder_helper = nullptr;
|
|
cursor_helper = nullptr;
|
|
model_work_mode = MORM_MODEL_WORK_MODE_NONE;
|
|
model_work_submode = MORM_MODEL_WORK_SUBMODE_NONE;
|
|
dump_mode = false;
|
|
table_name.clear();
|
|
table_name_short.clear();
|
|
table_index = 0;
|
|
set_field_name_helper = nullptr;
|
|
field_value_helper_tab = nullptr;
|
|
field_index = 0;
|
|
all_fields_are_null = false;
|
|
}
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif
|