[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 |
|
---|
[2698] | 46 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 47 | class PPF_TPointer_IO<int_1> {
|
---|
| 48 | public:
|
---|
| 49 | static void Write(POutPersist & os, int_1 const * arr, size_t n);
|
---|
| 50 | static void Read(PInPersist & is, int_1 * arr, size_t n);
|
---|
| 51 | };
|
---|
[2698] | 52 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 53 | class PPF_TPointer_IO<uint_1> {
|
---|
| 54 | public:
|
---|
| 55 | static void Write(POutPersist & os, uint_1 const * arr, size_t n);
|
---|
| 56 | static void Read(PInPersist & is, uint_1 * arr, size_t n);
|
---|
| 57 | };
|
---|
| 58 |
|
---|
[2698] | 59 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 60 | class PPF_TPointer_IO<int_2> {
|
---|
| 61 | public:
|
---|
| 62 | static void Write(POutPersist & os, int_2 const * arr, size_t n);
|
---|
| 63 | static void Read(PInPersist & is, int_2 * arr, size_t n);
|
---|
| 64 | };
|
---|
[2698] | 65 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 66 | class PPF_TPointer_IO<uint_2> {
|
---|
| 67 | public:
|
---|
| 68 | static void Write(POutPersist & os, uint_2 const * arr, size_t n);
|
---|
| 69 | static void Read(PInPersist & is, uint_2 * arr, size_t n);
|
---|
| 70 | };
|
---|
| 71 |
|
---|
[2698] | 72 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 73 | class PPF_TPointer_IO<int_4> {
|
---|
| 74 | public:
|
---|
| 75 | static void Write(POutPersist & os, int_4 const * arr, size_t n);
|
---|
| 76 | static void Read(PInPersist & is, int_4 * arr, size_t n);
|
---|
| 77 | };
|
---|
[2698] | 78 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 79 | class PPF_TPointer_IO<uint_4> {
|
---|
| 80 | public:
|
---|
| 81 | static void Write(POutPersist & os, uint_4 const * arr, size_t n);
|
---|
| 82 | static void Read(PInPersist & is, uint_4 * arr, size_t n);
|
---|
| 83 | };
|
---|
| 84 |
|
---|
[2698] | 85 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 86 | class PPF_TPointer_IO<int_8> {
|
---|
| 87 | public:
|
---|
| 88 | static void Write(POutPersist & os, int_8 const * arr, size_t n);
|
---|
| 89 | static void Read(PInPersist & is, int_8 * arr, size_t n);
|
---|
| 90 | };
|
---|
[2698] | 91 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 92 | class PPF_TPointer_IO<uint_8> {
|
---|
| 93 | public:
|
---|
| 94 | static void Write(POutPersist & os, uint_8 const * arr, size_t n);
|
---|
| 95 | static void Read(PInPersist & is, uint_8 * arr, size_t n);
|
---|
| 96 | };
|
---|
| 97 |
|
---|
[2698] | 98 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 99 | class PPF_TPointer_IO<r_4> {
|
---|
| 100 | public:
|
---|
| 101 | static void Write(POutPersist & os, r_4 const * arr, size_t n);
|
---|
| 102 | static void Read(PInPersist & is, r_4 * arr, size_t n);
|
---|
| 103 | };
|
---|
[2698] | 104 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 105 | class PPF_TPointer_IO<r_8> {
|
---|
| 106 | public:
|
---|
| 107 | static void Write(POutPersist & os, r_8 const * arr, size_t n);
|
---|
| 108 | static void Read(PInPersist & is, r_8 * arr, size_t n);
|
---|
| 109 | };
|
---|
| 110 |
|
---|
[2698] | 111 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 112 | class PPF_TPointer_IO< complex<r_4> > {
|
---|
| 113 | public:
|
---|
| 114 | static void Write(POutPersist & os, complex<r_4> const * arr, size_t n);
|
---|
| 115 | static void Read(PInPersist & is, complex<r_4> * arr, size_t n);
|
---|
| 116 | };
|
---|
[2698] | 117 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 118 | class PPF_TPointer_IO< complex<r_8> > {
|
---|
| 119 | public:
|
---|
| 120 | static void Write(POutPersist & os, complex<r_8> const * arr, size_t n);
|
---|
| 121 | static void Read(PInPersist & is, complex<r_8> * arr, size_t n);
|
---|
| 122 | };
|
---|
| 123 |
|
---|
[2660] | 124 | } // namespace SOPHYA
|
---|
| 125 |
|
---|
| 126 | #endif /* PPFTPOINTERIO_H_SEEN */
|
---|