[2660] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Classe pour faciliter entree-sortie PPF pour des pointeurs
|
---|
| 3 | // R. Ansari - Mars 2005
|
---|
| 4 |
|
---|
| 5 | #ifndef PPFTPOINTERIO_H_SEEN
|
---|
| 6 | #define PPFTPOINTERIO_H_SEEN
|
---|
| 7 |
|
---|
| 8 | #include "ppersist.h"
|
---|
| 9 |
|
---|
| 10 | //----------------------------------------------------------------------
|
---|
| 11 | namespace SOPHYA {
|
---|
| 12 |
|
---|
| 13 | /*!
|
---|
| 14 | \class SOPHYA::PPF_TPointer_IO
|
---|
| 15 | \ingroup BaseTools
|
---|
| 16 | A template utility class with static methods to ease handling of array
|
---|
| 17 | I/O in PPF streams (POutPersist and PInPersist). It is not intented for
|
---|
| 18 | direct use in user programs, but for writing PPF persistence handler
|
---|
| 19 | classes (PPersist).
|
---|
| 20 | The C++ I/O operators POutPersist& << and PInPersist& >> should be defined for
|
---|
| 21 | new types and classes.
|
---|
| 22 | */
|
---|
| 23 |
|
---|
| 24 | template <class T>
|
---|
| 25 | class PPF_TPointer_IO {
|
---|
| 26 | public:
|
---|
| 27 | //! Writes the array pointed to by \b arr (size \b n) to POutPersist stream \b os
|
---|
| 28 | static void Write(POutPersist & os, T const * arr, size_t n)
|
---|
| 29 | {
|
---|
| 30 | for(size_t k=0; k<n; k++) os << arr[k];
|
---|
| 31 | }
|
---|
| 32 | //! Reads from the PInPersist \b is into array pointed to by \b arr (size \b n)
|
---|
| 33 | static void Read(PInPersist & is, T * arr, size_t n)
|
---|
| 34 | {
|
---|
| 35 | for(size_t k=0; k<n; k++) is >> arr[k];
|
---|
| 36 | }
|
---|
| 37 | };
|
---|
| 38 |
|
---|
[2695] | 39 | // declaration specifique pour ecriture sous forme de tableaux PPF
|
---|
| 40 | class PPF_TPointer_IO<char> {
|
---|
| 41 | public:
|
---|
| 42 | static void Write(POutPersist & os, char const * arr, size_t n);
|
---|
| 43 | static void Read(PInPersist & is, char * arr, size_t n);
|
---|
| 44 | };
|
---|
[2660] | 45 |
|
---|
[2695] | 46 | class PPF_TPointer_IO<int_1> {
|
---|
| 47 | public:
|
---|
| 48 | static void Write(POutPersist & os, int_1 const * arr, size_t n);
|
---|
| 49 | static void Read(PInPersist & is, int_1 * arr, size_t n);
|
---|
| 50 | };
|
---|
| 51 | class PPF_TPointer_IO<uint_1> {
|
---|
| 52 | public:
|
---|
| 53 | static void Write(POutPersist & os, uint_1 const * arr, size_t n);
|
---|
| 54 | static void Read(PInPersist & is, uint_1 * arr, size_t n);
|
---|
| 55 | };
|
---|
| 56 |
|
---|
| 57 | class PPF_TPointer_IO<int_2> {
|
---|
| 58 | public:
|
---|
| 59 | static void Write(POutPersist & os, int_2 const * arr, size_t n);
|
---|
| 60 | static void Read(PInPersist & is, int_2 * arr, size_t n);
|
---|
| 61 | };
|
---|
| 62 | class PPF_TPointer_IO<uint_2> {
|
---|
| 63 | public:
|
---|
| 64 | static void Write(POutPersist & os, uint_2 const * arr, size_t n);
|
---|
| 65 | static void Read(PInPersist & is, uint_2 * arr, size_t n);
|
---|
| 66 | };
|
---|
| 67 |
|
---|
| 68 | class PPF_TPointer_IO<int_4> {
|
---|
| 69 | public:
|
---|
| 70 | static void Write(POutPersist & os, int_4 const * arr, size_t n);
|
---|
| 71 | static void Read(PInPersist & is, int_4 * arr, size_t n);
|
---|
| 72 | };
|
---|
| 73 | class PPF_TPointer_IO<uint_4> {
|
---|
| 74 | public:
|
---|
| 75 | static void Write(POutPersist & os, uint_4 const * arr, size_t n);
|
---|
| 76 | static void Read(PInPersist & is, uint_4 * arr, size_t n);
|
---|
| 77 | };
|
---|
| 78 |
|
---|
| 79 | class PPF_TPointer_IO<int_8> {
|
---|
| 80 | public:
|
---|
| 81 | static void Write(POutPersist & os, int_8 const * arr, size_t n);
|
---|
| 82 | static void Read(PInPersist & is, int_8 * arr, size_t n);
|
---|
| 83 | };
|
---|
| 84 | class PPF_TPointer_IO<uint_8> {
|
---|
| 85 | public:
|
---|
| 86 | static void Write(POutPersist & os, uint_8 const * arr, size_t n);
|
---|
| 87 | static void Read(PInPersist & is, uint_8 * arr, size_t n);
|
---|
| 88 | };
|
---|
| 89 |
|
---|
| 90 | class PPF_TPointer_IO<r_4> {
|
---|
| 91 | public:
|
---|
| 92 | static void Write(POutPersist & os, r_4 const * arr, size_t n);
|
---|
| 93 | static void Read(PInPersist & is, r_4 * arr, size_t n);
|
---|
| 94 | };
|
---|
| 95 | class PPF_TPointer_IO<r_8> {
|
---|
| 96 | public:
|
---|
| 97 | static void Write(POutPersist & os, r_8 const * arr, size_t n);
|
---|
| 98 | static void Read(PInPersist & is, r_8 * arr, size_t n);
|
---|
| 99 | };
|
---|
| 100 |
|
---|
| 101 | class PPF_TPointer_IO< complex<r_4> > {
|
---|
| 102 | public:
|
---|
| 103 | static void Write(POutPersist & os, complex<r_4> const * arr, size_t n);
|
---|
| 104 | static void Read(PInPersist & is, complex<r_4> * arr, size_t n);
|
---|
| 105 | };
|
---|
| 106 | class PPF_TPointer_IO< complex<r_8> > {
|
---|
| 107 | public:
|
---|
| 108 | static void Write(POutPersist & os, complex<r_8> const * arr, size_t n);
|
---|
| 109 | static void Read(PInPersist & is, complex<r_8> * arr, size_t n);
|
---|
| 110 | };
|
---|
| 111 |
|
---|
[2660] | 112 | } // namespace SOPHYA
|
---|
| 113 |
|
---|
| 114 | #endif /* PPFTPOINTERIO_H_SEEN */
|
---|