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

Last change on this file since 2703 was 2698, checked in by ansari, 20 years ago

1/ Simplification de la classe gestionnairee PPersist ObjFile<T> (objfio.h)
2/ Ajout DECL_TEMP_SPEC ds ppftpointerio.h
3/ Nom specifique pour methode SegDBInterface::GetSegment() const devenu
SegDBInterface::GetCstSegment() const pour eviter l'appel a la methode non const
et adapatation classes derivees (segdatablock.h et swsegdb.h)
4/ Ajout SkipToNextObjet() ds PInPersist::ReadObject() (ppersist.cc) et protection contre pointeur NULL -> new DVList pour la lecture PPersist de DVList

Reza - 27 Avril 2005

File size: 4.4 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
40class PPF_TPointer_IO<char> {
41public:
42 static void Write(POutPersist & os, char const * arr, size_t n);
43 static void Read(PInPersist & is, char * arr, size_t n);
44};
45
46DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
47class PPF_TPointer_IO<int_1> {
48public:
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};
52DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
53class PPF_TPointer_IO<uint_1> {
54public:
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
59DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
60class PPF_TPointer_IO<int_2> {
61public:
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};
65DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
66class PPF_TPointer_IO<uint_2> {
67public:
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
72DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
73class PPF_TPointer_IO<int_4> {
74public:
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};
78DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
79class PPF_TPointer_IO<uint_4> {
80public:
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
85DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
86class PPF_TPointer_IO<int_8> {
87public:
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};
91DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
92class PPF_TPointer_IO<uint_8> {
93public:
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
98DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
99class PPF_TPointer_IO<r_4> {
100public:
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};
104DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
105class PPF_TPointer_IO<r_8> {
106public:
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
111DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
112class PPF_TPointer_IO< complex<r_4> > {
113public:
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};
117DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
118class PPF_TPointer_IO< complex<r_8> > {
119public:
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
124} // namespace SOPHYA
125
126#endif /* PPFTPOINTERIO_H_SEEN */
Note: See TracBrowser for help on using the repository browser.