some work in morm
now in Model we have field() methods for other Model or std::list<Model> (code not tested) git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1118 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -62,8 +62,6 @@ public:
|
||||
virtual void set_logger(PT::Logger * logger);
|
||||
virtual void set_logger(PT::Logger & logger);
|
||||
|
||||
virtual int get_connector_mode();
|
||||
|
||||
// FIX ME
|
||||
// add c-copy ctr (allocate a new stream and expression)
|
||||
|
||||
@@ -98,6 +96,14 @@ public:
|
||||
|
||||
virtual void clear_values(Model & model);
|
||||
|
||||
template<typename ModelClass>
|
||||
void clear_values(std::list<ModelClass> & list)
|
||||
{
|
||||
list.clear();
|
||||
}
|
||||
|
||||
virtual void set_connector_for_childs(Model & model);
|
||||
|
||||
// template<typename ModelClass>
|
||||
// Finder<ModelClass> & find()
|
||||
// {
|
||||
@@ -108,8 +114,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
int model_connector_mode;
|
||||
|
||||
PT::Logger * logger;
|
||||
|
||||
FlatConnector * flat_connector;
|
||||
@@ -127,7 +131,7 @@ protected:
|
||||
|
||||
|
||||
template<typename FieldValue>
|
||||
void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, bool insertable, bool updatable, bool is_primary_key)
|
||||
void field_generic(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, bool insertable, bool updatable, bool is_primary_key, int model_connector_mode)
|
||||
{
|
||||
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_GENERATING_FLAT_STRING && flat_connector )
|
||||
{
|
||||
@@ -164,6 +168,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
template<typename FieldValue>
|
||||
void field(const PT::TextStream & db_field_name, const PT::TextStream & flat_field_name, FieldValue & field_value, bool insertable, bool updatable, bool is_primary_key)
|
||||
{
|
||||
@@ -174,18 +179,20 @@ protected:
|
||||
|
||||
field(db_field.c_str(), flat_field.c_str(), field_value, insertable, updatable, is_primary_key);
|
||||
}
|
||||
*/
|
||||
|
||||
template<typename ModelClass>
|
||||
void field_list(const wchar_t * field_name, std::list<ModelClass> & field_list, bool insertable = true, bool updatable = true, bool is_primary_key = false)
|
||||
//void field_list(const wchar_t * field_name, std::list<ModelClass> & field_list, bool insertable = true, bool updatable = true, bool is_primary_key = false)
|
||||
void field_list(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::list<ModelClass> & field_list, bool insertable, bool updatable, bool is_primary_key, int model_connector_mode)
|
||||
{
|
||||
// IMPLEMENTME what about db?
|
||||
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_GENERATING_FLAT_STRING && flat_connector )
|
||||
{
|
||||
FlatExpression * flat_expression = flat_connector->get_expression();
|
||||
|
||||
if( flat_expression && !is_empty_field(field_name) )
|
||||
if( flat_expression && !is_empty_field(flat_field_name) )
|
||||
{
|
||||
flat_expression->field_list(field_name, field_list, insertable, updatable, is_primary_key);
|
||||
flat_expression->field_list(flat_field_name, field_list, insertable, updatable, is_primary_key, model_connector_mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,19 +200,28 @@ protected:
|
||||
{
|
||||
field_list.clear();
|
||||
}
|
||||
|
||||
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_SETTING_CONNECTOR_FOR_CHILDS )
|
||||
{
|
||||
// IMPROVE ME
|
||||
// it would be better to set the connector when an operation is needed
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ModelClass>
|
||||
void field_model(const wchar_t * field_name, ModelClass & field_model, bool insertable = true, bool updatable = true, bool is_primary_key = false)
|
||||
//void field_model(const wchar_t * field_name, ModelClass & field_model, bool insertable = true, bool updatable = true, bool is_primary_key = false)
|
||||
void field_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelClass & field_model, bool insertable, bool updatable, bool is_primary_key, int model_connector_mode)
|
||||
{
|
||||
// IMPLEMENTME what about db?
|
||||
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_GENERATING_FLAT_STRING && flat_connector )
|
||||
{
|
||||
FlatExpression * flat_expression = flat_connector->get_expression();
|
||||
|
||||
if( flat_expression && !is_empty_field(field_name) )
|
||||
if( flat_expression && !is_empty_field(flat_field_name) )
|
||||
{
|
||||
flat_expression->field_model(field_name, field_model, insertable, updatable, is_primary_key);
|
||||
field_model.model_connector_mode = MORM_MODEL_CONNECTOR_MODE_GENERATING_FLAT_STRING;
|
||||
flat_expression->field_model(flat_field_name, field_model, insertable, updatable, is_primary_key);
|
||||
field_model.model_connector_mode = MORM_MODEL_CONNECTOR_MODE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,10 +229,16 @@ protected:
|
||||
{
|
||||
field_model.clear();
|
||||
}
|
||||
|
||||
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_SETTING_CONNECTOR_FOR_CHILDS )
|
||||
{
|
||||
field_model.set_connector(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename FieldValue>
|
||||
void add_field_for_select(const wchar_t * new_column_expression, const wchar_t * new_column_name, FieldValue & field_value)
|
||||
void add_field_for_select(const wchar_t * new_column_expression, const wchar_t * new_column_name, FieldValue & field_value, int model_connector_mode)
|
||||
{
|
||||
if( model_connector_mode == MORM_MODEL_CONNECTOR_MODE_GENERATING_DB_SQL && db_connector )
|
||||
{
|
||||
|
Reference in New Issue
Block a user