fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGStateOverride.h
blob2410eaec1190407d6797f687ae85817981960fbe
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 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSTATEOVERRIDE_H_
40 #define _OSGSTATEOVERRIDE_H_
42 #ifdef __sgi
43 #pragma once
44 #endif
46 #include "OSGBaseTypes.h"
47 #include "OSGSystemDef.h"
48 #include "OSGSimplePool.h"
49 #include "OSGState.h"
51 #include <vector>
52 #include <utility>
53 #include <algorithm>
55 OSG_BEGIN_NAMESPACE
57 class ShaderExecutableChunk;
58 class ShaderExecutableVarChunk;
59 class ShaderProgramChunk;
60 class ShaderProgramVariableChunk;
61 class ShaderProgram;
62 class SimpleSHLChunk;
64 /*! \ingroup GrpSystemStateBase
65 \ingroup GrpLibOSGSystem
66 \nohierarchy
69 class OSG_SYSTEM_DLLMAPPING StateOverride
71 /*========================== PUBLIC =================================*/
73 public:
75 typedef std::pair <UInt32, StateChunk *> ChunkElement;
77 typedef std::vector<ChunkElement > ChunkStore;
78 typedef std::vector<ChunkElement >::iterator ChunkStoreIt;
79 typedef std::vector<ChunkElement >::const_iterator ChunkStoreConstIt;
81 typedef std::vector<UInt16 > IdStore;
82 typedef std::vector<UInt16 >::iterator IdStoreIt;
85 typedef std::vector<ShaderProgramChunk *> ProgramChunkStore;
86 typedef std::vector<ShaderProgramVariableChunk *> ProgramVarChunkStore;
89 static const UInt32 InvalidKey = State::InvalidKey;
91 static const UInt32 SkipRebuild = State::SkipRebuild;
93 static const UInt32 Key1Mask = State::Key1Mask;
94 static const UInt32 Key2Mask = State::Key2Mask;
95 static const UInt32 Key3Mask = State::Key3Mask;
97 /*---------------------------------------------------------------------*/
98 /*! \name Constructors */
99 /*! \{ */
101 StateOverride(void);
103 /*! \} */
104 /*---------------------------------------------------------------------*/
105 /*! \name Destructor */
106 /*! \{ */
108 virtual ~StateOverride(void);
110 /*! \} */
111 /*---------------------------------------------------------------------*/
112 /*! \name Statistic */
113 /*! \{ */
115 void fillFrom(StateOverride *pState);
117 /*! \} */
118 /*---------------------------------------------------------------------*/
119 /*! \name Statistic */
120 /*! \{ */
122 void setKeyGen (UInt32 uiKeyGen );
123 void updateSortKey(UInt32 &uiSortKey, UInt32 uiKeyGen = SkipRebuild);
125 /*! \} */
126 /*---------------------------------------------------------------------*/
127 /*! \name Statistic */
128 /*! \{ */
130 ChunkStoreConstIt begin (void) const;
131 ChunkStoreConstIt end (void) const;
132 SizeT size (void) const;
133 UInt32 size32(void) const;
135 /*! \} */
136 /*---------------------------------------------------------------------*/
137 /*! \name Access */
138 /*! \{ */
140 void reset (void );
142 void addOverride (UInt32 uiSlot,
143 StateChunk *pChunk);
144 void addOverride (UInt32 uiSlot,
145 SimpleSHLChunk *pChunk);
146 void addOverride (UInt32 uiSlot,
147 ShaderProgramChunk *pChunk);
148 void addOverride (UInt32 uiSlot,
149 ShaderProgramVariableChunk *pChunk);
152 void subOverride (UInt32 uiSlot,
153 StateChunk *pChunk);
154 void subOverride (UInt32 uiSlot,
155 SimpleSHLChunk *pChunk);
156 void subOverride (UInt32 uiSlot,
157 ShaderProgramChunk *pChunk);
158 void subOverride (UInt32 uiSlot,
159 ShaderProgramVariableChunk *pChunk);
162 bool empty (void );
164 bool isTransparent(void );
166 /*! \} */
167 /*---------------------------------------------------------------------*/
168 /*! \name Access */
169 /*! \{ */
171 const IdStore &getProgIds (void);
172 const ProgramChunkStore &getPrograms (void);
174 const IdStore &getVarIds (void);
175 const ProgramVarChunkStore &getVariables(void);
177 /*! \} */
178 /*---------------------------------------------------------------------*/
179 /*! \name Access */
180 /*! \{ */
182 void setShader (ShaderExecutableChunk *pShader);
183 ShaderExecutableChunk *getShader (void );
185 void setShaderVar(ShaderExecutableVarChunk *pVar );
186 ShaderExecutableVarChunk *getShaderVar(void );
188 /*! \} */
189 /*========================= PROTECTED ===============================*/
191 protected:
194 /*---------------------------------------------------------------------*/
195 /*! \name Member */
196 /*! \{ */
198 ChunkStore _vChunks;
200 ShaderExecutableChunk *_pShader;
201 ShaderExecutableVarChunk *_pShaderVar;
203 ProgramChunkStore _vProgChunks;
204 IdStore _vProgIds;
206 ProgramVarChunkStore _vProgVarChunks;
207 IdStore _vProgVarIds;
209 UInt32 _uiSortKey;
210 UInt32 _uiKeyGen;
211 UInt32 _uiKeyMask;
213 /*! \} */
214 /*---------------------------------------------------------------------*/
215 /*! \name Access */
216 /*! \{ */
218 void rebuildSortKey(void);
220 /*! \} */
221 /*---------------------------------------------------------------------*/
222 /*! \name Access */
223 /*! \{ */
225 void insertOverride(UInt32 uiSlot,
226 StateChunk *pChunk);
228 void eraseOverride (UInt32 uiSlot,
229 StateChunk *pChunk);
231 /*! \} */
232 /*========================== PRIVATE ================================*/
234 private:
236 template <class T,
237 class Tag,
238 class RefCountPolicy,
239 class LockPolicy > friend class SimplePool;
241 /*! \brief prohibit default function (move to 'public' if needed) */
242 StateOverride(const StateOverride &source);
243 /*! \brief prohibit default function (move to 'public' if needed) */
244 void operator =(const StateOverride &source);
247 bool operator <(const StateOverride::ChunkElement &lhs,
248 const StateOverride::ChunkElement &rhs);
250 OSG_END_NAMESPACE
252 #include "OSGStateOverride.inl"
254 #endif /* _OSGSTATEOVERRIDE_H_ */