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

tResult.h

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 #ifndef __T_RESULT_H__
00016 #define __T_RESULT_H__
00017 
00018 template<class T> class Result;
00019 
00020 // Parent Header(s)
00021 #include <cResultBase.h>
00022 
00023 // Other POLiTe Header(s)
00024 #include <tRef.h>
00025 
00026 template<class T> class Result: public ResultBase
00027 {
00028 #ifdef POLITE_TEST_FRIEND
00029         friend POLITE_TEST_FRIEND;
00030 #endif // POLITE_TEST_FRIEND
00031 
00032 public:
00033         Result() : ResultBase()
00034         {};
00035 
00036         T *operator ->()
00037         //Returns the pointer to the pointed object
00038         //which will be read from the database, if the object
00039         //is not present in memory yet.
00040         {
00041                 if (*this == DBNULL)
00042                         throw ObjLibException_NotFound();
00043                 return IsPersistent() ? (T *)ObjectCache.GetReferencedObject(*this) : (T *)_Object();
00044         };
00045 
00046         T &operator *()
00047         //Returns the pointed object
00048         //which will be read from the database, if the object
00049         //is not present in memory yet.
00050         {
00051                 if (*this == DBNULL)
00052                         throw ObjLibException_NotFound();
00053                 return IsPersistent() ? *(T *)ObjectCache.GetReferencedObject(*this) : *(T *)_Object();
00054         };
00055 
00056 };
00057 
00058 #endif //__T_RESULT_H__

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