Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

cObjectIdentification.cpp

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /* POLiTe - Persistent Object Library Test                                    */
00004 /*                                        Ph.D. Thesis by Mgr. Michal Kopecky */
00005 /*                                                                            */
00006 /* Charles University Prague                                                  */
00007 /*                                                                            */
00008 /******************************************************************************/
00009 /*                                                                            */
00010 /* File name: ...                                                             */
00011 /* Module: ......                                                             */
00012 /*                                                                            */
00013 /******************************************************************************/
00014 
00015 // Own Header
00016 #include <cObjectIdentification.h>              // ObjectIdentification class header
00017 
00018 // Other POLiTe Header(s)
00019 #include <cObject.h>            // Object class header
00020 
00022 // ObjectIdentification constructors:
00023 // Create the ObjectIdentification object with the appropriate initialization.
00024 
00025 ObjectIdentification::ObjectIdentification()
00026 {
00027         #ifdef C_OBJECTIDENTIFICATION_TRACE
00028                 logmsg("ObjectIdentification::ObjectIdentification() invoked");
00029         #endif
00030 
00031         _prototype = NULL;
00032         _SelectKeyValues = NULL;
00033 
00034         #ifdef C_OBJECTIDENTIFICATION_TRACE
00035                 logmsg("ObjectIdentification::ObjectIdentification() finished");
00036         #endif
00037 };
00038 
00039 ObjectIdentification::ObjectIdentification(
00040         class ProtoBase *aPrototype,
00041         char * const aSelectKeyValues
00042         )
00043 {
00044         #ifdef C_OBJECTIDENTIFICATION_TRACE
00045                 logmsg("ObjectIdentification::ObjectIdentification(aPrototype, aSelectKeyValues) invoked");
00046         #endif
00047 
00048         _prototype = aPrototype;
00049         _SelectKeyValues = aSelectKeyValues;
00050         //StrCpy(_SelectKeyValues = NULL, aSelectKeyValues);
00051 
00052         #ifdef C_OBJECTIDENTIFICATION_TRACE
00053                 logmsg("ObjectIdentification::ObjectIdentification(aPrototype, aSelectKeyValues) finished");
00054         #endif
00055 };
00056 
00057 ObjectIdentification::ObjectIdentification(
00058         const class Object *anObject
00059         )
00060 {
00061         #ifdef C_OBJECTIDENTIFICATION_TRACE
00062                 logmsg("ObjectIdentification::ObjectIdentification(anObject) invoked");
00063         #endif
00064 
00065         _object = anObject;
00066         _SelectKeyValues = NULL;
00067 
00068         #ifdef C_OBJECTIDENTIFICATION_TRACE
00069                 logmsg("ObjectIdentification::ObjectIdentification(anObject) finished");
00070         #endif
00071 };
00072 
00073 ObjectIdentification::ObjectIdentification(
00074         const ObjectIdentification &X
00075         )
00076 {
00077         #ifdef C_OBJECTIDENTIFICATION_TRACE
00078                 logmsg("ObjectIdentification::ObjectIdentification(anObjectId) invoked");
00079         #endif
00080 
00081         _prototype = X._prototype;
00082         StrCpy(_SelectKeyValues = NULL, X._SelectKeyValues);
00083 
00084         #ifdef C_OBJECTIDENTIFICATION_TRACE
00085                 logmsg("ObjectIdentification::ObjectIdentification(anObjectId) finished");
00086         #endif
00087 };
00088 
00089 ObjectIdentification::ObjectIdentification(
00090         const long anOid,
00091         class ProtoBase *aPrototype
00092         )
00093 {
00094         #ifdef C_OBJECTIDENTIFICATION_TRACE
00095                 logmsg("ObjectIdentification::ObjectIdentification(aPrototype,anOid) invoked");
00096         #endif
00097 
00098         _prototype = aPrototype;
00099         _SelectKeyValues = LongToStr(anOid);
00100 
00101         #ifdef C_OBJECTIDENTIFICATION_TRACE
00102                 logmsg("ObjectIdentification::ObjectIdentification(aPrototype,anOid) finished");
00103         #endif
00104 };
00105 
00106 
00108 // ObjectIdentification destructor:
00109 // Delete the ObjectIdentification object
00110 
00111 ObjectIdentification::~ObjectIdentification()
00112 {
00113         #ifdef C_OBJECTIDENTIFICATION_TRACE
00114                 logmsg("ObjectIdentification::~ObjectIdentification() invoked");
00115         #endif
00116 
00117         _prototype = NULL;
00118         StrFree(_SelectKeyValues);
00119 
00120         #ifdef C_OBJECTIDENTIFICATION_TRACE
00121                 logmsg("ObjectIdentification::~ObjectIdentification() finished");
00122         #endif
00123 };
00124 
00125 bool ObjectIdentification::_Init(
00126         class ProtoBase *aPrototype,
00127         char * const aSelectKeyValues
00128         )
00129 // Initializes already existing identification
00130 {
00131         #ifdef C_OBJECTIDENTIFICATION_TRACE
00132                 logmsg("ObjectIdentification::_Init(aPrototype, aSelectKeyValues) invoked");
00133         #endif
00134 
00135         _prototype = aPrototype;
00136         StrFree(_SelectKeyValues);
00137         _SelectKeyValues = aSelectKeyValues;
00138         //StrCpy(_SelectKeyValues, aSelectKeyValues);
00139 
00140         #ifdef C_OBJECTIDENTIFICATION_TRACE
00141                 logmsg("ObjectIdentification::_Init(aPrototype, aSelectKeyValues) finished");
00142         #endif
00143 
00144         return true;
00145 };
00146 
00147 bool ObjectIdentification::_Init(
00148         const class Object *anObject
00149         )
00150 // Initializes already existing identification
00151 {
00152         #ifdef C_OBJECTIDENTIFICATION_TRACE
00153                 logmsg("ObjectIdentification::_Init(anObject) invoked");
00154         #endif
00155 
00156         _object = anObject;
00157         StrFree(_SelectKeyValues);
00158 
00159         #ifdef C_OBJECTIDENTIFICATION_TRACE
00160                 logmsg("ObjectIdentification::_Init(aPrototype, aSelectKeyValues) finished");
00161         #endif
00162 
00163         return true;
00164 };
00165 
00166 class ProtoBase *ObjectIdentification::Prototype() const
00167 // Returns reference to prototype instance of the target class
00168 {
00169         if (_SelectKeyValues == NULL)
00170                 if (_object == NULL)
00171                         return NULL;
00172                 else
00173                         return _object -> Prototype();
00174         else
00175                 return _prototype;
00176 };
00177 
00178 inline bool ObjectIdentification::operator ==(
00179                 const ObjectIdentification &X
00180                 ) const
00181 {
00182         if (this == &X)
00183                 return true;
00184         return (_object == X._object)
00185                 && (StrCmp(_SelectKeyValues,X._SelectKeyValues) == 0);
00186 };
00187 
00188 inline bool ObjectIdentification::operator !=(
00189                 const ObjectIdentification &X
00190                 ) const
00191 {
00192         if (this == &X)
00193                 return false;
00194         return (_object != X._object)
00195           || (StrCmp(_SelectKeyValues,X._SelectKeyValues) != 0);
00196 };
00197 
00198 inline ObjectIdentification &ObjectIdentification::operator =(
00199                 const ObjectIdentification &X
00200                 )
00201 {
00202         if (this != &X) {
00203           _object = X._object;
00204           StrCpy(_SelectKeyValues,X._SelectKeyValues);
00205           };
00206         return *this;
00207 };

Generated on Sun Jul 14 20:51:14 2002 for POLiTe by doxygen1.2.16