source: Sophya/trunk/Poubelle/DPC:FitsIOServer/SysTools/objfio.h@ 658

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

no message

File size: 1.3 KB
RevLine 
[658]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
13namespace SOPHYA {
14
15
16template <class T>
17class ObjFileIO : public PPersist {
18
19public :
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; }
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;
35 bool ownobj; // True si dobj obtenu par new
36};
37
38/*
39template <class T>
40inline POutPersist& operator << (POutPersist& os, T const & obj)
41{ ObjFileIO<T> fio((const_cast)&obj); fio.Write(os); return(os); }
42
43template <class T>
44inline PInPersist& operator >> (PInPersist& is, T & obj)
45{ ObjFileIO<T> fio(&obj); fio.Read(is); return(is); }
46*/
47
48
49} // Fin namespace
50
51#endif
Note: See TracBrowser for help on using the repository browser.