changed: gcc8 base update
[opensg.git] / Source / System / FileIO / Base / OSGSceneFileHandler.inl
blob6927e1e38d5293536e36baa8f40b516348d45c48
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 OSG_BEGIN_NAMESPACE
41 /*! Attempts to set option \a name to \a value for the SceneFileHandler that
42     handles files with the given \a suffix.
43     If successful \c true is returned, false otherwise.
44     For the operation to succeed a \c boost::lexical_cast<> from the given type
45     has to succeed, usually that means an appropriate overload of
46     \c operator<< has to be available.
47     
48     \param[in] suffix File extension to choose the scene file type
49                       this option applies to.
50     \param[in] name Name of the option.
51     \param[in] value Value of the option.
52     \return Whether the value was set successfully.
53  */
54 template <class ValueTypeT>
55 inline bool
56     SceneFileHandlerBase::setOptionAs(
57         const std::string &suffix,
58         const std::string &name,
59         const ValueTypeT  &value  )
61     bool           retVal = false;
62     SceneFileType *type   = getFileType(suffix.c_str());
63     
64     if(type != NULL)
65     {
66         retVal = type->setOptionAs<ValueTypeT>(name, value);
67     }
68     
69     return retVal;
72 /*! Retrieves the option \a name from the SceneFileType that handles files
73     with the given \a suffix and stores its value in \a value.
74     Returns \c true if successful, \c false otherwise in which case \a value has
75     an undefined value.
76     
77     \param[in] suffix File extension to choose the scene file type
78                       this option applies to.
79     \param[in] name Name of the option.
80     \param[out] value Value the option.
81     \return Whether the option is present for the given SceneFileType.
82  */
83 template <class ValueTypeT>
84 inline bool 
85     SceneFileHandlerBase::getOptionAs(
86         const std::string &suffix,
87         const std::string &name,
88               ValueTypeT  &value  )
90     bool           retVal = false;
91     SceneFileType *type   = getFileType(suffix.c_str());
92     
93     if(type != NULL)
94     {
95         retVal = type->getOptionAs<ValueTypeT>(name, value);
96     }
97     
98     return retVal;
101 OSG_END_NAMESPACE