added: travMask to csm viewport
[opensg.git] / Source / Base / Base / OSGIOStream.h
blobabb05428545b6166abb6e678fd4a7306ecce99cc
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGIOSTREAM_H_
40 #define _OSGIOSTREAM_H_
42 #include "OSGConfig.h"
43 #include "OSGBaseDef.h"
45 #include <iostream>
46 #include <iomanip>
47 #include <fstream>
49 #ifdef WIN32
50 #define OSG_STREAM_API __cdecl
51 #else
52 #define OSG_STREAM_API
53 #endif
55 OSG_BEGIN_NAMESPACE
57 class Fixed32;
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 struct SetIndent
62 SetIndent(unsigned int uiIndent) : _uiIndent(uiIndent) {}
64 unsigned int _uiIndent;
67 struct _IncIndent {};
68 struct _DecIndent {};
69 struct _BeginElem {};
70 struct _EndElem {};
71 struct _EndElemNL {};
73 typedef void (*_IncIndent_)(_IncIndent);
74 typedef void (*_DecIndent_)(_DecIndent);
75 typedef void (*_BeginElem_)(_BeginElem);
76 typedef void (*_EndElem_ )(_EndElem );
77 typedef void (*_EndElemNL_)(_EndElemNL);
78 #endif
80 /*! \name Stream Controls
84 /*! \ingroup GrpBaseBaseStreamIO */
85 OSG_BASE_DLLMAPPING void IncIndent(_IncIndent);
86 /*! \ingroup GrpBaseBaseStreamIO */
87 OSG_BASE_DLLMAPPING void DecIndent(_DecIndent);
88 /*! \ingroup GrpBaseBaseStreamIO */
89 OSG_BASE_DLLMAPPING void BeginElem(_BeginElem);
90 /*! \ingroup GrpBaseBaseStreamIO */
91 OSG_BASE_DLLMAPPING void EndElem (_EndElem );
92 /*! \ingroup GrpBaseBaseStreamIO */
93 OSG_BASE_DLLMAPPING void EndElemNL(_EndElemNL);
95 /*! \} */
97 /*! \ingroup GrpBaseBase
98 \ingroup GrpBaseBaseStreamIO
99 \ingroup GrpLibOSGBase
100 \nohierarchy
103 class OSG_BASE_DLLMAPPING OutStream
105 /*========================== PUBLIC =================================*/
107 public:
109 /*---------------------------------------------------------------------*/
110 /*! \name Constructor */
111 /*! \{ */
113 OutStream(std::ostream &baseStream);
115 /*! \} */
116 /*---------------------------------------------------------------------*/
117 /*! \name Destructor */
118 /*! \{ */
120 virtual ~OutStream(void);
122 /*! \} */
123 /*---------------------------------------------------------------------*/
124 /*! \name formated output */
125 /*! \{ */
127 OutStream &operator<<( long __n);
128 OutStream &operator<<( unsigned long __n);
130 OutStream &operator<<( bool __n);
131 OutStream &operator<<( char __c);
133 OutStream &operator<<( short __n);
134 OutStream &operator<<( unsigned short __n);
136 OutStream &operator<<( int __n);
137 OutStream &operator<<( unsigned int __n);
139 OutStream &operator<<( long long __n);
140 OutStream &operator<<( unsigned long long __n);
142 OutStream &operator<<( double __f);
143 OutStream &operator<<( float __f);
145 OutStream &operator<<( long double __f);
147 OutStream &operator<<(const Fixed32 &val);
149 OutStream &operator<<(const void *__p);
151 OutStream &operator<<(const char *__p);
152 OutStream &operator<<(const std::string &__s);
154 /*! \} */
155 /*---------------------------------------------------------------------*/
156 /*! \name formated output */
157 /*! \{ */
159 #ifndef WIN32
160 OutStream &operator<<(std::_Setbase __f);
161 #else
162 template <class Arg>
163 OutStream &operator<<(std::_Smanip<Arg> &__f);
164 #endif
166 OutStream &operator<<(std::ostream& (OSG_STREAM_API *__pf)(std::ostream&));
168 /*! \} */
169 /*---------------------------------------------------------------------*/
170 /*! \name formated output */
171 /*! \{ */
173 virtual OutStream &operator<<( SetIndent);
174 virtual OutStream &operator<<(_IncIndent_);
175 virtual OutStream &operator<<(_DecIndent_);
177 virtual OutStream &operator<<(_BeginElem_);
178 virtual OutStream &operator<<(_EndElem_ );
179 virtual OutStream &operator<<(_EndElemNL_);
181 /*! \} */
182 /*========================== PROTECTRED =============================*/
184 protected:
186 std::ostream *_pBaseStream;
188 /*========================== PRIVATE ================================*/
190 private:
192 OutStream(const OutStream &source);
193 void operator =(const OutStream &source);
196 /*! \ingroup GrpBaseBase
197 \ingroup GrpBaseBaseStreamIO
198 \ingroup GrpLibOSGBase
199 \nohierarchy
202 template<class ParentT>
203 class FileStreamMixin : public ParentT
205 /*========================== PUBLIC =================================*/
207 public:
209 typedef ParentT Inherited;
211 /*---------------------------------------------------------------------*/
212 /*! \name Constructor */
213 /*! \{ */
215 FileStreamMixin(const char *szFileName);
217 /*! \} */
218 /*---------------------------------------------------------------------*/
219 /*! \name Destructor */
220 /*! \{ */
222 virtual ~FileStreamMixin(void);
224 /*! \} */
225 /*---------------------------------------------------------------------*/
226 /*! \name formated output */
227 /*! \{ */
229 void close(void);
231 operator bool (void);
233 /*! \} */
234 /*========================== PROTECTRED =============================*/
236 protected:
238 std::ofstream _oFileStream;
240 /*========================== PRIVATE ================================*/
242 private:
245 /*! \ingroup GrpBaseBase
246 \ingroup GrpBaseBaseStreamIO
247 \ingroup GrpLibOSGBase
248 \nohierarchy
251 template<class ParentT>
252 class IndentOutStreamMixin : public ParentT
254 /*========================== PUBLIC =================================*/
256 public:
258 typedef ParentT Inherited;
260 /*---------------------------------------------------------------------*/
261 /*! \name Constructor */
262 /*! \{ */
264 IndentOutStreamMixin(std::ostream &baseStream);
266 /*! \} */
267 /*---------------------------------------------------------------------*/
268 /*! \name Destructor */
269 /*! \{ */
271 virtual ~IndentOutStreamMixin(void);
273 /*! \} */
274 /*---------------------------------------------------------------------*/
275 /*! \name formated output */
276 /*! \{ */
278 virtual IndentOutStreamMixin &operator<<(SetIndent setIndent);
280 virtual IndentOutStreamMixin &operator<<(_IncIndent_);
281 virtual IndentOutStreamMixin &operator<<(_DecIndent_);
282 virtual IndentOutStreamMixin &operator<<(_BeginElem_);
283 virtual IndentOutStreamMixin &operator<<(_EndElem_ );
284 virtual IndentOutStreamMixin &operator<<(_EndElemNL_);
286 /*! \} */
287 /*---------------------------------------------------------------------*/
288 /*! \name formated output */
289 /*! \{ */
291 /*! \} */
292 /*========================== PROTECTRED =============================*/
294 protected:
296 /*========================== PRIVATE ================================*/
298 std::string _szIndent;
299 unsigned int _uiIndentStep;
301 private:
305 /*! \ingroup GrpBaseBase
306 \ingroup GrpBaseBaseStreamIO
307 \ingroup GrpLibOSGBase
308 \nohierarchy
311 class OSG_BASE_DLLMAPPING InStream
313 /*========================== PUBLIC =================================*/
315 public:
317 /*---------------------------------------------------------------------*/
318 /*! \name Constructor */
319 /*! \{ */
321 InStream(std::istream &baseStream);
323 /*! \} */
324 /*---------------------------------------------------------------------*/
325 /*! \name Destructor */
326 /*! \{ */
328 virtual ~InStream(void);
330 /*! \} */
331 /*========================== PROTECTRED =============================*/
333 protected:
335 std::istream *_pBaseStream;
337 /*========================== PRIVATE ================================*/
339 private:
341 InStream(const InStream &source);
342 void operator =(const InStream &source);
345 /*! \name Streams
349 /*! \ingroup GrpBaseBaseStreamIO */
350 typedef FileStreamMixin <OutStream> FileOutStream;
351 /*! \ingroup GrpBaseBaseStreamIO */
352 typedef FileStreamMixin<IndentOutStreamMixin<OutStream> > IndentFileOutStream;
354 /*! \}
357 OSG_END_NAMESPACE
359 #include "OSGIOStream.inl"
361 #endif // _OSG_IOSTREAM_H_