morm/src/modelenv.h

126 lines
3.0 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 "setfieldvaluehelper.h"
#include "morm_types.h"
namespace morm
{
class ModelEnv
{
public:
ModelData * model_data;
FinderHelper * finder_helper;
CursorHelper * cursor_helper;
int model_connector_mode;
const void * doc_field_pointer;
PT::TextStream table_name;
PT::TextStream table_name_short;
int table_index;
int field_index;
SetFieldValueHelper * set_field_value_helper;
ModelEnv()
{
clear();
}
~ModelEnv()
{
}
ModelEnv(const ModelEnv & e)
{
model_data = e.model_data;
finder_helper = e.finder_helper;
cursor_helper = e.cursor_helper;
model_connector_mode = e.model_connector_mode;
table_index = e.table_index;
doc_field_pointer = e.doc_field_pointer;
set_field_value_helper = e.set_field_value_helper;
field_index = e.field_index;
// 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_connector_mode = e.model_connector_mode;
// what about doc_field_pointer?
}
void clear()
{
model_data = nullptr;
finder_helper = nullptr;
cursor_helper = nullptr;
model_connector_mode = MORM_MODEL_CONNECTOR_MODE_NONE;
doc_field_pointer = nullptr;
table_name.clear();
table_name_short.clear();
table_index = 0;
set_field_value_helper = nullptr;
field_index = 0;
}
};
}
#endif