00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <cObjRef.h>
00017
00018
00019 #include <cRefBase.h>
00020 #include <cProtoBase.h>
00021 #include <cQuery.h>
00022 #include <cConnection.h>
00023
00025
00026
00027
00028
00029
00030
00031
00033
00035
00036
00037
00038 ObjRef::ObjRef()
00039 {
00040 _Strategies =
00041 DEFAULT_LOCKING_STRATEGY
00042 | DEFAULT_UPDATING_STRATEGY
00043 | DEFAULT_WAITING_STRATEGY
00044 | DEFAULT_READING_STRATEGY;
00045 _Connection = NULL;
00046 #ifdef GC_OBJRF_TRACE
00047 logmsg("ObjRef::ObjRef() invoked and finished");
00048 #endif
00049 }
00050
00052
00053
00054
00055 ObjRef::~ObjRef()
00056 {
00057 #ifdef GC_OBJRF_TRACE
00058 logmsg("ObjRef::~ObjRef() invoked and finished");
00059 #endif
00060 }
00061
00062 char *ObjRef::_Where() const
00063
00064 {
00065 if (Prototype() == NULL)
00066 return NONE._Where();
00067 char *_where = NULL;
00068 char *_columns = StrCpy(_columns = NULL, Prototype()->KeySelect());
00069 char *_values = _KeyValues();
00070 char *_1column = NULL;
00071 char *_1value = NULL;
00072 const char *delim = "";
00073 while (StrSplit(_columns,',',_1column) && StrSplit(_values,',',_1value))
00074 {
00075 StrDecode(_1value);
00076 StrCat(_where,6,delim,"(",_1column," = ",_1value,")");
00077 delim = " AND ";
00078 StrFree(_1column);
00079 StrFree(_1value);
00080 };
00081 StrFree(_columns);
00082 StrFree(_values);
00083 return _where;
00084 };
00085
00086 bool ObjRef::IsAncestor(
00087 const ObjRef &descendant
00088 ) const
00089
00090
00091 {
00092 return (this->Prototype())>=(descendant.Prototype());
00093 };
00094
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 bool ObjRef::SetUpdatingStrategy(enum UpdatingStrategy anUpdatingStrategy)
00150 {
00151 #ifdef C_OBJREF_TRACE
00152 logmsg("bool ObjRef::SetUpdatingStrategy(...) invoked");
00153 #endif
00154 switch (anUpdatingStrategy)
00155 {
00156 case US_Current:
00157 break;
00158 case US_Inherited:
00159 _Strategies = _Strategies & ~US_MASK | (unsigned int)(_Connection ? _Connection->CurrentUpdatingStrategy() : DEFAULT_UPDATING_STRATEGY);
00160 break;
00161 case US_Default:
00162 _Strategies = _Strategies & ~US_MASK | DEFAULT_UPDATING_STRATEGY;
00163 break;
00164 default:
00165 _Strategies = _Strategies & ~US_MASK | (unsigned int)anUpdatingStrategy;
00166 };
00167 #ifdef C_OBJREF_TRACE
00168 logmsg("bool ObjRef::SetUpdatingStrategy(...) finished");
00169 #endif
00170 return true;
00171 };
00172 bool ObjRef::SetWaitingStrategy(enum WaitingStrategy aWaitingStrategy)
00173 {
00174 #ifdef C_OBJREF_TRACE
00175 logmsg("bool ObjRef::SetWaitingStrategy(...) invoked");
00176 #endif
00177 switch (aWaitingStrategy)
00178 {
00179 case WS_Current:
00180 break;
00181 case WS_Inherited:
00182 _Strategies = _Strategies & ~WS_MASK | (unsigned int)(_Connection ? _Connection->CurrentWaitingStrategy() : DEFAULT_WAITING_STRATEGY);
00183 break;
00184 case WS_Default:
00185 _Strategies = _Strategies & ~WS_MASK | DEFAULT_WAITING_STRATEGY;
00186 break;
00187 default:
00188 _Strategies = _Strategies & ~WS_MASK | (unsigned int)aWaitingStrategy;
00189 };
00190 #ifdef C_OBJREF_TRACE
00191 logmsg("bool ObjRef::SetWaitingStrategy(...) finished");
00192 #endif
00193 return true;
00194 };
00195 bool ObjRef::SetLockingStrategy(enum LockingStrategy aLockingStrategy)
00196 {
00197 #ifdef C_OBJREF_TRACE
00198 logmsg("bool ObjRef::SetLockingStrategy(...) invoked");
00199 #endif
00200 switch (aLockingStrategy)
00201 {
00202 case LS_Current:
00203 break;
00204 case LS_Inherited:
00205 _Strategies = _Strategies & ~LS_MASK | (unsigned int)(_Connection ? _Connection->CurrentLockingStrategy() : DEFAULT_LOCKING_STRATEGY);
00206 break;
00207 case LS_Default:
00208 _Strategies = _Strategies & ~LS_MASK | DEFAULT_LOCKING_STRATEGY;
00209 break;
00210 default:
00211 _Strategies = _Strategies & ~LS_MASK | (unsigned int)aLockingStrategy;
00212 };
00213 #ifdef C_OBJREF_TRACE
00214 logmsg("bool ObjRef::SetLockingStrategy(...) finished");
00215 #endif
00216 return true;
00217 };
00218 bool ObjRef::SetReadingStrategy(enum ReadingStrategy aReadingStrategy)
00219 {
00220 #ifdef C_OBJREF_TRACE
00221 logmsg("bool ObjRef::SetReadingStrategy(...) invoked");
00222 #endif
00223 switch (aReadingStrategy)
00224 {
00225 case RS_Current:
00226 break;
00227 case RS_Inherited:
00228 _Strategies = _Strategies & ~RS_MASK | (unsigned int)(_Connection ? _Connection->CurrentReadingStrategy() : DEFAULT_READING_STRATEGY);
00229 break;
00230 case RS_Default:
00231 _Strategies = _Strategies & ~RS_MASK | DEFAULT_READING_STRATEGY;
00232 break;
00233 default:
00234 _Strategies = _Strategies & ~RS_MASK | (unsigned int)aReadingStrategy;
00235 };
00236 #ifdef C_OBJREF_TRACE
00237 logmsg("bool ObjRef::SetReadingStrategy(...) finished");
00238 #endif
00239 return true;
00240 };