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

cClassRegister.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 <cClassRegister.h>
00017 
00018 ClassRegister Class;
00019 
00020 void ClassRegister::_Invent(ProtoBase * const _p, int _l)
00021 {
00022         for (int i=0; i<_l; i++)
00023                 printf(" ");
00024         if (!_p)
00025                 printf("*\n");
00026         else
00027         {
00028                 printf("%s\n",_p->ClassName());
00029                 _Invent(_p->_left,_l+1);
00030                 _Invent(_p->_right,_l+1);
00031         };
00032 };
00033 
00034 void ClassRegister::_Initialise(ProtoBase * const _p)
00035 {
00036         if (_p)
00037         {
00038                 _p->_Initialise();
00039                 _Initialise(_p->_left);
00040                 _Initialise(_p->_right);
00041         };
00042 };
00043 
00044 void ClassRegister::_WriteDDL(ProtoBase * const _p, ofstream &S, class Database &Db)
00045 // generates DDL staments nedded for class _p and all its predecessors
00046 {
00047         if (!_p)
00048                 return;
00049         for(int i=0; i<_p->_fullParentPrototypeCount; i++)
00050         {
00051                 if (_p->_fullParentPrototype[i] && !_p->_fullParentPrototype[i]->_processed)
00052                         _p->_fullParentPrototype[i]->WriteDDL(S,Db);
00053                 _p->_fullParentPrototype[i]->_processed = true;
00054         };
00055 };
00056 
00057 bool ClassRegister::WriteDDL(ofstream &S, class Database &Db)
00058 // generates DDL staments nedded for all registered clases
00059 {
00060         if (!S.rdbuf()->is_open())
00061                 return false;
00062         _Initialise(ProtoBase::_root);
00063         ProtoBase::_root->_ResetProcessed(ProtoBase::_root);
00064         ProtoBase *_p = ProtoBase::_first;
00065         while (_p)
00066         {
00067                 if (!_p->_processed)
00068                         _WriteDDL(_p,S,Db);
00069                 _p = _p->_next;
00070         };
00071         return true;
00072 };
00073 
00074 ProtoBase *ProtoBase::_gcs(ProtoBase &X)
00075 // greatest common successor of X and Y
00076 // (one of potentially many of them)
00077 {
00078         if ((*this)<=(X))
00079                 return this;
00080         else if ((X)<=(*this))
00081                 return &X;
00082         // Try to find a prototype that is less or equal than both X and Y
00083         ProtoBase *p = ProtoBase::_first;
00084         ProtoBase *result = NULL;
00085     while (p)
00086         {
00087                 if (((*p)<=(*this)) && ((*p)<=(X)) && ((!result) || ((*p)>=(*result))))
00088                         result = p;
00089                 p = p->_next;
00090         };
00091         return result;
00092 };

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