fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Base / OSGSceneFileType.cpp
blob449627e5a0a3ce4597d7baaabd89f29b05816758
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
40 //---------------------------------------------------------
41 // Includes
42 //---------------------------------------------------------
44 #include <cstdlib>
45 #include <cstdio>
47 #include <fstream>
49 #include "OSGConfig.h"
51 #include "OSGLog.h"
53 #include "OSGSceneFileType.h"
54 #include "OSGSceneFileHandler.h"
55 #include "OSGBaseInitFunctions.h"
57 OSG_BEGIN_NAMESPACE
60 /*! \class SceneFileType
62 Base class for all file loaders.
65 //---------------------------------------------------------
67 /*! Constructor for SceneFileType.
69 \param[in] suffixArray Raw char buffer of supported suffix values.
70 \param[in] suffixByteCount Length of suffix strings to extract.
71 \param[in] override
72 \param[in] overridePriority Priority of this file handler in overload
73 resolution.
74 \param[in] flags Combination of OSG_READ_SUPPORTED and
75 OSG_WRITE_SUPPORTED to say what this handler supports.
78 SceneFileType::SceneFileType(const Char8 *suffixArray[],
79 UInt16 suffixByteCount,
80 bool override,
81 UInt32 overridePriority,
82 UInt32 flags ) :
83 Inherited (flags ),
84 _suffixList ( ),
85 _override (override ),
86 _overridePriority(overridePriority)
88 FINFO(( "Init %s Scene File Type %p\n",
89 suffixArray[0], static_cast<void *>(this)));
91 int count = (suffixByteCount / sizeof(const Char8 *)), i = 0;
93 std::list<std::string>::iterator sI;
95 _suffixList.resize(count);
97 for(sI = _suffixList.begin(); sI != _suffixList.end(); sI++)
99 sI->assign(suffixArray[i++]);
102 SceneFileHandler::the()->addSceneFileType(*this);
105 //---------------------------------------------------------
107 /*! Copy constructor
110 SceneFileType::SceneFileType(const SceneFileType &obj) :
111 Inherited (obj ),
112 _suffixList (obj._suffixList ),
113 _override (obj._override ),
114 _overridePriority(obj._overridePriority)
116 SWARNING << "In SceneFileType copy constructor" << std::endl;
119 //---------------------------------------------------------
120 SceneFileType::~SceneFileType(void)
122 if(GlobalSystemState < OSG::Shutdown)
123 SceneFileHandler::the()->subSceneFileType(*this);
126 void SceneFileType::terminate(void)
130 //---------------------------------------------------------
131 /*! Print supported suffixes to osgLog. */
132 void SceneFileType::print(void)
134 std::list<std::string>::iterator sI;
136 osgLog() << getName();
138 if (_suffixList.empty())
140 osgLog() << "NONE";
142 else
144 for (sI = _suffixList.begin(); sI != _suffixList.end(); sI++)
146 osgLog().stream(OSG::LOG_DEBUG) << sI->c_str() << " ";
149 osgLog() << std::endl;
152 //---------------------------------------------------------
153 /*! Return list of supported suffix strings. */
154 std::list<std::string> &SceneFileType::suffixList(void)
156 return _suffixList;
159 //---------------------------------------------------------
161 bool SceneFileType::doOverride(void)
163 return _override;
166 //---------------------------------------------------------
168 UInt32 SceneFileType::getOverridePriority(void)
170 return _overridePriority;
173 //---------------------------------------------------------
175 NodeTransitPtr SceneFileType::read(
176 std::istream &,
177 const Char8 *,
178 Resolver ) const
180 FWARNING (("STREAM INTERFACE NOT IMPLEMENTED!\n"));
182 return NodeTransitPtr(NULL);
185 #ifndef OSG_DISABLE_DEPRECATED
186 NodeTransitPtr SceneFileType::readFile(const Char8 *) const
188 FWARNING (("FILE INTERFACE NOT IMPLEMENTED!\n"));
190 return NodeTransitPtr(NULL);
192 #endif
194 bool SceneFileType::write(
195 Node * const OSG_CHECK_ARG(node ),
196 std::ostream &OSG_CHECK_ARG(os ),
197 Char8 const *OSG_CHECK_ARG(fileNameOrExtension)) const
199 FWARNING (("STREAM INTERFACE NOT IMPLEMENTED!\n"));
200 return false;
203 #ifndef OSG_DISABLE_DEPRECATED
204 bool SceneFileType::writeFile(Node * const OSG_CHECK_ARG(node ),
205 Char8 const *OSG_CHECK_ARG(fileName)) const
207 FWARNING (("FILE INTERFACE NOT IMPLEMENTED!\n"));
208 return false;
210 #endif
212 OSG_END_NAMESPACE