[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 | /*!
|
---|
| 12 | \class SOPHYA::PPF_TPointer_IO
|
---|
| 13 | \ingroup BaseTools
|
---|
| 14 | A template utility class with static methods to ease handling of array
|
---|
| 15 | I/O in PPF streams (POutPersist and PInPersist). It is not intented for
|
---|
| 16 | direct use in user programs, but for writing PPF persistence handler
|
---|
| 17 | classes (PPersist).
|
---|
| 18 | The C++ I/O operators POutPersist& << and PInPersist& >> should be defined for
|
---|
| 19 | new types and classes.
|
---|
| 20 | */
|
---|
| 21 |
|
---|
[2805] | 22 | namespace SOPHYA {
|
---|
| 23 |
|
---|
[2660] | 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 |
|
---|
[2805] | 39 | //! \cond
|
---|
[2695] | 40 | // declaration specifique pour ecriture sous forme de tableaux PPF
|
---|
[2704] | 41 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 42 | class PPF_TPointer_IO<char> {
|
---|
| 43 | public:
|
---|
| 44 | static void Write(POutPersist & os, char const * arr, size_t n);
|
---|
| 45 | static void Read(PInPersist & is, char * arr, size_t n);
|
---|
| 46 | };
|
---|
[2660] | 47 |
|
---|
[2698] | 48 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 49 | class PPF_TPointer_IO<int_1> {
|
---|
| 50 | public:
|
---|
| 51 | static void Write(POutPersist & os, int_1 const * arr, size_t n);
|
---|
| 52 | static void Read(PInPersist & is, int_1 * arr, size_t n);
|
---|
| 53 | };
|
---|
[2698] | 54 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 55 | class PPF_TPointer_IO<uint_1> {
|
---|
| 56 | public:
|
---|
| 57 | static void Write(POutPersist & os, uint_1 const * arr, size_t n);
|
---|
| 58 | static void Read(PInPersist & is, uint_1 * arr, size_t n);
|
---|
| 59 | };
|
---|
| 60 |
|
---|
[2698] | 61 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 62 | class PPF_TPointer_IO<int_2> {
|
---|
| 63 | public:
|
---|
| 64 | static void Write(POutPersist & os, int_2 const * arr, size_t n);
|
---|
| 65 | static void Read(PInPersist & is, int_2 * arr, size_t n);
|
---|
| 66 | };
|
---|
[2698] | 67 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 68 | class PPF_TPointer_IO<uint_2> {
|
---|
| 69 | public:
|
---|
| 70 | static void Write(POutPersist & os, uint_2 const * arr, size_t n);
|
---|
| 71 | static void Read(PInPersist & is, uint_2 * arr, size_t n);
|
---|
| 72 | };
|
---|
| 73 |
|
---|
[2698] | 74 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 75 | class PPF_TPointer_IO<int_4> {
|
---|
| 76 | public:
|
---|
| 77 | static void Write(POutPersist & os, int_4 const * arr, size_t n);
|
---|
| 78 | static void Read(PInPersist & is, int_4 * arr, size_t n);
|
---|
| 79 | };
|
---|
[2698] | 80 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 81 | class PPF_TPointer_IO<uint_4> {
|
---|
| 82 | public:
|
---|
| 83 | static void Write(POutPersist & os, uint_4 const * arr, size_t n);
|
---|
| 84 | static void Read(PInPersist & is, uint_4 * arr, size_t n);
|
---|
| 85 | };
|
---|
| 86 |
|
---|
[2698] | 87 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 88 | class PPF_TPointer_IO<int_8> {
|
---|
| 89 | public:
|
---|
| 90 | static void Write(POutPersist & os, int_8 const * arr, size_t n);
|
---|
| 91 | static void Read(PInPersist & is, int_8 * arr, size_t n);
|
---|
| 92 | };
|
---|
[2698] | 93 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 94 | class PPF_TPointer_IO<uint_8> {
|
---|
| 95 | public:
|
---|
| 96 | static void Write(POutPersist & os, uint_8 const * arr, size_t n);
|
---|
| 97 | static void Read(PInPersist & is, uint_8 * arr, size_t n);
|
---|
| 98 | };
|
---|
| 99 |
|
---|
[2698] | 100 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 101 | class PPF_TPointer_IO<r_4> {
|
---|
| 102 | public:
|
---|
| 103 | static void Write(POutPersist & os, r_4 const * arr, size_t n);
|
---|
| 104 | static void Read(PInPersist & is, r_4 * arr, size_t n);
|
---|
| 105 | };
|
---|
[2698] | 106 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 107 | class PPF_TPointer_IO<r_8> {
|
---|
| 108 | public:
|
---|
| 109 | static void Write(POutPersist & os, r_8 const * arr, size_t n);
|
---|
| 110 | static void Read(PInPersist & is, r_8 * arr, size_t n);
|
---|
| 111 | };
|
---|
| 112 |
|
---|
[2698] | 113 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 114 | class PPF_TPointer_IO< complex<r_4> > {
|
---|
| 115 | public:
|
---|
| 116 | static void Write(POutPersist & os, complex<r_4> const * arr, size_t n);
|
---|
| 117 | static void Read(PInPersist & is, complex<r_4> * arr, size_t n);
|
---|
| 118 | };
|
---|
[2698] | 119 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2695] | 120 | class PPF_TPointer_IO< complex<r_8> > {
|
---|
| 121 | public:
|
---|
| 122 | static void Write(POutPersist & os, complex<r_8> const * arr, size_t n);
|
---|
| 123 | static void Read(PInPersist & is, complex<r_8> * arr, size_t n);
|
---|
| 124 | };
|
---|
| 125 |
|
---|
[2805] | 126 | //! \endcond
|
---|
[2660] | 127 | } // namespace SOPHYA
|
---|
| 128 |
|
---|
| 129 | #endif /* PPFTPOINTERIO_H_SEEN */
|
---|