fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / SHL / OSGSimpleSHLVariableChunk.inl
blob40fbb9ea95a1916d7e7e4b20f45af341b4e3956a
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *               Copyright (C) 2000-2006 by the OpenSG Forum                 *
6  *                                                                           *
7  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
8  *                                                                           *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11  *                                License                                    *
12  *                                                                           *
13  * This library is free software; you can redistribute it and/or modify it   *
14  * under the terms of the GNU Library General Public License as published    *
15  * by the Free Software Foundation, version 2.                               *
16  *                                                                           *
17  * This library is distributed in the hope that it will be useful, but       *
18  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
20  * Library General Public License for more details.                          *
21  *                                                                           *
22  * You should have received a copy of the GNU Library General Public         *
23  * License along with this library; if not, write to the Free Software       *
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
25  *                                                                           *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28  *                                Changes                                    *
29  *                                                                           *
30  *                                                                           *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
38 //  Includes
39 //---------------------------------------------------------------------------
41 OSG_BEGIN_NAMESPACE
43 inline
44 const StateChunkClass *SimpleSHLVariableChunk::getStaticClass(void)
46     return ShaderExecutableVarChunk::getStaticClass();
49 inline
50 UInt32 SimpleSHLVariableChunk::getStaticClassId(void)
52     return getStaticClass()->getId();
55 #ifdef OSG_1_COMPAT
56 template<class ValueT> inline
57 bool SimpleSHLVariableChunk::setUniformParameter(const Char8  *name, 
58                                                  const ValueT &value)
60     if(_sfVariables.getValue() == NULL)
61     {
62         ShaderProgramVariablesUnrecPtr pParam = 
63             ShaderProgramVariables::createDependent(
64                 this->getFieldFlags()->_bNamespaceMask);
66         setVariables(pParam);
67     }
69     return _sfVariables.getValue()->addUniformVariable(
70         name, 
71         value,
72         editMFVariableLocations(),
73         NULL                     );
75 #endif
77 template<class ValueT> inline
78 bool SimpleSHLVariableChunk::addUniformVariable(const Char8  *name, 
79                                                 const ValueT &value)
81     if(_sfVariables.getValue() == NULL)
82     {
83         ShaderProgramVariablesUnrecPtr pParam = 
84             ShaderProgramVariables::createDependent(
85                 this->getFieldFlags()->_bNamespaceMask);
87         setVariables(pParam);
88     }
90     return _sfVariables.getValue()->addUniformVariable(
91         name, 
92         value,
93         editMFVariableLocations(),
94         NULL                     );
97 template<class ValueT> inline
98 bool SimpleSHLVariableChunk::updateUniformVariable(const Char8  *name, 
99                                                    const ValueT &value)
101     if(_sfVariables.getValue() == NULL)
102     {
103         ShaderProgramVariablesUnrecPtr pParam = 
104             ShaderProgramVariables::createDependent(
105                 getFieldFlags()->_bNamespaceMask);
107         setVariables(pParam);
108     }
110     return _sfVariables.getValue()->updateUniformVariable(name, value);
113 template<class ValueT>
114 bool SimpleSHLVariableChunk::getUniformVariable(const Char8  *name, 
115                                                       ValueT &value)
117     if(_sfVariables.getValue() != NULL)
118     {
119         return _sfVariables.getValue()->getUniformVariable(name, value);
120     }
122     return false;
125 OSG_END_NAMESPACE