Changeset 278 in Sophya for trunk/SophyaLib/NTools
- Timestamp:
- Apr 28, 1999, 3:36:50 PM (26 years ago)
- Location:
- trunk/SophyaLib/NTools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/dvlist.cc
r244 r278 39 39 40 40 41 using namespace PlanckDPC; 42 41 43 char MuTyV::myStrBuf[64]; // Declare static ds le .h 42 44 … … 74 76 { 75 77 PInPersist s(flnm); 76 Read(s); 78 ObjFileIO<DVList> fiodvl(this); 79 fiodvl.Read(s); 77 80 } 78 81 … … 279 282 } 280 283 281 282 /* --Methode-- */ 283 void DVList::WriteSelf(POutPersist& s) const 284 { 285 char buf[320]; 286 287 int lc = comment.length(); 288 if (lc > 319) lc = 319; 289 if (lc > 0) { 290 sprintf(buf,"Comment: ( %6d ) ", lc); 291 s.PutLine(buf); 292 s.PutBytes(comment.c_str(), lc); 293 } 294 s.PutLine("----Variable-List---------------"); 295 ValList::const_iterator it; 296 for(it = mvlist.begin(); it != mvlist.end(); it++) { 297 switch ((*it).second.typ) 298 { 299 case 'I' : 300 sprintf(buf,"I %s %d", (*it).first.substr(0,64).c_str(), (*it).second.mtv.iv ); 301 s.PutLine(buf); 302 break; 303 case 'D' : 304 sprintf(buf,"D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.mtv.dv ); 305 s.PutLine(buf); 306 break; 307 case 'S' : 308 sprintf(buf,"S %s %s", (*it).first.substr(0,64).c_str(), (*it).second.mtv.strv ); 309 s.PutLine(buf); 310 break; 311 default : 312 break; 313 } 314 } 315 316 s.PutLine("ZZZZZ--End-of-Varible-List------"); 317 } 318 319 /* --Methode-- */ 320 void DVList::ReadSelf(PInPersist& s) 321 { 322 char buf[320]; 323 int_4 j,iv; 324 double dv; 325 bool ok=true; 326 buf[0] = '\0'; 327 Clear(); 328 329 s.GetLine(buf, 319); // Pour lire les "------- " 330 if (buf[0] != '-') { // Il y a un champ commentaire a lire 331 buf[18] ='\0'; 332 int lc = atoi(buf+11); 333 if (lc > 319) { 334 cerr << "DVList::ReadSelf() Pb/Bug ?? CommentLength= " << lc << endl; 335 lc = 319; 336 } 337 s.GetBytes(buf, lc); 338 buf[lc] ='\0'; 339 comment = buf; 340 } 341 342 while(ok) { 343 s.GetLine(buf, 319); 344 buf[319] = '\0'; 345 if (strncmp(buf,"ZZZZZ",5) == 0) { ok=false; break; } 346 j = posc(buf+2, ' ')+2; 347 buf[j] = '\0'; 348 switch (buf[0]) 349 { 350 case 'I' : 351 iv = (int_4)atol(buf+j+1); 352 SetI(buf+2, iv); 353 break; 354 case 'D' : 355 dv = atof(buf+j+1); 356 SetD(buf+2, dv); 357 break; 358 case 'S' : 359 SetS(buf+2, buf+j+1); 360 break; 361 default : 362 break; 363 } 364 } 365 366 } 284 // Classe pour la gestion de persistance 285 // ObjFileIO<DVList> 286 367 287 368 288 //++ … … 397 317 //| int m = dvlr["hello"] ; // m = 88 398 318 //-- 319 320 321 322 /* --Methode-- */ 323 void ObjFileIO<DVList>::WriteSelf(POutPersist& s) const 324 { 325 char buf[320]; 326 327 int lc = dobj->Comment().length(); 328 if (lc > 319) lc = 319; 329 if (lc > 0) { 330 sprintf(buf,"Comment: ( %6d ) ", lc); 331 s.PutLine(buf); 332 s.PutBytes(dobj->Comment().c_str(), lc); 333 } 334 s.PutLine("----Variable-List---------------"); 335 DVList::ValList::const_iterator it; 336 for(it = dobj->Begin(); it != dobj->End(); it++) { 337 switch ((*it).second.typ) 338 { 339 case 'I' : 340 sprintf(buf,"I %s %d", (*it).first.substr(0,64).c_str(), (*it).second.mtv.iv ); 341 s.PutLine(buf); 342 break; 343 case 'D' : 344 sprintf(buf,"D %s %.20g", (*it).first.substr(0,64).c_str(), (*it).second.mtv.dv ); 345 s.PutLine(buf); 346 break; 347 case 'S' : 348 sprintf(buf,"S %s %s", (*it).first.substr(0,64).c_str(), (*it).second.mtv.strv ); 349 s.PutLine(buf); 350 break; 351 default : 352 break; 353 } 354 } 355 356 s.PutLine("ZZZZZ--End-of-Varible-List------"); 357 } 358 359 /* --Methode-- */ 360 void ObjFileIO<DVList>::ReadSelf(PInPersist& s) 361 { 362 char buf[320]; 363 int_4 j,iv; 364 double dv; 365 bool ok=true; 366 buf[0] = '\0'; 367 dobj->Clear(); 368 369 s.GetLine(buf, 319); // Pour lire les "------- " 370 if (buf[0] != '-') { // Il y a un champ commentaire a lire 371 buf[18] ='\0'; 372 int lc = atoi(buf+11); 373 if (lc > 319) { 374 cerr << "DVList::ReadSelf() Pb/Bug ?? CommentLength= " << lc << endl; 375 lc = 319; 376 } 377 s.GetBytes(buf, lc); 378 buf[lc] ='\0'; 379 dobj->Comment() = buf; 380 } 381 382 while(ok) { 383 s.GetLine(buf, 319); 384 buf[319] = '\0'; 385 if (strncmp(buf,"ZZZZZ",5) == 0) { ok=false; break; } 386 j = posc(buf+2, ' ')+2; 387 buf[j] = '\0'; 388 switch (buf[0]) 389 { 390 case 'I' : 391 iv = (int_4)atol(buf+j+1); 392 dobj->SetI(buf+2, iv); 393 break; 394 case 'D' : 395 dv = atof(buf+j+1); 396 dobj->SetD(buf+2, dv); 397 break; 398 case 'S' : 399 dobj->SetS(buf+2, buf+j+1); 400 break; 401 default : 402 break; 403 } 404 } 405 } 406 407 #ifdef __CXX_PRAGMA_TEMPLATES__ 408 #pragma define_template ObjFileIO<DVList> 409 #endif 410 411 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 412 template class ObjFileIO<DVList>; 413 #endif -
trunk/SophyaLib/NTools/dvlist.h
r220 r278 6 6 #define DVLIST_H_SEEN 7 7 8 #include " ppersist.h"8 #include "objfio.h" 9 9 10 10 #include <stdio.h> … … 21 21 #include <map.h> 22 22 #endif 23 24 namespace PlanckDPC { 23 25 24 26 // Classe utilitaire pour manipuler des variables typees … … 66 68 // Classe liste de variables Dynamic Variable List 67 69 68 class DVList : public PPersist{70 class DVList : public AnyDataObj { 69 71 public: 70 enum {classId = ClassId_DVList };72 // enum {classId = ClassId_DVList }; 71 73 72 74 DVList(); … … 97 99 inline void Print() const { Print(cout); } 98 100 virtual void Print(ostream& os) const; 101 102 typedef map<string, MuTyV, less<string> > ValList; 103 inline ValList::const_iterator Begin() { return(mvlist.begin()); } 104 inline ValList::const_iterator End() { return(mvlist.end()); } 99 105 100 int_4 ClassId() const { return classId; }101 static PPersist* Create() { return new DVList;}106 // int_4 ClassId() const { return classId; } 107 // static PPersist* Create() { return new DVList;} 102 108 103 virtual void WriteSelf(POutPersist&) const;104 virtual void ReadSelf(PInPersist&);109 // virtual void WriteSelf(POutPersist&) const; 110 // virtual void ReadSelf(PInPersist&); 105 111 106 112 private: 107 typedef map<string, MuTyV, less<string> > ValList;108 113 109 114 ValList mvlist; … … 114 119 { dvl.Print(s); return(s); } 115 120 121 inline POutPersist& operator << (POutPersist& os, DVList & obj) 122 { ObjFileIO<DVList> fio(&obj); fio.Write(os); return(os); } 123 inline PInPersist& operator >> (PInPersist& is, DVList & obj) 124 { ObjFileIO<DVList> fio(&obj); fio.Read(is); return(is); } 125 126 // Classe pour la gestion de persistance 127 // ObjFileIO<DVList> 128 129 } // namespace PlanckDPC 130 116 131 #endif /* DVLIST_H__SEEN */ 117 132 -
trunk/SophyaLib/NTools/ntuple.cc
r220 r278 311 311 s.PutI4(mBlk); 312 312 s.PutI4(mNBlk); 313 if (mInfo) mInfo->Write(s);313 if (mInfo) s << (*mInfo); 314 314 int jb; 315 315 for(jb=0; jb<mNBlk; jb++) … … 344 344 if (hadinfo) { // Lecture eventuelle du DVList Info 345 345 if (mInfo == NULL) mInfo = new DVList; 346 mInfo->Read(s);346 s >> (*mInfo); 347 347 } 348 348 -
trunk/SophyaLib/NTools/outilsinit.cc
r244 r278 34 34 PPRegister(Poly); 35 35 PPRegister(Poly2); 36 PPRegister( DVList);36 PPRegister(ObjFileIO<DVList>); 37 37 PPRegister(Histo); 38 38 PPRegister(Histo2D); -
trunk/SophyaLib/NTools/rzimage.cc
r270 r278 5 5 // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA 6 6 7 // $Id: rzimage.cc,v 1. 3 1999-04-27 15:03:02ansari Exp $7 // $Id: rzimage.cc,v 1.4 1999-04-28 13:36:50 ansari Exp $ 8 8 9 9 #include "machdefs.h" … … 602 602 } 603 603 604 if (mInfo) mInfo->Write(s);604 if (mInfo) s << (*mInfo); 605 605 return; 606 606 } … … 667 667 if (itab[3]) // has info 668 668 { if (mInfo == NULL) mInfo = new DVList; 669 mInfo->Read(s); }669 s >> (*mInfo); } 670 670 671 671 return;
Note:
See TracChangeset
for help on using the changeset viewer.