#include <Supersede.h>
Public Member Functions | |
Visitor::VisitorState | accept (Visitor *v) |
Visitor::VisitorState | accept (Visitor *v) |
void | addSet (Set *s) |
void | addSet (Set *s) |
const std::vector< std::string > & | getAsk () const |
const std::vector< std::string > & | getAsk () const |
const std::vector< FieldVal > & | getFixed () const |
const std::vector< FieldVal > & | getFixed () const |
const std::vector< std::string > & | getFixedInterp () const |
const std::vector< std::string > & | getFixedInterp () const |
const std::vector< std::string > & | getForced () const |
const std::vector< std::string > & | getForced () const |
const std::vector< std::string > & | getFromOld () const |
const std::vector< std::string > & | getFromOld () const |
const std::vector< std::string > & | getOldDefaulted () const |
const std::vector< std::string > & | getOldDefaulted () const |
Assertion * | getOnlyIf () |
Assertion * | getOnlyIf () |
const std::vector< Set * > & | getSetNew () const |
const std::vector< Set * > & | getSetNew () const |
const std::vector< Set * > & | getSetOld () const |
const std::vector< Set * > & | getSetOld () const |
const Table * | getTable () const |
const Table * | getTable () const |
void | normalize () |
void | normalize () |
void | setOnlyIf (Assertion *onlyIf) |
void | setOnlyIf (Assertion *onlyIf) |
Supersede (Table *table, Assertion *onlyIf=0) | |
Supersede (Table *table, Assertion *onlyIf=0) | |
~Supersede () | |
~Supersede () | |
Private Attributes | |
std::vector< std::string > | m_ask |
Names of columns for which client must supply a value (no default). | |
std::vector< std::string > | m_ask |
Names of columns for which client must supply a value (no default). | |
std::vector< FieldVal > | m_fixed |
Names of columns for which <supersede> supplies fixed value for new row. | |
std::vector< FieldVal > | m_fixed |
Names of columns for which <supersede> supplies fixed value for new row. | |
std::vector< std::string > | m_fixedInterp |
std::vector< std::string > | m_fixedInterp |
std::vector< std::string > | m_fromOld |
Name of all columns to be fetched from old row by Table::supersedeRow. | |
std::vector< std::string > | m_fromOld |
Name of all columns to be fetched from old row by Table::supersedeRow. | |
Table * | m_myTable |
Table * | m_myTable |
bool | m_normalized |
std::vector< std::string > | m_oldDefaults |
column names where old-row value is to be used as default | |
std::vector< std::string > | m_oldDefaults |
column names where old-row value is to be used as default | |
std::vector< std::string > | m_oldForced |
column names where old-row value is to be copied to new row | |
std::vector< std::string > | m_oldForced |
column names where old-row value is to be copied to new row | |
Assertion * | m_onlyIf |
Assertion * | m_onlyIf |
std::vector< Set * > | m_setNew |
std::vector< Set * > | m_setNew |
std::vector< Set * > | m_setOld |
std::vector< Set * > | m_setOld |
|
00009 : 00010 m_myTable(table), m_onlyIf(onlyIf), m_normalized(false) { 00011 m_setOld.clear(); 00012 m_setNew.clear(); 00013 m_oldDefaults.clear(); 00014 m_oldForced.clear(); 00015 m_ask.clear(); 00016 m_fixed.clear(); 00017 }
|
|
00075 { 00076 while (m_setOld.size() ) { 00077 Set* s = m_setOld.back(); 00078 m_setOld.pop_back(); 00079 delete s; 00080 } 00081 while (m_setNew.size() ) { 00082 Set* s = m_setNew.back(); 00083 m_setNew.pop_back(); 00084 delete s; 00085 } 00086 // delete m_onlyIf; probably already handled by ~Table 00087 }
|
|
|
|
|
|
|
|
00090 { 00091 Visitor::VisitorState state = v->visitSupersede(this); 00092 if (state == Visitor::VBRANCHDONE) return Visitor::VCONTINUE; 00093 return state; 00094 }
|
|
|
|
00019 { 00020 FIELDTYPE vtype = s->getDestType(); 00021 switch(vtype) { 00022 case FIELDTYPEold: 00023 case FIELDTYPEoldDef: // this shouldn't occur 00024 m_setOld.push_back(s); break; 00025 case FIELDTYPEtoBe: 00026 case FIELDTYPEtoBeDef: // nor this 00027 m_setNew.push_back(s); break; 00028 default: throw RdbException("Bad value type for <set> destination"); 00029 } 00030 return; 00031 }
|
|
00037 {
00038 return m_ask; }
|
|
00037 {
00038 return m_ask; }
|
|
00046 { return m_fixed;}
|
|
00046 { return m_fixed;}
|
|
00047 {
00048 return m_fixedInterp;}
|
|
00047 {
00048 return m_fixedInterp;}
|
|
00050 { return m_oldForced;}
|
|
00050 { return m_oldForced;}
|
|
00043 {
00044 return m_fromOld;}
|
|
00043 {
00044 return m_fromOld;}
|
|
00040 {
00041 return m_oldDefaults; }
|
|
00040 {
00041 return m_oldDefaults; }
|
|
00035 {return m_onlyIf;}
|
|
00035 {return m_onlyIf;}
|
|
00027 {return m_setOld;}
|
|
00027 {return m_setOld;}
|
|
00026 {return m_setOld;}
|
|
00026 {return m_setOld;}
|
|
00031 {return m_myTable;}
|
|
00031 {return m_myTable;}
|
|
Initialize m_oldDefaults, m_oldForced, m_ask and m_fixed if it hasn't been done already |
|
Initialize m_oldDefaults, m_oldForced, m_ask and m_fixed if it hasn't been done already 00034 { 00035 if (m_normalized) return; 00036 // unsigned nOld = m_setOld.size(); 00037 unsigned nNew = m_setNew.size(); 00038 // For each object in m_setNew, store information in one of the 00039 // vectors of column names or in m_fixed for easy access later 00040 for (unsigned iNew = 0; iNew < nNew; iNew++) { 00041 // FIELDTYPE srcType = m_setOld[iOld]->getSrcType(); 00042 // switch (srcType) { 00043 switch (m_setNew[iNew]->getSrcType()) { 00044 case FIELDTYPEold: 00045 m_oldForced.push_back(m_setNew[iNew]->getDestColName()); 00046 break; 00047 case FIELDTYPEoldDef: 00048 m_oldDefaults.push_back(m_setNew[iNew]->getDestColName()); 00049 break; 00050 case FIELDTYPEask: 00051 m_ask.push_back(m_setNew[iNew]->getDestColName()); 00052 break; 00053 case FIELDTYPElit: 00054 m_fixed.push_back(FieldVal(m_setNew[iNew]->getDestColName(), 00055 m_setNew[iNew]->getSrcValue())); 00056 m_fixedInterp.push_back(m_setNew[iNew]->getInterp()); 00057 break; 00058 default: 00059 throw RdbException("Supersede::normalize Unrecognized <set>"); 00060 } 00061 } 00062 00063 m_fromOld.reserve(m_oldDefaults.size() + m_oldForced.size()); 00064 m_fromOld.clear(); 00065 for (unsigned i = 0; i < m_oldDefaults.size(); i++) { 00066 m_fromOld.push_back(m_oldDefaults[i]); 00067 } 00068 for (unsigned i = 0; i < m_oldForced.size(); i++) { 00069 m_fromOld.push_back(m_oldForced[i]); 00070 } 00071 m_normalized = true; 00072 }
|
|
00057 {m_onlyIf = onlyIf;}
|
|
00057 {m_onlyIf = onlyIf;}
|
|
Names of columns for which client must supply a value (no default).
|
|
Names of columns for which client must supply a value (no default).
|
|
Names of columns for which <supersede> supplies fixed value for new row.
|
|
Names of columns for which <supersede> supplies fixed value for new row.
|
|
Parallel vector to keep track of which among fixed columns require further interpretation. May want to move this into FieldVal |
|
Parallel vector to keep track of which among fixed columns require further interpretation. May want to move this into FieldVal |
|
Name of all columns to be fetched from old row by Table::supersedeRow.
|
|
Name of all columns to be fetched from old row by Table::supersedeRow.
|
|
|
|
|
|
|
|
column names where old-row value is to be used as default Always need to fetch the same set of columns from the row to be superseded. Some of the values must be used in the new row; others are just defaults. |
|
column names where old-row value is to be used as default Always need to fetch the same set of columns from the row to be superseded. Some of the values must be used in the new row; others are just defaults. |
|
column names where old-row value is to be copied to new row
|
|
column names where old-row value is to be copied to new row
|
|
|
|
|
|
|
|
|
|
|
|
|