00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #ifndef KOGMO_RTDB_OBJ_BASE_CLASSES_HXX
00010 #define KOGMO_RTDB_OBJ_BASE_CLASSES_HXX
00011 
00012 #ifndef KOGMO_RTDB_H
00013         #ifndef KOGMO_RTDB_DONT_INCLUDE_ALL_OBJECTS
00014         #define KOGMO_RTDB_DONT_INCLUDE_ALL_OBJECTS //automatically don't include all objects, if an object file was included manually
00015         #endif
00016 #endif
00017 
00018 #include "kogmo_rtdb.hxx"
00019 
00020 namespace KogniMobil {
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 typedef kogmo_rtdb_objid_t ObjID;  
00037 typedef kogmo_rtdb_objtype_t ObjType;
00038 typedef kogmo_rtdb_objsize_t ObjSize;
00039 
00040 
00041 
00042 
00043 class RTDBObj
00044 {
00045   public: 
00046     
00047     kogmo_rtdb_handle_t *db_h;
00048     kogmo_rtdb_obj_info_t *objinfo_p;
00049     kogmo_rtdb_subobj_base_t *objbase_p;
00050     kogmo_rtdb_objsize_t *objsize_p; 
00051     kogmo_rtdb_objsize_t *objsize_min_p;
00052   private:
00053     void operator= ( const RTDBObj& src); 
00054     int *reference_counter;
00055   public:
00056     
00057     
00058     RTDBObj (const class RTDBConn& DBC,
00059                const char* name = "",
00060                const int& otype = 0, 
00061                const int32_t& child_size = 0, char** child_dataptr = NULL)
00062       {
00063                 
00064         db_h=DBC.getHandle();
00065         
00066         objinfo_p = new kogmo_rtdb_obj_info_t;
00067 
00068         
00069                     objsize_p = new kogmo_rtdb_objsize_t; 
00070                     objsize_min_p = new kogmo_rtdb_objsize_t;
00071         (*objsize_p) = sizeof (kogmo_rtdb_subobj_base_t) + child_size;
00072         char *ptr = new char [(*objsize_p)];
00073         objbase_p = (kogmo_rtdb_subobj_base_t*) ptr;
00074         (*objsize_min_p) = (*objsize_p);
00075 
00076         
00077         if ( child_size && child_dataptr != NULL )
00078           *child_dataptr = ptr + sizeof (kogmo_rtdb_obj_base_t);
00079 
00080         
00081         int err = kogmo_rtdb_obj_initinfo (db_h, objinfo_p, name, otype, (*objsize_p));
00082         if ( err < 0 )
00083           throw DBError(err);
00084 
00085         
00086         err = kogmo_rtdb_obj_initdata (db_h, objinfo_p, objbase_p);
00087         if ( err < 0 )
00088           throw DBError(err);
00089 
00090                 
00091                 reference_counter = new int;
00092                 (*reference_counter) = 1;
00093       };
00094 
00095 
00096                         RTDBObj (const RTDBObj& src)
00097                         {
00098                                 
00099                                 db_h = src.db_h;
00100                                 objinfo_p = src.objinfo_p;
00101                                 objbase_p = src.objbase_p;
00102                     objsize_p = src.objsize_p; 
00103                     objsize_min_p = src.objsize_min_p;
00104                                 reference_counter = src.reference_counter; 
00105                 (*reference_counter)++;
00106       };
00107 
00108     virtual ~RTDBObj ()
00109       {
00110                 
00111                 (*reference_counter)--;
00112                 if ((*reference_counter) == 0) {
00113                         
00114                 delete reference_counter;
00115                             delete objsize_p; 
00116                             delete objsize_min_p;
00117                 delete objbase_p;
00118                 delete objinfo_p;
00119                 }
00120       };
00121 
00122     
00123     
00124     
00125     bool Copy ( const RTDBObj& src, int force = 0)
00126       {
00127         bool ok = true;
00128         if ( objinfo_p->otype && objinfo_p->otype != src.objinfo_p->otype ) 
00129           ok = false;
00130         if ( *(src.objsize_p) < (*objsize_min_p) ) 
00131           ok = false;
00132         if ( *(src.objsize_min_p) > (*objsize_p) ) 
00133           ok = false;
00134         if ( !ok && !force )
00135           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00136 
00137         (*objsize_p) = *(src.objsize_p) <= (*objsize_p) ? *(src.objsize_p) : (*objsize_p);
00138         (*objsize_min_p) = *(src.objsize_min_p) <= (*objsize_min_p) ? *(src.objsize_min_p) : (*objsize_min_p); 
00139 
00140         memcpy ( objinfo_p, src.objinfo_p, sizeof(kogmo_rtdb_obj_info_t) );
00141         if ( db_h != src.db_h )
00142           objinfo_p -> oid = 0; 
00143         memcpy ( objbase_p, src.objbase_p, (*objsize_p) > *(src.objsize_p) ? *(src.objsize_p) : (*objsize_p) );
00144         memset ( objbase_p + (*objsize_p), 0, (*objsize_p) > *(src.objsize_p) ? *(objsize_p)-*(src.objsize_p) : 0 );
00145         return ok;
00146       };
00147 
00148     
00149 
00150     kogmo_rtdb_handle_t *getDBC() const
00151       {
00152         return db_h;
00153       };
00154 
00155     
00156     
00157     
00158     
00159     
00160 
00161     kogmo_rtdb_obj_info_t *getObjInfo() const
00162       {
00163         return objinfo_p;
00164       };
00165 
00166     kogmo_rtdb_subobj_base_t *getObjData() const
00167       {
00168         return objbase_p;
00169       };
00170 
00171 
00172     
00173     
00174     
00175     
00176     
00177 
00178     void RTDBInsert (void)
00179       {
00180         
00181         if ( objinfo_p -> oid )
00182           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00183         int err = kogmo_rtdb_obj_insert (db_h, objinfo_p);
00184         if ( err < 0 )
00185           throw DBError(err);
00186       }
00187 
00188     void RTDBDelete (void)
00189       {
00190         if ( ! objinfo_p -> oid )
00191           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00192         int err = kogmo_rtdb_obj_delete (db_h, objinfo_p);
00193         if ( err < 0 )
00194           throw DBError(err);
00195       }
00196 
00197     void setTimes (float avg_cycletime,   
00198                    float max_cycletime,   
00199                    float history_interval 
00200 
00201                   )
00202       {
00203         if ( objinfo_p -> oid )
00204           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00205         objinfo_p->avg_cycletime = avg_cycletime;
00206         objinfo_p->max_cycletime = max_cycletime;
00207         objinfo_p->history_interval = history_interval;
00208       }
00209 
00210     float getAvgCycleTime () const
00211       {
00212         return objinfo_p->avg_cycletime;
00213       }
00214 
00215     float getMaxCycleTime () const
00216       {
00217         return objinfo_p->max_cycletime;
00218       }
00219 
00220     float getHistoryInterval () const
00221       {
00222         return objinfo_p->history_interval;
00223       }
00224 
00225     kogmo_rtdb_objid_t getOID () const
00226       {
00227         return objinfo_p->oid;
00228       };
00229 
00230     void newObject ()
00231       {
00232         objinfo_p->oid = 0;
00233       };
00234 
00235     std::string getName () const
00236       {
00237         return std::string(objinfo_p->name);
00238       };
00239 
00240     void setName (std::string name)
00241       {
00242         if ( objinfo_p -> oid )
00243           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00244         strncpy (objinfo_p->name, name.c_str(), KOGMO_RTDB_OBJMETA_NAME_MAXLEN);
00245         objinfo_p->name[KOGMO_RTDB_OBJMETA_NAME_MAXLEN-1] = '\0';
00246       };
00247 
00248     kogmo_rtdb_objtype_t getType () const
00249       {
00250         return objinfo_p->otype;
00251       };
00252 
00253     void setType (kogmo_rtdb_objtype_t type)
00254       {
00255         if ( objinfo_p -> oid )
00256           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00257         objinfo_p->otype = type;
00258       };
00259 
00260     kogmo_rtdb_objid_t getParent () const
00261       {
00262         return objinfo_p->parent_oid;
00263       };
00264 
00265     void setParent (kogmo_rtdb_objid_t oid)
00266       {
00267         if ( objinfo_p -> oid )
00268           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00269         objinfo_p->parent_oid = oid;
00270       };
00271 
00272     void setAllowPublicRead(bool yes = true)
00273       {
00274         if ( objinfo_p -> oid )
00275           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00276         objinfo_p->flags.read_deny = yes ? 0 : 1;
00277       };
00278 
00279     void setAllowPublicWrite(bool yes = true)
00280       {
00281         if ( objinfo_p -> oid )
00282           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00283         objinfo_p->flags.write_allow = yes ? 1 : 0;
00284       };
00285 
00286     void setForceUnique(bool yes = true)
00287       {
00288         if ( objinfo_p -> oid )
00289           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00290         objinfo_p->flags.unique = yes ? 1 : 0;
00291       };
00292 
00293     void setCycleWatch(bool yes = true)
00294       {
00295         if ( objinfo_p -> oid )
00296           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00297         objinfo_p->flags.cycle_watch = yes ? 1 : 0;
00298       };
00299 
00300     void setPersistent(bool yes = true)
00301       {
00302         if ( objinfo_p -> oid )
00303           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00304         objinfo_p->flags.persistent = yes ? 1 : 0;
00305       };
00306 
00307     void setParentDelete(bool yes = true)
00308       {
00309         if ( objinfo_p -> oid )
00310           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00311         objinfo_p->flags.parent_delete = yes ? 1 : 0;
00312       };
00313 
00314     Timestamp getCreatedTimestamp () const
00315       {
00316         return Timestamp(objinfo_p -> created_ts);
00317       }
00318 
00319     Timestamp getDeletedTimestamp () const
00320       {
00321         return Timestamp(objinfo_p -> deleted_ts);
00322       }
00323 
00324     bool isDeleted () const
00325       {
00326         return objinfo_p -> deleted_ts ? true : false;
00327       }
00328 
00329     kogmo_rtdb_objid_t getDeletededProcOID () const
00330       {
00331         return objinfo_p->deleted_proc;
00332       };
00333 
00334     kogmo_rtdb_objid_t getCreatedProcOID () const
00335       {
00336         return objinfo_p->created_proc;
00337       };
00338 
00339     std::string getDeletededProcInfo () const
00340       {
00341         kogmo_rtdb_obj_c3_process_info_t pi;
00342         kogmo_rtdb_obj_c3_process_getprocessinfo (db_h,
00343                                                   objinfo_p->deleted_proc,
00344                                                   objinfo_p->deleted_ts, pi);
00345         std::string info = std::string (pi);
00346         return info;
00347       }
00348 
00349     std::string getCreatedProcInfo () const
00350       {
00351         kogmo_rtdb_obj_c3_process_info_t pi;
00352         kogmo_rtdb_obj_c3_process_getprocessinfo (db_h,
00353                                                   objinfo_p->created_proc,
00354                                                   objinfo_p->created_ts, pi);
00355         std::string info = std::string (pi);
00356         return info;
00357       }
00358 
00359      kogmo_rtdb_objsize_t getMaxSize () const
00360       {
00361         return objinfo_p -> size_max;
00362       }
00363 
00364      
00365      
00366 
00367      kogmo_rtdb_objsize_t getMinSize () const
00368       {
00369         return (*objsize_min_p);
00370       }
00371 
00372      void setMinSize (kogmo_rtdb_objsize_t size = 0)
00373       {
00374         if ( size == 0 )
00375           {
00376             (*objsize_min_p) = sizeof (kogmo_rtdb_subobj_base_t);
00377             return;
00378           }
00379         if ( size < 0 ) 
00380           {
00381             size = (*objsize_p) - (-size);
00382           }
00383         if ( size < (kogmo_rtdb_objsize_t)sizeof (kogmo_rtdb_subobj_base_t) )
00384           {
00385             throw DBError(-KOGMO_RTDB_ERR_INVALID);
00386           }
00387         (*objsize_min_p) = size;
00388       }
00389 
00390 
00391     
00392 
00393     void RTDBWrite (int32_t size = 0, Timestamp ts = 0)
00394       {
00395         if ( ! objinfo_p -> oid )
00396           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00397         if (size)
00398           objbase_p -> size = size;
00399         if (ts)
00400           objbase_p -> data_ts = ts;
00401         int err;
00402         do
00403          {
00404           err = kogmo_rtdb_obj_writedata (db_h, objinfo_p -> oid, objbase_p);
00405           if ( err == -KOGMO_RTDB_ERR_TOOFAST )
00406             std::cout << "too fast!\n";
00407          }
00408         while ( err == -KOGMO_RTDB_ERR_TOOFAST );
00409         if ( err < 0 )
00410           throw DBError(err);
00411       }
00412 
00413     void RTDBRead ( Timestamp ts = 0 ) 
00414       {
00415         kogmo_rtdb_objsize_t osize;
00416         osize = kogmo_rtdb_obj_readdata (db_h, objinfo_p -> oid, ts,
00417                                          objbase_p, (*objsize_p));
00418         if ( osize < 0 )
00419           {
00420             objbase_p -> size = 0;
00421             throw DBError(osize);
00422           }
00423         if ( osize < (*objsize_min_p) )
00424           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00425       };
00426 
00427     void RTDBReadDataTime ( Timestamp ts = 0 )
00428       {
00429         kogmo_rtdb_objsize_t osize;
00430         osize = kogmo_rtdb_obj_readdata_datatime (db_h, objinfo_p -> oid, ts,
00431                                          objbase_p, (*objsize_p));
00432         if ( osize < 0 )
00433           {
00434             objbase_p -> size = 0;
00435             throw DBError(osize);
00436           }
00437         if ( osize < (*objsize_min_p) )
00438           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00439       };
00440 
00441     void RTDBReadWaitNext ( Timestamp old_ts = 0, float timeout = 0 )
00442       
00443       
00444       {
00445         Timestamp wakeup_ts = 0;
00446         if ( timeout )
00447           {
00448             wakeup_ts.now(); 
00449                       
00450                       
00451                       
00452             wakeup_ts+=timeout;
00453           }
00454         kogmo_rtdb_objsize_t osize;
00455         if ( ! old_ts )
00456           old_ts = objbase_p -> committed_ts;
00457         osize = kogmo_rtdb_obj_readdata_waitnext_until (db_h, objinfo_p -> oid,
00458                                                         old_ts, objbase_p, (*objsize_p), wakeup_ts);
00459         if ( osize < 0 )
00460           throw DBError(osize);
00461         if ( osize < (*objsize_min_p) )
00462           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00463       };
00464 
00465     void RTDBReadDataYounger ( Timestamp old_ts = 0 )
00466       {
00467         kogmo_rtdb_objsize_t osize;
00468         if ( ! old_ts )
00469           old_ts = objbase_p -> data_ts;
00470         osize = kogmo_rtdb_obj_readdata_datayounger (db_h, objinfo_p -> oid, old_ts,
00471                                          objbase_p, (*objsize_p));
00472         if ( osize < 0 )
00473           {
00474             objbase_p -> size = 0;
00475             throw DBError(osize);
00476           }
00477         if ( osize < (*objsize_min_p) )
00478           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00479       };
00480 
00481     void RTDBReadYounger ( Timestamp old_ts = 0 )
00482       {
00483         kogmo_rtdb_objsize_t osize;
00484         if ( ! old_ts )
00485           old_ts = objbase_p -> data_ts;
00486         osize = kogmo_rtdb_obj_readdata_younger (db_h, objinfo_p -> oid, old_ts,
00487                                          objbase_p, (*objsize_p));
00488         if ( osize < 0 )
00489           {
00490             objbase_p -> size = 0;
00491             throw DBError(osize);
00492           }
00493         if ( osize < (*objsize_min_p) )
00494           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00495       };
00496 
00497     void RTDBReadDataOlder ( Timestamp old_ts = 0 )
00498       {
00499         kogmo_rtdb_objsize_t osize;
00500         if ( ! old_ts )
00501           old_ts = objbase_p -> data_ts;
00502         osize = kogmo_rtdb_obj_readdata_dataolder (db_h, objinfo_p -> oid, old_ts,
00503                                          objbase_p, (*objsize_p));
00504         if ( osize < 0 )
00505           {
00506             objbase_p -> size = 0;
00507             throw DBError(osize);
00508           }
00509         if ( osize < (*objsize_min_p) )
00510           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00511       };
00512 
00513     void RTDBReadOlder ( Timestamp old_ts = 0 )
00514       {
00515         kogmo_rtdb_objsize_t osize;
00516         if ( ! old_ts )
00517           old_ts = objbase_p -> data_ts;
00518         osize = kogmo_rtdb_obj_readdata_older (db_h, objinfo_p -> oid, old_ts,
00519                                          objbase_p, (*objsize_p));
00520         if ( osize < 0 )
00521           {
00522             objbase_p -> size = 0;
00523             throw DBError(osize);
00524           }
00525         if ( osize < (*objsize_min_p) )
00526           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00527       };
00528 
00529     
00530     
00531     
00532     
00533     
00534     void RTDBReadWaitSuccessor ( Timestamp old_ts = 0 )
00535       {
00536         if ( ! old_ts )
00537           old_ts = objbase_p -> committed_ts;
00538         
00539         kogmo_rtdb_obj_base_t tmp_obj; 
00540         kogmo_rtdb_objsize_t osize;
00541         osize = kogmo_rtdb_obj_readdata_waitnext (db_h, objinfo_p -> oid,
00542                                                   old_ts, &tmp_obj, sizeof(tmp_obj));
00543         if ( osize < 0 )
00544           throw DBError(osize);
00545         
00546         RTDBReadYounger ( old_ts );
00547         
00548         
00549         if ( ! isValid ( old_ts ) )
00550           throw DBError("History wrap-around, you might be too slow");
00551           
00552       };
00553 
00554     void RTDBReadPredecessor ( Timestamp old_ts = 0 )
00555       {
00556         kogmo_rtdb_objsize_t osize;
00557         if ( ! old_ts )
00558           old_ts = objbase_p -> committed_ts;
00559         osize = kogmo_rtdb_obj_readdata_older (db_h, objinfo_p -> oid, old_ts,
00560                                                objbase_p, (*objsize_p));
00561         if ( osize < 0 )
00562           {
00563             objbase_p -> size = 0;
00564             if ( osize == -KOGMO_RTDB_ERR_NOTFOUND )
00565               throw DBError("History wrap-around, you might be too slow");
00566               
00567             throw DBError(osize);
00568           }
00569         if ( osize < (*objsize_min_p) )
00570           throw DBError(-KOGMO_RTDB_ERR_INVALID);
00571       };
00572 
00573     bool isValid ( Timestamp ts = 0 )
00574       {
00575         if ( ! ts )
00576           ts = objbase_p -> committed_ts;
00577         
00578         kogmo_rtdb_obj_base_t tmp_obj; 
00579         kogmo_rtdb_objsize_t osize;
00580         osize = kogmo_rtdb_obj_readdata (db_h, objinfo_p -> oid,
00581                                          ts, &tmp_obj, sizeof(tmp_obj));
00582         if ( osize < 0 )
00583           return false;
00584         return true;
00585       }
00586 
00587     Timestamp getTimestamp () const 
00588       {
00589         return getDataTimestamp();
00590       }
00591 
00592     void setTimestamp (Timestamp ts = 0) 
00593       {
00594         setDataTimestamp (ts);
00595       }
00596 
00597     Timestamp getDataTimestamp () const
00598       {
00599         return objbase_p -> data_ts;
00600       }
00601 
00602     void setDataTimestamp (Timestamp ts = 0)
00603       {
00604         if (!ts)
00605           ts = kogmo_rtdb_timestamp_now(db_h);
00606         objbase_p -> data_ts = ts;
00607       }
00608 
00609     Timestamp getCommittedTimestamp () const
00610       {
00611         return objbase_p -> committed_ts;
00612       }
00613 
00614      kogmo_rtdb_objid_t getCommittedProcOID () const
00615       {
00616         return objbase_p -> committed_proc;
00617       }
00618 
00619      std::string getCommittedProcInfo () const
00620       {
00621         kogmo_rtdb_obj_c3_process_info_t pi;
00622         kogmo_rtdb_obj_c3_process_getprocessinfo (db_h,
00623                                                   objbase_p->committed_proc,
00624                                                   objbase_p->committed_ts, pi);
00625         std::string info = std::string (pi);
00626         return info;
00627       }
00628 
00629      kogmo_rtdb_objsize_t getSize () const
00630       {
00631         return objbase_p -> size;
00632       }
00633 
00634      void setSize (int size = 0)
00635       {
00636         if ( size < 0 ) 
00637           {
00638             size = (*objsize_p) - (-size);
00639           }
00640         if ( size < (kogmo_rtdb_objsize_t)sizeof (kogmo_rtdb_subobj_base_t) )
00641           {
00642             throw DBError(-KOGMO_RTDB_ERR_INVALID);
00643           }
00644         objbase_p -> size = size;
00645       }
00646 
00647 
00648 
00649 
00650 
00651 
00652 
00653     
00654 
00655     void RTDBSearch (kogmo_rtdb_objid_t oid, Timestamp ts = 0)
00656       {
00657         kogmo_rtdb_objtype_t saved_otype = objinfo_p->otype;
00658         int err = kogmo_rtdb_obj_readinfo ( db_h, oid, ts, objinfo_p );
00659         if ( err < 0 )
00660           throw DBError(err);
00661         if ( saved_otype && objinfo_p->otype != saved_otype )
00662           { 
00663             newObject();
00664             objinfo_p->otype = saved_otype;
00665             throw DBError(-KOGMO_RTDB_ERR_INVALID);
00666           }
00667         
00668         if ( objinfo_p->size_max > (*objsize_p) ) objinfo_p->size_max = (*objsize_p);
00669         err = kogmo_rtdb_obj_initdata (db_h, objinfo_p, objbase_p);
00670         if ( err < 0 )
00671           throw DBError(err);
00672       };
00673 
00674     void RTDBSearch (const char* name = "", kogmo_rtdb_objid_t parent_oid = 0,
00675                      kogmo_rtdb_objid_t proc_oid = 0, Timestamp ts = 0,
00676                      int nth = 1, kogmo_rtdb_objtype_t type = -1)
00677       {
00678         kogmo_rtdb_objid_t oid;
00679         if (type<0) type = objinfo_p -> otype;
00680         oid = kogmo_rtdb_obj_searchinfo ( db_h, name, type,
00681                     parent_oid, proc_oid, ts, NULL, nth);
00682         if ( oid < 0 )
00683           throw DBError(oid);
00684         RTDBSearch (oid, ts);
00685       };
00686 
00687     void RTDBSearchWait (const char* name = "", kogmo_rtdb_objid_t parent_oid = 0,
00688                          kogmo_rtdb_objid_t proc_oid = 0, float timeout = 0 )
00689       
00690       {
00691         Timestamp wakeup_ts = 0;
00692         if ( timeout )
00693           {
00694             wakeup_ts.now();
00695             wakeup_ts+=timeout;
00696           }
00697         kogmo_rtdb_objid_t oid;
00698         oid = kogmo_rtdb_obj_searchinfo_wait_until ( db_h, name, objinfo_p -> otype,
00699                     parent_oid, proc_oid, wakeup_ts);
00700         if ( oid < 0 )
00701           throw DBError(oid);
00702         RTDBSearch (oid);
00703       };
00704 
00705     virtual std::string dump (void) const
00706       {
00707         char *p;
00708         p = kogmo_rtdb_obj_dumpinfo_str (db_h, objinfo_p);
00709         std::string info = std::string(p);
00710         free(p);
00711         p = kogmo_rtdb_obj_dumpbase_str (db_h, objbase_p);
00712         std::string data = std::string(p);
00713         free(p);
00714         return info+data;
00715       }
00716 
00717 
00718 #ifdef   KOGMO_RTDB_OBJ_BASE_CLASS_EXTRA_METHODS_FILE
00719 #include KOGMO_RTDB_OBJ_BASE_CLASS_EXTRA_METHODS_FILE
00720 #endif
00721 
00722 };
00723 
00724 
00725 inline std::ostream& operator<< (std::ostream& out, const RTDBObj& O)
00726 {
00727   return out << std::endl << O.dump() << std::endl;
00728 };
00729 
00730 
00731 
00732 
00733 
00734 
00735 
00736 
00737 
00738 
00739 
00740 
00741 
00742 
00743 
00744 template < typename KOGMO_SUBSTRUCT, int KOGMO_TYPE_ID,
00745            class KOGMO_CLASS = RTDBObj, int size_add = 0 > class RTDBObj_T
00746          : public KOGMO_CLASS
00747 {
00748   public:
00749     KOGMO_SUBSTRUCT *subobj_p;
00750   public:
00751     RTDBObj_T (class RTDBConn& DBC,
00752                const char* name = "",
00753                const int& otype = KOGMO_TYPE_ID,
00754                const int32_t& child_size = size_add)
00755         : KOGMO_CLASS (DBC, name, otype, sizeof(KOGMO_SUBSTRUCT) +
00756                        child_size, (char**)&subobj_p)
00757       {
00758       };
00759 };
00760 
00761 
00762 
00763 }; 
00764 
00765 #endif