fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Chunks / OSGShaderExecutableVarChunk.h
blob7db957696362e7deea1ef03f6e827f9d0de5aa72
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 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 _OSGSHADEREXECUTABLEVARCHUNK_H_
40 #define _OSGSHADEREXECUTABLEVARCHUNK_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGShaderExecutableVarChunkBase.h"
46 #include "OSGShaderExecutableChunk.h"
48 #include <map>
50 OSG_BEGIN_NAMESPACE
52 class ShaderCache;
53 class SimpleSHLVariableChunk;
55 /*! \brief ShaderExecutableVarChunk class. See \ref
56 PageStateShaderExecutableVarChunk for a description.
57 \ingroup GrpSystemShaderChunks
58 \ingroup GrpLibOSGSystem
59 \includebasedoc
62 class OSG_SYSTEM_DLLMAPPING ShaderExecutableVarChunk :
63 public ShaderExecutableVarChunkBase
65 protected:
67 /*========================== PUBLIC =================================*/
69 public:
71 typedef ShaderExecutableVarChunkBase Inherited;
72 typedef ShaderExecutableVarChunk Self;
74 typedef MFProgramVarChunksType::const_iterator VarChunksIt;
76 /*---------------------------------------------------------------------*/
77 /*! \name Chunk Class Access */
78 /*! \{ */
80 virtual const StateChunkClass *getClass(void) const;
82 /*! \} */
83 /*---------------------------------------------------------------------*/
84 /*! \name Static Chunk Class Access */
85 /*! \{ */
87 static UInt32 getStaticClassId(void);
88 static const StateChunkClass *getStaticClass (void);
90 /*! \} */
91 /*---------------------------------------------------------------------*/
92 /*! \name Chunk Id */
93 /*! \{ */
95 virtual UInt16 getChunkId(void);
97 /*! \} */
98 /*---------------------------------------------------------------------*/
99 /*! \name Sync */
100 /*! \{ */
102 virtual void changed(ConstFieldMaskArg whichField,
103 UInt32 origin,
104 BitVector details );
106 /*! \} */
107 /*---------------------------------------------------------------------*/
108 /*! \name Output */
109 /*! \{ */
111 void setShaderExecutableChunk(ShaderExecutableChunk * const);
113 /*! \} */
114 /*---------------------------------------------------------------------*/
115 /*! \name Output */
116 /*! \{ */
118 void merge(ShaderProgramVariableChunk *pVar);
120 /*! \} */
121 /*---------------------------------------------------------------------*/
122 /*! \name Output */
123 /*! \{ */
125 /*! \} */
126 /*---------------------------------------------------------------------*/
127 /*! \name Init */
128 /*! \{ */
130 virtual void activate (DrawEnv*, UInt32 index = 0);
131 virtual void changeFrom(DrawEnv*, StateChunk*, UInt32 index = 0);
132 virtual void deactivate(DrawEnv*, UInt32 index = 0);
134 /*! \} */
135 /*---------------------------------------------------------------------*/
136 /*! \name Output */
137 /*! \{ */
139 virtual void dump( UInt32 uiIndent = 0,
140 const BitVector bvFlags = 0) const;
142 /*! \} */
143 /*========================= PROTECTED ===============================*/
145 protected:
147 #ifdef OSG_MULTISHADER_VARCHUNK
148 typedef std::map<UInt32, MFInt32> ShaderVarLocMap;
149 typedef std::map<UInt32, MFInt32>::value_type ShaderVarLocMapValueT;
150 typedef std::map<UInt32, MFInt32>::iterator ShaderVarLocMapIt;
151 typedef std::map<UInt32, MFInt32>::const_iterator ShaderVarLocMapConstIt;
152 #endif
154 /*---------------------------------------------------------------------*/
156 static volatile UInt16 _uiChunkCounter;
158 #ifdef OSG_MULTISHADER_VARCHUNK
159 ShaderVarLocMap _mShaderVarLocs;
160 #endif
161 UInt16 _uiChunkId;
163 // Variables should all be in SHLVariableChunkBase.
165 /*---------------------------------------------------------------------*/
166 /*! \name Init */
167 /*! \{ */
169 void onCreate (const ShaderExecutableVarChunk *source = NULL);
170 void onCreateAspect(const ShaderExecutableVarChunk *createAspect,
171 const ShaderExecutableVarChunk *source = NULL);
173 /*! \} */
174 /*---------------------------------------------------------------------*/
175 /*! \name Constructors */
176 /*! \{ */
178 ShaderExecutableVarChunk(void);
179 ShaderExecutableVarChunk(const ShaderExecutableVarChunk &source);
181 /*! \} */
182 /*---------------------------------------------------------------------*/
183 /*! \name Destructors */
184 /*! \{ */
186 virtual ~ShaderExecutableVarChunk(void);
188 /*! \} */
189 /*---------------------------------------------------------------------*/
190 /*! \name Init */
191 /*! \{ */
193 static void initMethod(InitPhase ePhase);
195 /*! \} */
196 /*---------------------------------------------------------------------*/
197 /*! \name Init */
198 /*! \{ */
200 void updateVariables (DrawEnv *pEnv);
201 void remergeVariables(void );
203 /*! \} */
204 /*---------------------------------------------------------------------*/
205 /*! \name Init */
206 /*! \{ */
208 const MFProgramVarChunksType *getMFProgramVarChunks(void);
210 /*! \} */
211 /*========================== PRIVATE ================================*/
213 private:
215 // class. Used for indexing in State
216 static StateChunkClass _class;
218 friend class FieldContainer;
219 friend class ShaderExecutableVarChunkBase;
220 friend class ShaderCache;
221 friend class SimpleSHLVariableChunk;
223 // prohibit default functions (move to 'public' if you need one)
224 void operator =(const ShaderExecutableVarChunk &source);
227 typedef ShaderExecutableVarChunk *ShaderExecutableVarChunkP;
229 OSG_END_NAMESPACE
231 #include "OSGShaderExecutableVarChunkBase.inl"
232 #include "OSGShaderExecutableVarChunk.inl"
234 #endif /* _OSGSHADEREXECUTABLEVARCHUNK_H_ */