source: XMLIO_V2/dev/dev_rv/src4/xmlio/buffer/linear_buffer.hpp @ 264

Last change on this file since 264 was 264, checked in by hozdoba, 13 years ago

Ajout de classes pour la version 4

File size: 5.6 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4 
5#ifndef __LINEAR_BUFFER_HPP__
6#define __LINEAR_BUFFER_HPP__
7
8#ifndef __XIOS_NO_EXTERN
9
10// C++ standard headers
11#include <vector>
12
13#endif // __XIOS_NO_EXTERN
14
15// XMLIOServer headers
16#include "xmlioserver_spl.hpp"
17#include "buffer.hpp"
18
19// ////////////////////////////// Déclarations ///////////////////////////// //
20
21#define _NULL_ARG xmlioserver::comm::CLinearBuffer::NULL_ARG
22
23namespace xmlioserver
24{
25   namespace comm
26   {
27      class CLinearBuffer : public CBuffer
28      {
29         public : // Définition de type
30
31            typedef CBuffer SuperClass;
32
33         public :
34
35            static long int * NULL_ARG;
36            friend class CMPIManager;
37
38         public :// Construteurs
39
40
41            explicit CLinearBuffer(std::size_t size = 1E5);
42            CLinearBuffer(char * data, std::size_t _size);
43            CLinearBuffer(const CLinearBuffer & _lbuffer_ref);
44            CLinearBuffer(const CLinearBuffer * const _lbuffer_ptr);
45
46         public :// Accesseurs
47
48            std::size_t getUsedSize(void) const;
49            std::size_t getUnusedSize(void) const;
50
51            std::size_t getNumberOfStoredData(void) const;
52            std::vector<std::size_t> getPositionsOfStoredData(void) const;
53            std::vector<std::size_t> getSizesOfStoredData(void) const;
54            std::vector<std::pair<CBufferDataType, bool> > getTypesOfStoredData(void) const;
55
56         //--------------------------------------------------------------
57           
58            char     getChar  (std::size_t _position) const;
59            bool     getBool  (std::size_t _position) const;
60            float    getFloat (std::size_t _position) const;
61            double   getDouble(std::size_t _position) const;
62            long int getInt   (std::size_t _position) const;
63
64            std::string getString(std::size_t _position) const;
65
66            boost::shared_ptr<boost::multi_array<char, 1> >
67               getCharArray  (std::size_t _position) const;
68            boost::shared_ptr<boost::multi_array<bool, 1> >
69                getBoolArray  (std::size_t _position) const;
70            boost::shared_ptr<boost::multi_array<float, 1> >
71                getFloatArray (std::size_t _position) const;
72            boost::shared_ptr<boost::multi_array<double, 1> >
73                getDoubleArray(std::size_t _position) const;
74            boost::shared_ptr<boost::multi_array<long int, 1> >
75                getIntArray   (std::size_t _position) const;
76
77         //--------------------------------------------------------------
78
79            void getRequestInfos(std::size_t   _position,
80                                 long int    & _managerId,
81                                 long int    & _methodId,
82                                 long int    & _nbargs);
83
84         //--------------------------------------------------------------
85         public : // Mutateurs
86
87            void appendChar  (char     _value) ;
88            void appendBool  (bool     _value) ;
89            void appendFloat (float    _value) ;
90            void appendDouble(double   _value) ;
91            void appendInt   (long int _value) ;
92
93            void appendString(const std::string & _value) ;
94
95            void appendCharArray 
96               (boost::shared_ptr<boost::multi_array<char, 1> > _value) ;
97            void appendBoolArray 
98               (boost::shared_ptr<boost::multi_array<bool, 1> > _value) ;
99            void appendFloatArray 
100               (boost::shared_ptr<boost::multi_array<float, 1> > _value) ;
101            void appendDoubleArray
102               (boost::shared_ptr<boost::multi_array<double, 1> > _value) ;
103            void appendIntArray 
104             (boost::shared_ptr<boost::multi_array<long int, 1> > _value) ;
105
106         //--------------------------------------------------------------
107
108            void appendRequestInfos(const long int & _managerId,
109                                    const long int & _methodId,
110                                    const long int & _nbargs);
111
112         //--------------------------------------------------------------
113           
114            virtual void clear(void);
115
116         public :// Test ///
117            template <typename A1, typename A2, typename A3, typename A4>
118               inline std::size_t getRequestedSize(A1 * _arg1 = NULL_ARG,
119                                                   A2 * _arg2 = NULL_ARG,
120                                                   A3 * _arg3 = NULL_ARG,
121                                                   A4 * _arg4 = NULL_ARG) const;
122
123         public : // Sortie fichier ascii
124
125            virtual void printToTextFile (const std::string & _filename);
126            virtual void printToTextStream (std::ostream & _ostr);
127
128         public : // Destructeur
129
130            virtual ~CLinearBuffer(void);
131
132         protected : // Accesseurs protégés
133
134            template <class T>
135               inline void getLData
136                 (T & _data, std::size_t _position) const;
137                 
138            template <class T>
139               inline void getLDataArray
140                 (boost::shared_ptr<boost::multi_array<T, 1> > data, std::size_t _position) const;
141
142         protected : // Mutateurs protégés
143
144            template <class T>
145               inline void appendLData(const T & _data);
146            template <class T>
147               inline void appendLDataArray
148                 (boost::shared_ptr<boost::multi_array<T, 1> > _data);
149
150         private : // Traitement
151
152            void computeBufferData(void);
153
154         private : // Propriétés privées
155
156            std::vector<std::size_t> bdata;
157            std::size_t p_write;
158
159      }; // class CLinearBuffer
160   } // namespace comm
161} // namespace xmlioserver
162#endif //__LINEAR_BUFFER_HPP__
Note: See TracBrowser for help on using the repository browser.