1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2008 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGIOFILETYPEBASE_H_
40 #define _OSGIOFILETYPEBASE_H_
45 #include "OSGConfig.h"
46 #include "OSGSystemDef.h"
47 #include "OSGBaseTypes.h"
50 #include <boost/lexical_cast.hpp>
57 /*! \ingroup GrpSystemFileIOBase
58 \ingroup GrpLibOSGSystem
61 class OSG_SYSTEM_DLLMAPPING IOFileTypeBase
63 /*========================== PUBLIC =================================*/
67 /*---------------------------------------------------------------------*/
68 /*! \name Public Types */
71 typedef IOFileTypeBase Self
;
75 OSG_READ_SUPPORTED
= 1, /**< The file type supports reading. */
76 OSG_WRITE_SUPPORTED
= 2 /**< The file type supports writing. */
82 struct OSG_SYSTEM_DLLMAPPING IOOption
85 IOOption(const IOOption
&other
);
86 IOOption(const std::string
&name
, const std::string
&value
);
92 typedef std::map
<std::string
, IOOption
> OptionSet
;
93 typedef std::stack
<OptionSet
> OptionStack
;
96 /*---------------------------------------------------------------------*/
100 UInt32
getFlags(void) const;
103 /*---------------------------------------------------------------------*/
104 /*! \name Option Handling Helpers */
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
,
125 static bool getOption (const OptionSet
&optSet
,
126 const std::string
&name
,
127 std::string
&value
);
130 /*---------------------------------------------------------------------*/
131 /*! \name Option Handling */
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;
157 /*========================= PROTECTED ===============================*/
161 /*---------------------------------------------------------------------*/
162 /*! \name Constructors */
165 IOFileTypeBase(UInt32
const flags
);
166 IOFileTypeBase(Self
const &other
);
168 /*---------------------------------------------------------------------*/
169 /*! \name Destructor */
172 virtual ~IOFileTypeBase(void);
175 /*---------------------------------------------------------------------*/
180 OptionStack _optStack
;
183 /*---------------------------------------------------------------------*/
188 #include "OSGIOFileTypeBase.inl"
190 #endif // _OSGIOFILETYPEBASE_H_