source: Sophya/trunk/SophyaProg/Examples/MyPPF/tvfs.cc@ 4057

Last change on this file since 4057 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.7 KB
Line 
1#include "machdefs.h"
2
3#include <iostream>
4
5#include "pexceptions.h"
6#include "vfs.h"
7
8//------------------------------------------------------
9// An example to illustrate how to make a class
10// persistent using the SOPHYA PPF services
11// (C) LAL-IN2P3/CNRS (C) DAPNIA-SPP/CEA
12// ----------------------------------------------------
13
14using namespace SOPHYA;
15
16//--- The main program ----
17
18int main(int narg, char* arg[])
19{
20
21 cout << " --------- tvfs.cc test of class Vfs and ObjFileIO<Vfs> ---------- "
22 << endl;
23
24 // We have to register the PPersist handler for our class Vfs
25 // This should be performed at initialization
26 // The following two lines (CPP macros) do the job :
27
28 // First, register the PPF handler ObjFileIO<Vfs>
29 PPRegister(ObjFileIO<Vfs>);
30 // Register the list of classes which can be handled by ObjFileIO<Vfs>
31 DObjRegister(ObjFileIO<Vfs>, Vfs);
32
33
34 try {
35 Vfs xa(5);
36 xa.Set(0, 0., "Zero");
37 xa.Set(1, 1., "Un");
38 xa.Set(2, 2., "Deux");
39 xa.Set(3, 3., "Trois");
40 xa.Set(4, 4., "Quatre");
41 cout << xa ;
42 {
43 // We save our objet ito a POutPersist flow
44 POutPersist po("tvfs.ppf");
45 po << xa;
46 }
47 {
48 // We try to read in the saved Vfs xa object
49 Vfs xb;
50 cout << " Vfs xb before reading : \n " << xb << endl;
51 PInPersist pi("tvfs.ppf");
52 pi >> xb;
53 cout << " After reading pi >> xb : \n " << xb << endl;
54 }
55
56 }
57
58 catch (PThrowable & pex) {
59 cerr << " tvfs.cc/Error - Exception catched " << (string)typeid(pex).name()
60 << " - Msg= " << pex.Msg() << endl;
61 }
62 catch (...) {
63 cerr << " tx.cc/Error - Exception (...) catched " << endl;
64 }
65
66 cout << " ----------- End of tx.cc ------------- " << endl;
67
68 return(0);
69
70}
Note: See TracBrowser for help on using the repository browser.