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 __C_RESULTBASE_H__ 00016 #define __C_RESULTBASE_H__ 00017 00018 // Common POLiTe Header(s) 00019 #include <lTypes.h> 00020 #include <lStr.h> 00021 00022 // Parent Header(s) 00023 #include <cRefBase.h> 00024 00025 class DLL_External ResultBase: public RefBase 00026 { 00027 #ifdef POLITE_TEST_FRIEND 00028 friend POLITE_TEST_FRIEND; 00029 #endif // POLITE_TEST_FRIEND 00030 00031 friend class Object; 00032 friend class ProtoBase; 00033 00034 protected: 00035 #ifdef NO_DATABASE_PRESENT 00036 int _row_counter; 00037 #endif 00038 class Query *_query; 00039 // a original Query for this result 00040 class Cursor *_cursor; 00041 // a cursor for data retrieving 00042 bool _isValRef; 00043 // if reference to a retrieved object is valid 00044 char *_sql_select; 00045 // select statement of the query 00046 class ProtoBase *_queryPrototype; 00047 // a prototype which should be used to execute the query 00048 class Connection *_queryConnection; 00049 // a database connection which should be used to retrieve data 00050 00051 00052 public: 00053 ResultBase(); 00054 00055 ~ResultBase(); 00056 00057 /* 00058 virtual class ObjRef *Get(); 00059 //Returns the reference to the resulted object on the position 00060 //given by the index (by the position of the database cursor in the result). 00061 00062 virtual class ObjRef *GetNext(); 00063 //Returns the next reference to the resulted object on the position 00064 //given by the index (by the position of the database cursor in the result). 00065 */ 00066 00067 virtual class ResultBase &operator++ (); 00068 //Sets result to Next() position 00069 00070 virtual class ResultBase &operator+= (long int n); 00071 //Sets result to Next() position 00072 00073 virtual bool operator== (const ResultBase &Q) const; 00074 //Compares two ResultBases (through the parity of pointers) 00075 virtual bool operator!= (const ResultBase &Q) const; 00076 //Compares two ResultBases (through the non-parity of pointers) 00077 00078 00079 bool Open(); //Stored command is executed and the result is retrieved. 00080 bool Close(); //Constructor //Closes retrieved set of objects. By closing the ResultBase, the cursor attached to it is closed. After closing, ResultBase can be reopened by sending Open message. 00081 00082 long Count(); //Returns the number of the items in the collection. 00083 bool Prev(); //Sets the index to the previous object in the collection. It returns true if the setting was successful, otherwise it returns false. 00084 bool Next(); //Sets the index to the next object in the collection. It returns true, if the setting was successful, otherwise it returns false. 00085 bool First(); //Sets the index to the first object in the collection. It returns true, if the setting was successful, otherwise it returns false. 00086 bool Last(); //Sets the index to the last object in the collection. It returns true, if the setting was successful, otherwise it returns false. 00087 bool IsOnFirst(); //Returns true, if the index points to the first item of the collection, otherwise it returns false. 00088 bool IsOnLast(); //Returns true, if the index points to the last item of the collection, otherwise it returns false. 00089 bool GoToPosition (long Pos); //Sets the index to the given position. Next calling of Get returns the Pos-th item of the collection. 00090 long Position(); //Returns the current value of the index. 00091 00092 bool operator == (const class RefBase &DbPtr) const; 00093 //Tests, if the objects to which two database pointers 00094 //point, are the same 00095 00096 bool operator != (const class RefBase &DbPtr) const; 00097 00098 protected: 00099 bool _SetSqlCommand(char* SQLcommand); //The method, which sets the text of SQL command to be executed in Query result. 00100 00101 }; 00102 00103 #endif //__C_RESULTBASE_H__