| 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 |
|
|---|
| 22 | namespace SOPHYA {
|
|---|
| 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 | //! \cond
|
|---|
| 40 | // declaration specifique pour ecriture sous forme de tableaux PPF
|
|---|
| 41 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 47 |
|
|---|
| 48 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 54 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 |
|
|---|
| 61 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 67 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 |
|
|---|
| 74 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 80 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 |
|
|---|
| 87 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 93 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 |
|
|---|
| 100 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 106 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 |
|
|---|
| 113 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 | };
|
|---|
| 119 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
|---|
| 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 |
|
|---|
| 126 | //! \endcond
|
|---|
| 127 | } // namespace SOPHYA
|
|---|
| 128 |
|
|---|
| 129 | #endif /* PPFTPOINTERIO_H_SEEN */
|
|---|