fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Base / OSGIOFileTypeBase.h
blobd349f867f5726531f990b735be2cd5db086860be
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2008 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 _OSGIOFILETYPEBASE_H_
40 #define _OSGIOFILETYPEBASE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGConfig.h"
46 #include "OSGSystemDef.h"
47 #include "OSGBaseTypes.h"
48 #include "OSGLog.h"
50 #include <boost/lexical_cast.hpp>
51 #include <map>
52 #include <stack>
53 #include <string>
55 OSG_BEGIN_NAMESPACE
57 /*! \ingroup GrpSystemFileIOBase
58 \ingroup GrpLibOSGSystem
61 class OSG_SYSTEM_DLLMAPPING IOFileTypeBase
63 /*========================== PUBLIC =================================*/
65 public:
67 /*---------------------------------------------------------------------*/
68 /*! \name Public Types */
69 /*! \{ */
71 typedef IOFileTypeBase Self;
73 enum
75 OSG_READ_SUPPORTED = 1, /**< The file type supports reading. */
76 OSG_WRITE_SUPPORTED = 2 /**< The file type supports writing. */
79 /*! \nohierarchy
82 struct OSG_SYSTEM_DLLMAPPING IOOption
84 IOOption(void );
85 IOOption(const IOOption &other );
86 IOOption(const std::string &name, const std::string &value);
88 std::string optName;
89 std::string optValue;
92 typedef std::map <std::string, IOOption> OptionSet;
93 typedef std::stack<OptionSet > OptionStack;
95 /*! \} */
96 /*---------------------------------------------------------------------*/
97 /*! \name Flags */
98 /*! \{ */
100 UInt32 getFlags(void) const;
102 /*! \} */
103 /*---------------------------------------------------------------------*/
104 /*! \name Option Handling Helpers */
105 /*! \{ */
107 static bool hasOption (const OptionSet &optSet,
108 const std::string &name );
110 template <class ValueTypeT>
111 static bool setOptionAs( OptionSet &optSet,
112 const std::string &name,
113 const ValueTypeT &value );
114 static void setOption ( OptionSet &optSet,
115 const std::string &name,
116 const std::string &value );
118 static bool unsetOption( OptionSet &optSet,
119 const std::string &name );
121 template <class ValueTypeT>
122 static bool getOptionAs(const OptionSet &optSet,
123 const std::string &name,
124 ValueTypeT &value );
125 static bool getOption (const OptionSet &optSet,
126 const std::string &name,
127 std::string &value );
129 /*! \} */
130 /*---------------------------------------------------------------------*/
131 /*! \name Option Handling */
132 /*! \{ */
134 void pushOptions(bool copyTop = true);
135 void popOptions (void );
137 OptionSet const &getOptions (void ) const;
138 OptionSet &editOptions(void );
140 bool hasOption (const std::string &name ) const;
142 template <class ValueTypeT>
143 bool setOptionAs(const std::string &name,
144 const ValueTypeT &value );
145 void setOption (const std::string &name,
146 const std::string &value );
148 bool unsetOption(const std::string &name );
150 template <class ValueTypeT>
151 bool getOptionAs(const std::string &name,
152 ValueTypeT &value ) const;
153 bool getOption (const std::string &name,
154 std::string &value ) const;
156 /*! \} */
157 /*========================= PROTECTED ===============================*/
159 protected:
161 /*---------------------------------------------------------------------*/
162 /*! \name Constructors */
163 /*! \{ */
165 IOFileTypeBase(UInt32 const flags);
166 IOFileTypeBase(Self const &other);
168 /*---------------------------------------------------------------------*/
169 /*! \name Destructor */
170 /*! \{ */
172 virtual ~IOFileTypeBase(void);
174 /*! \} */
175 /*---------------------------------------------------------------------*/
176 /*! \name Members */
177 /*! \{ */
179 UInt32 _flags;
180 OptionStack _optStack;
182 /*! \} */
183 /*---------------------------------------------------------------------*/
186 OSG_END_NAMESPACE
188 #include "OSGIOFileTypeBase.inl"
190 #endif // _OSGIOFILETYPEBASE_H_