source: Sophya/trunk/SophyaLib/BaseTools/objfio.h@ 552

Last change on this file since 552 was 552, checked in by ansari, 26 years ago

namespace changed to SOPHYA cmv 5/11/99

File size: 1.3 KB
RevLine 
[269]1// This may look like C code, but it is really -*- C++ -*-
2// Classe de gestion des I/O fichiers des objets
3// R.Ansari 04/99
4// LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
5
6#ifndef OBJFILEIO_H_SEEN
7#define OBJFILEIO_H_SEEN
8
9#include "machdefs.h"
10#include "anydataobj.h"
11#include "ppersist.h"
12
[552]13namespace SOPHYA {
[269]14
15
16template <class T>
17class ObjFileIO : public PPersist {
18
19public :
[277]20 ObjFileIO() { dobj=new T; ownobj=true; }
21 ObjFileIO(string const & filename)
22 { dobj=new T; ownobj=true; Read(filename); }
23 ObjFileIO(const T & obj) { dobj = new T(obj); ownobj=true; }
24 ObjFileIO(T * obj) { dobj = obj; ownobj=false; }
25 virtual ~ObjFileIO() { if (ownobj && dobj) delete dobj; }
[269]26
27 virtual AnyDataObj* DataObj() { return(dobj); }
28 inline operator T() { return(*dobj); }
29
30protected :
31 virtual void ReadSelf(PInPersist&);
32 virtual void WriteSelf(POutPersist&) const;
33
34 T * dobj;
[277]35 bool ownobj; // True si dobj obtenu par new
[269]36};
37
[277]38/*
39template <class T>
40inline POutPersist& operator << (POutPersist& os, T const & obj)
41{ ObjFileIO<T> fio((const_cast)&obj); fio.Write(os); return(os); }
[269]42
[277]43template <class T>
44inline PInPersist& operator >> (PInPersist& is, T & obj)
45{ ObjFileIO<T> fio(&obj); fio.Read(is); return(is); }
46*/
[269]47
48
49} // Fin namespace
50
51#endif
Note: See TracBrowser for help on using the repository browser.