[3420] | 1 | #ifndef VFS_H_SEEN
|
---|
| 2 | #define VFS_H_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "machdefs.h"
|
---|
| 5 |
|
---|
| 6 | #include <string>
|
---|
| 7 | #include <vector>
|
---|
| 8 |
|
---|
| 9 | #include "ndatablock.h"
|
---|
| 10 | #include "objfio.h"
|
---|
| 11 |
|
---|
| 12 | //------------------------------------------------------
|
---|
| 13 | // An example to illustrate how to make a class
|
---|
| 14 | // persistent using the SOPHYA PPF services
|
---|
| 15 | // (C) LAL-IN2P3/CNRS (C) DAPNIA-SPP/CEA
|
---|
| 16 | // ----------------------------------------------------
|
---|
| 17 |
|
---|
| 18 | // A simple class to hold pairs(float, string)
|
---|
| 19 | // we want to make this class persistent using SOPHYA PPF services
|
---|
| 20 |
|
---|
| 21 | class Vfs : public SOPHYA::AnyDataObj {
|
---|
| 22 | public:
|
---|
| 23 | // We need a default constructor , if we want to use the ObjFileIO<Vfs> class
|
---|
| 24 | Vfs(int sz=10);
|
---|
| 25 | virtual ~Vfs() { };
|
---|
| 26 |
|
---|
| 27 | // Setting element k
|
---|
| 28 | void Set(int k, r_4 fv, string const sv);
|
---|
| 29 | // Accessing float part of element k
|
---|
| 30 | r_4 GetF(int k);
|
---|
| 31 | // Accessing string part of element k
|
---|
| 32 | string GetS(int k);
|
---|
| 33 | // display/print object content
|
---|
| 34 | void Print(ostream& os) const ;
|
---|
| 35 | // For persistence handling
|
---|
| 36 | friend class SOPHYA::ObjFileIO<Vfs> ;
|
---|
| 37 | private:
|
---|
| 38 | SOPHYA::NDataBlock<r_4> mFVal;
|
---|
| 39 | vector<string> mSVal;
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | // For easy printing of Vfs through cout << x ;
|
---|
| 43 | inline ostream& operator << (ostream& s, Vfs const & x)
|
---|
| 44 | { x.Print(s); return(s); }
|
---|
| 45 |
|
---|
| 46 | /* Writes the object in the POutPersist stream os */
|
---|
| 47 | inline SOPHYA::POutPersist& operator << (SOPHYA::POutPersist& os, Vfs & obj)
|
---|
| 48 | { SOPHYA::ObjFileIO<Vfs> fio(&obj); fio.Write(os); return(os); }
|
---|
| 49 | /* Reads the object from the PInPersist stream is */
|
---|
| 50 | inline SOPHYA::PInPersist& operator >> (SOPHYA::PInPersist& is, Vfs & obj)
|
---|
| 51 | { SOPHYA::ObjFileIO<Vfs> fio(&obj); fio.Read(is); return(is); }
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 |
|
---|