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