Changeset 2805 in Sophya for trunk/SophyaLib/BaseTools/ppersist.cc
- Timestamp:
- Jun 9, 2005, 6:20:00 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/ppersist.cc
r2698 r2805 21 21 22 22 23 #define MAXTAGLEN 255 23 24 /*! 25 \class SOPHYA::PIOPersist 26 \ingroup BaseTools 27 Handles (statically) the registration of PPF Sophya Persistence) handler classes. 28 \sa PPersist 29 */ 30 24 31 25 32 //++ … … 32 39 //-- 33 40 34 //++35 // Links See36 // PPersist37 // PInPersist38 // POutPersist39 //--40 41 42 41 MD5_CONTEXT PIOPersist::ctx; 43 42 PIOPersist::ClassList * PIOPersist::ppclassList = NULL; // $CHECK$ Reza 26/04/99 … … 57 56 } 58 57 59 //++ 58 /*! 59 Register a new persistence handler (PPersist) class. 60 The classId is usually a hash of the class< name, and 61 ppclass_name is typeid(PPersistClass).name() . 62 This method is called only through the PPersistRegistrar template 63 */ 60 64 void 61 65 PIOPersist::RegisterPPHandlerClass(uint_8 classId, string ppclass_name, ClassCreatorFunc f) 62 //63 // Register a new persistence handler (PPersist) class.64 // The classId is usually a hash of the class< name, and65 // ppclass_name is typeid(PPersistClass).name() .66 // This method is called only through the PPersistRegistrar template67 //68 //--69 66 { 70 67 if (ppclassList->size() && (ppclassList->find(classId) != ppclassList->end()) ) { … … 83 80 } 84 81 85 //++ 82 /*! 83 Register a new DataObj class corresponding to a PPersist classId 84 class_typename should be typeid(DataObject).name() 85 */ 86 86 void 87 87 PIOPersist::RegisterDataObjClass(uint_8 classId, string class_name) 88 // Register a new DataObj class corresponding to a PPersist classId89 // class_typename should be typeid(DataObject).name()90 //--91 88 { 92 89 if (ppclassList->find(classId) == ppclassList->end() ) { … … 132 129 } 133 130 131 //! Returns the PPersist class creator function for the specified classId 134 132 PIOPersist::ClassCreatorFunc 135 133 PIOPersist::FindCreatorFunc(uint_8 classId) 136 // Returns the PPersist class creator function for the specified classId137 134 { 138 135 ClassList::iterator i = ppclassList->find(classId); … … 141 138 } 142 139 140 //! Returns the PPersist class name for the specified classId 143 141 string 144 142 PIOPersist::getPPClassName(uint_8 classId) 145 // Returns the PPersist class name for the specified classId146 143 { 147 144 map<string, uint_8>::iterator i; … … 152 149 } 153 150 151 //! Returns the classId for the specified PPersist class type name 154 152 uint_8 155 153 PIOPersist::getPPClassId(string const & typ_name) 156 // Returns the classId for the specified PPersist class type name157 154 { 158 155 map<string, uint_8>::iterator i = ppclassNameList->find(typ_name); … … 162 159 } 163 160 161 //! Returns the classId for the specified PPersist class 164 162 uint_8 165 163 PIOPersist::getPPClassId(PPersist const & ppo) 166 // Returns the classId for the specified PPersist class167 164 { 168 165 string typ_name = typeid(ppo).name() ; … … 171 168 172 169 170 //! Returns the PPersist class name for the specified classId 173 171 string 174 172 PIOPersist::getDataObjClassName(uint_8 classId) 175 // Returns the PPersist class name for the specified classId176 173 { 177 174 map<string, uint_8>::iterator i; … … 182 179 } 183 180 181 //! Returns the classId for the specified PPersist class type name 184 182 uint_8 185 183 PIOPersist::getDataObjClassId(string const & typ_name) 186 // Returns the classId for the specified PPersist class type name187 184 { 188 185 map<string, uint_8>::iterator i = dobjclassNameList->find(typ_name); … … 192 189 } 193 190 191 //! Returns the classId for the specified PPersist class 194 192 uint_8 195 193 PIOPersist::getDataObjClassId(AnyDataObj const & o) 196 // Returns the classId for the specified PPersist class197 194 { 198 195 string typ_name = typeid(o).name() ; … … 200 197 } 201 198 199 //! \cond 202 200 static inline void bswap8_hash(void* p) 203 201 { … … 213 211 } 214 212 215 213 //! \endcond 216 214 217 215 uint_8 PIOPersist::Hash(string const& typname) { … … 238 236 // persistant : 239 237 // - Hériter de PPersist. 240 // - Définir un numéro d'identification de la classe, unique dans Peida241 // - Implémenter "ClassId()"242 238 // - Implémenter "WriteSelf" et "ReadSelf", qui doivent écrire toutes les variables 243 239 // membres que l'on souhaite écrire, et les relire dans le même ordre. … … 253 249 //-- 254 250 255 //++ 256 // Links See 257 // PInPersist 258 // POutPersist 259 // PIOPersist 260 //-- 261 262 //++ 251 /*! 252 \class SOPHYA::PPersist 253 \ingroup BaseTools 254 Ancestor (base) class for SOPHYA persistence (PPF) handlers. 255 In order to have provide a PPF handler for an object : 256 - Inherit from PPersist 257 - Implement WriteSelf() and ReadSelf() 258 259 \sa PInPersist POutPersist PIOPersist 260 */ 261 262 //! Writes the object into a new PPF file named \b fn 263 263 void 264 264 PPersist::Write(string const& fn) const 265 //266 // Ecrit l'objet dans un nouveau fichier ppersist "fn".267 //--268 265 { 269 266 POutPersist of(fn); … … 271 268 } 272 269 273 // ++270 //! Reads the object from a PInPersist stream created from file \b fn 274 271 void 275 272 PPersist::Read(string const& fn) 276 //277 // Relit l'objet dans le fichier ppersist "fn". Il faut connaître a priori278 // le type de l'objet. Pour une relecture avec création automatique du bon279 // objet, utiliser PPersistMgr::ReadObject.280 //--281 273 { 282 274 PInPersist inf(fn); … … 285 277 } 286 278 287 // ++279 //! Writes the object to the output PPF stream \b s 288 280 void 289 281 PPersist::Write(POutPersist& s) const 290 //291 // Ecrit l'objet dans le fichier PPersist.292 //--293 282 { 294 283 s.PutPPObject(this); … … 296 285 297 286 298 // ++287 //! Reads the object from the input PPF stream \b s 299 288 void 300 289 PPersist::Read(PInPersist& s) … … 337 326 } 338 327 339 // ++328 //! Writes a name tag (\b tag) and then the object to the output PPF stream \b s 340 329 void 341 330 PPersist::Write(POutPersist& s, string const& tag) const 342 //343 // Ecrit l'objet dans le fichier PPersist avec un tag344 //--345 331 { 346 332 s.WriteNameTag(tag); … … 348 334 } 349 335 350 // ++336 //! Try to position at the name tag \b tag and then reads the object from the input stream \b s 351 337 void 352 338 PPersist::ReadAtTag(PInPersist& s, string const& tag) 353 //354 // Lit l'objet à la position du tag numéro "tagid".355 //--356 339 { 357 340 if (!s.GotoNameTag(tag)) … … 361 344 362 345 // Renvoie l'identificateur de l'objet - par defaut=0 363 346 /*! Return the object identifier (default: return 0) 347 (used for handling of PPF I/O for objects with reference sharing). 348 */ 364 349 uint_8 365 350 PPersist::getMemOId() const … … 370 355 // Ces deux methodes doivent etre redefinies si getMemOId() renvoie non nul (>0) 371 356 // ShareDataReference() et CloneSharedReference() 357 /*! 358 This method should be re-implemented if getMemOId() non zero value. 359 (used for handling of PPF I/O for objects with reference sharing). 360 */ 372 361 void 373 362 PPersist::ShareDataReference(PPersist & pcs) … … 376 365 } 377 366 367 /*! 368 This method should be re-implemented if getMemOId() non zero value. 369 (used for handling of PPF I/O for objects with reference sharing). 370 */ 378 371 PPersist * 379 372 PPersist::CloneSharedReference() … … 403 396 //-- 404 397 398 /*! 399 \class SOPHYA::PInPersist 400 \ingroup BaseTools 401 This class implements the I/O read services necessary for SOPHYA 402 persistence (PPF) by extending the services provided by PPFBinaryInputStream. 403 \sa PPersist 404 */ 405 406 /*! Constructor from a RawInOutStream pointer 407 \param is : pointer to RawInOutStream 408 \param ad : if true, the RawInOutStream \b is is deleted by the destructor 409 \param scan : if true, try to read the name-tags table from the end of the input stream 410 */ 405 411 PInPersist::PInPersist(RawInOutStream * is, bool ad, bool scan) 406 412 : PPFBinaryInputStream(is, ad, scan) … … 408 414 } 409 415 416 /*! Constructor 417 \param flnm : input file name 418 \param scan : if true, try to read the name-tags table from the end of the input stream 419 */ 410 420 PInPersist::PInPersist(string const& flnm, bool scan) 411 421 : PPFBinaryInputStream(flnm, scan) … … 436 446 } 437 447 448 /*! Skip to next object in the streams, reads it and return 449 the corresponding PPersist handler 450 */ 438 451 PPersist* 439 452 PInPersist::ReadObject() … … 443 456 } 444 457 458 /*! 459 Tries to read in from the stream into object \b o 460 */ 445 461 void 446 462 PInPersist::GetObject(AnyDataObj & o) … … 450 466 } 451 467 468 /*! 469 Tries to move to \b nametag and then read in from the stream into object \b o 470 */ 452 471 void 453 472 PInPersist::GetObject(AnyDataObj & o, string tagname) … … 458 477 } 459 478 479 /*! 480 Reading of objects - used by GetObject() and ReadObject() 481 */ 460 482 PPersist* 461 483 PInPersist::GetPPObject(AnyDataObj * po) … … 575 597 576 598 599 /*! 600 \class SOPHYA::POutPersist 601 \ingroup BaseTools 602 This class implements the I/O write services necessary for SOPHYA 603 persistence (PPF) by extending the services provided by PPFBinaryOutputStream. 604 \sa PPersist 605 */ 606 577 607 //++ 578 608 // POutPersist(string const& flnm, int endianness = PPersist::PPS_NATIVE) … … 583 613 // ou PPersist::PPS_BIG_ENDIAN. 584 614 //-- 615 616 /*! Constructor from a RawInOutStream pointer 617 \param os : pointer to RawInOutStream 618 \param ad : if true, the RawInOutStream \b os is deleted by the destructor 619 \param endianness : Endianness selector PPS_NATIVE PPS_LITTLE_ENDIAN PPS_BIG_ENDIAN 620 */ 585 621 POutPersist::POutPersist(RawInOutStream* os, bool ad, int endianness) 586 622 : PPFBinaryOutputStream(os, ad, endianness) … … 590 626 } 591 627 628 /*! Constructor 629 \param flnm : output file name 630 \param endianness : Endianness selector PPS_NATIVE PPS_LITTLE_ENDIAN PPS_BIG_ENDIAN 631 */ 592 632 POutPersist::POutPersist(string const& flnm, int endianness) 593 633 : PPFBinaryOutputStream(flnm, endianness) … … 603 643 604 644 645 //! Writes the object \b o to the stream 605 646 void 606 647 POutPersist::PutObject(AnyDataObj & o) … … 614 655 } 615 656 657 //! Writes the nametag \b tagname and then the object \b o to the stream 616 658 void 617 659 POutPersist::PutObject(AnyDataObj & o, string tagname)
Note:
See TracChangeset
for help on using the changeset viewer.