source: Sophya/trunk/SophyaLib/BaseTools/ppftpointerio.h@ 2760

Last change on this file since 2760 was 2704, checked in by ansari, 20 years ago

Ajout/suppression de DECL_TEMP_SPEC ds ppftpointerio.cc .h pour compil sur SGI-CC , Reza 27/04/2005

File size: 4.5 KB
Line 
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//----------------------------------------------------------------------
11namespace 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
24template <class T>
25class PPF_TPointer_IO {
26public:
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
40DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
41class PPF_TPointer_IO<char> {
42public:
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
47DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
48class PPF_TPointer_IO<int_1> {
49public:
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};
53DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
54class PPF_TPointer_IO<uint_1> {
55public:
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
60DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
61class PPF_TPointer_IO<int_2> {
62public:
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};
66DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
67class PPF_TPointer_IO<uint_2> {
68public:
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
73DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
74class PPF_TPointer_IO<int_4> {
75public:
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};
79DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
80class PPF_TPointer_IO<uint_4> {
81public:
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
86DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
87class PPF_TPointer_IO<int_8> {
88public:
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};
92DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
93class PPF_TPointer_IO<uint_8> {
94public:
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
99DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
100class PPF_TPointer_IO<r_4> {
101public:
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};
105DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
106class PPF_TPointer_IO<r_8> {
107public:
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
112DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
113class PPF_TPointer_IO< complex<r_4> > {
114public:
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};
118DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
119class PPF_TPointer_IO< complex<r_8> > {
120public:
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 */
Note: See TracBrowser for help on using the repository browser.