fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGStateOverride.inl
blob36657cf63a62530ff1a4ba0c4472aa39a3b9a9f0
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 OSG_BEGIN_NAMESPACE
42 inline
43 bool operator <(const StateOverride::ChunkElement &lhs, 
44                 const StateOverride::ChunkElement &rhs)
46     return lhs.first < rhs.first;
49 inline
50 void StateOverride::fillFrom(StateOverride *pState)
52     _vChunks        = pState->_vChunks;
55     _pShader        = pState->_pShader;
56     _pShaderVar     = pState->_pShaderVar;
59     _vProgChunks    = pState->_vProgChunks;
60     _vProgIds       = pState->_vProgIds;
62     _vProgVarChunks = pState->_vProgVarChunks;
63     _vProgVarIds    = pState->_vProgVarIds;
66     _uiSortKey      = pState->_uiSortKey;
67     _uiKeyGen       = pState->_uiKeyGen;
68     _uiKeyMask      = pState->_uiKeyMask;
71 inline
72 void StateOverride::setKeyGen(UInt32 uiKeyGen)
74     _uiKeyGen = uiKeyGen;
77 inline
78 void StateOverride::updateSortKey(UInt32 &uiSortKey, 
79                                   UInt32  uiKeyGen)
81     if(_uiKeyGen != uiKeyGen && uiKeyGen < SkipRebuild)
82     {
83         _uiKeyGen = uiKeyGen;
85         rebuildSortKey();
86     }
88     if(_uiSortKey != 0x0000)
89     {
90         uiSortKey = (uiSortKey & _uiKeyMask) | _uiKeyGen;
91     }
94 inline
95 void StateOverride::reset(void)
97     _vChunks.clear();
99     _pShader    = NULL;
100     _pShaderVar = NULL;
103     _vProgChunks.clear();
104     _vProgIds   .clear();
106     _vProgVarChunks.clear();
107     _vProgVarIds   .clear();
110     _uiSortKey  = 0;
111     _uiKeyGen   = 0;
112     _uiKeyMask  = 0;
115 inline
116 bool StateOverride::empty(void)
118     return _vChunks.empty();
121 inline
122 bool StateOverride::isTransparent(void)
124     ChunkStoreIt cIt  = _vChunks.begin();
125     ChunkStoreIt cEnd = _vChunks.end  ();
127     for(; cIt != cEnd; ++cIt)
128     {
129         if(cIt->second != NULL && cIt->second->isTransparent() == true)
130         {
131             return true;
132         }
133     }
135     return false;
138 inline
139 StateOverride::ChunkStoreConstIt StateOverride::begin(void) const
141     return _vChunks.begin();
144 inline
145 StateOverride::ChunkStoreConstIt StateOverride::end(void) const
147     return _vChunks.end();
150 inline
151 SizeT StateOverride::size(void) const
153     return _vChunks.size();
156 inline
157 UInt32 StateOverride::size32(void) const
159     return UInt32(_vChunks.size());
162 inline
163 const StateOverride::IdStore &StateOverride::getProgIds(void)
165     return _vProgIds;
168 inline
169 const StateOverride::ProgramChunkStore &StateOverride::getPrograms(void)
171     return _vProgChunks;
174 inline
175 const StateOverride::IdStore &StateOverride::getVarIds(void)
177     return _vProgVarIds;
180 inline
181 const StateOverride::ProgramVarChunkStore &StateOverride::getVariables(void)
183     return _vProgVarChunks;
186 inline
187 void StateOverride::setShader(ShaderExecutableChunk *pShader)
189     _pShader = pShader;
192 inline
193 ShaderExecutableChunk *StateOverride::getShader(void)
195     return _pShader;
198 inline
199 void StateOverride::setShaderVar(ShaderExecutableVarChunk *pVar)
201     _pShaderVar = pVar;
204 inline
205 ShaderExecutableVarChunk *StateOverride::getShaderVar(void)
207     return _pShaderVar;
210 OSG_END_NAMESPACE