| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | //      template array class for numerical types | 
|---|
| 3 | //                     R. Ansari, C.Magneville   03/2000 | 
|---|
| 4 |  | 
|---|
| 5 | #ifndef FIOTArray_SEEN | 
|---|
| 6 | #define FIOTArray_SEEN | 
|---|
| 7 |  | 
|---|
| 8 | #include "machdefs.h" | 
|---|
| 9 | #include <iostream> | 
|---|
| 10 | #include "tarray.h" | 
|---|
| 11 | #include "tmatrix.h" | 
|---|
| 12 | #include "tvector.h" | 
|---|
| 13 | #include "ppersist.h" | 
|---|
| 14 |  | 
|---|
| 15 | namespace SOPHYA { | 
|---|
| 16 | ///////////////////////////////////////////////////////////////////////// | 
|---|
| 17 | // Gestionnaire PPF de TArray<T>, ainsi que TMatrix<T>/TVector<T> | 
|---|
| 18 | ///////////////////////////////////////////////////////////////////////// | 
|---|
| 19 | template <class T> | 
|---|
| 20 | class FIO_TArray : public  PPersist  { | 
|---|
| 21 | public: | 
|---|
| 22 | FIO_TArray(); | 
|---|
| 23 | FIO_TArray(string const & filename); | 
|---|
| 24 | FIO_TArray(const TArray<T> & obj); | 
|---|
| 25 | FIO_TArray(TArray<T> * obj); | 
|---|
| 26 | virtual ~FIO_TArray(); | 
|---|
| 27 | virtual AnyDataObj* DataObj(); | 
|---|
| 28 | virtual void        SetDataObj(AnyDataObj & o); | 
|---|
| 29 | inline operator TArray<T>() { return(*dobj); } | 
|---|
| 30 | protected : | 
|---|
| 31 | virtual void ReadSelf(PInPersist&); | 
|---|
| 32 | virtual void WriteSelf(POutPersist&) const; | 
|---|
| 33 | TArray<T> * dobj; //!< Pointer to the connected TArray | 
|---|
| 34 | bool ownobj; //!< true if the connected object belong to the class | 
|---|
| 35 | }; | 
|---|
| 36 |  | 
|---|
| 37 | /*! \ingroup TArray \fn operator<<(POutPersist&,TArray<T>&) | 
|---|
| 38 | \brief Write TArray \b obj into POutPersist stream \b os */ | 
|---|
| 39 | template <class T> | 
|---|
| 40 | inline POutPersist& operator << (POutPersist& os, TArray<T> & obj) | 
|---|
| 41 | { FIO_TArray<T> fio(&obj);  fio.Write(os);  return(os); } | 
|---|
| 42 |  | 
|---|
| 43 | /*! \ingroup TArray \fn operator>>(PInPersist&,TArray<T>&) | 
|---|
| 44 | \brief Read TArray \b obj from PInPersist stream \b os */ | 
|---|
| 45 | template <class T> | 
|---|
| 46 | inline PInPersist& operator >> (PInPersist& is, TArray<T> & obj) | 
|---|
| 47 | { FIO_TArray<T> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); } | 
|---|
| 48 |  | 
|---|
| 49 |  | 
|---|
| 50 | } // Fin du namespace | 
|---|
| 51 |  | 
|---|
| 52 | #endif | 
|---|