source: Sophya/trunk/SophyaProg/Examples/MyPPF/vfs.h

Last change on this file was 3420, checked in by ansari, 18 years ago

Ajout du repetoire MyPPF (exemple de handler PPersist) dans le module Example - Reza 07/12/2007

File size: 1.6 KB
RevLine 
[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
21class Vfs : public SOPHYA::AnyDataObj {
22public:
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 ;
43inline ostream& operator << (ostream& s, Vfs const & x)
44 { x.Print(s); return(s); }
45
46/* Writes the object in the POutPersist stream os */
47inline 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 */
50inline 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
Note: See TracBrowser for help on using the repository browser.