#include <OSGStateChunk.h>
Class Access | |
| typedef std::vector < std::string > ::const_iterator | iterator |
| static const Char8 * | getName (UInt32 index) |
| static Int32 | getNumSlots (UInt32 index) |
| static UInt32 | getUsedSlots (void) |
| static iterator | begin () |
| static iterator | end () |
Public Member Functions | |
Constructor | |
| StateChunkClass (Char8 *name, UInt32 numslots=1) | |
Instance Access | |
| UInt32 | getId (void) const |
| const Char8 * | getName (void) const |
| Int32 | getNumSlots (void) const |
Protected Member Functions | |
| void | swap (StateChunkClass &other) |
Private Attributes | |
| UInt32 | _classId |
Static Private Attributes | |
| static std::vector< std::string > * | _classNames = NULL |
| static std::vector< UInt32 > * | _numslots = NULL |
Friends | |
| class | TextureTransformChunk |
Definition at line 60 of file OSGStateChunk.h.
Iterator type to access the chunk class list.
Definition at line 88 of file OSGStateChunk.h.
Constructor. The name is mandatory, the number of concurrently active slots is optional, default is 1.
Definition at line 106 of file OSGStateChunk.cpp.
References _classId, _classNames, and _numslots.
00107 { 00108 if(!_classNames) 00109 { 00110 _classNames = new std::vector<std::string>(0); 00111 _numslots = new std::vector< UInt32>(0); 00112 } 00113 00114 _classId = _classNames->size(); 00115 00116 for(unsigned i = 0; i < numslots; i++) 00117 { 00118 _classNames->push_back(std::string(name)); 00119 _numslots->push_back (numslots); 00120 } 00121 }
| UInt32 StateChunkClass::getId | ( | void | ) | const |
Definition at line 123 of file OSGStateChunk.cpp.
References _classId.
Referenced by osg::State::chunkPresent(), osg::StateChunk::getClassId(), osg::VertexProgramChunk::getStaticClassId(), osg::TransformChunk::getStaticClassId(), osg::TextureTransformChunk::getStaticClassId(), osg::TextureChunk::getStaticClassId(), osg::TexGenChunk::getStaticClassId(), osg::StencilChunk::getStaticClassId(), osg::StateChunk::getStaticClassId(), osg::SHLChunk::getStaticClassId(), osg::SClipPlaneChunk::getStaticClassId(), osg::RegisterCombinersChunk::getStaticClassId(), osg::ProgramChunk::getStaticClassId(), osg::PolygonChunk::getStaticClassId(), osg::PointChunk::getStaticClassId(), osg::MaterialChunk::getStaticClassId(), osg::LogicOpChunk::getStaticClassId(), osg::LineChunk::getStaticClassId(), osg::LightModelChunk::getStaticClassId(), osg::LightChunk::getStaticClassId(), osg::FragmentProgramChunk::getStaticClassId(), osg::DepthChunk::getStaticClassId(), osg::CubeTextureChunk::getStaticClassId(), osg::ColorMaskChunk::getStaticClassId(), osg::ClipPlaneChunk::getStaticClassId(), osg::BlendChunk::getStaticClassId(), and swap().
00124 { 00125 return _classId; 00126 }
| const Char8 * StateChunkClass::getName | ( | void | ) | const |
Definition at line 128 of file OSGStateChunk.cpp.
References _classId, and _classNames.
Referenced by swap().
00129 { 00130 return(*_classNames)[_classId].c_str(); 00131 }
| Int32 StateChunkClass::getNumSlots | ( | void | ) | const |
Definition at line 133 of file OSGStateChunk.cpp.
References _classId, and _numslots.
Referenced by osg::State::activate(), osg::State::changeFrom(), osg::State::chunkPresent(), osg::State::deactivate(), osg::State::subChunk(), and swap().
Access the name for the class whose id is index.
Definition at line 141 of file OSGStateChunk.cpp.
References _classNames.
00142 { 00143 if(index >=(*_classNames).size()) 00144 return "<Unknown StatChunkClass!>"; 00145 00146 return(*_classNames)[index].c_str(); 00147 }
Access the number of slots for the class whose id is index.
Definition at line 152 of file OSGStateChunk.cpp.
References _numslots.
00153 { 00154 if(index >= (*_numslots).size()) 00155 return -1; 00156 00157 return (*_numslots)[index]; 00158 }
| UInt32 osg::StateChunkClass::getUsedSlots | ( | void | ) | [inline, static] |
Iterator type to access the chunk class list.
Definition at line 68 of file OSGStateChunk.inl.
References _numslots.
00069 { 00070 return StateChunkClass::_numslots->size(); 00071 }
| StateChunkClass::iterator StateChunkClass::begin | ( | void | ) | [static] |
Iterator to allow access to all known StateChunkClasses.
Definition at line 168 of file OSGStateChunk.cpp.
References _classNames.
00169 { 00170 return _classNames->begin(); 00171 }
| StateChunkClass::iterator StateChunkClass::end | ( | void | ) | [static] |
Iterator to allow access to all known StateChunkClasses.
Definition at line 176 of file OSGStateChunk.cpp.
References _classNames.
00177 { 00178 return _classNames->end(); 00179 }
| void StateChunkClass::swap | ( | StateChunkClass & | other | ) | [protected] |
Definition at line 181 of file OSGStateChunk.cpp.
References _classId, FINFO, FWARNING, getId(), getName(), and getNumSlots().
Referenced by osg::TextureTransformChunk::checkTexChunkOrder().
00182 { 00183 FINFO(("Swap %s(%d|%d) %s(%d|%d)\n", 00184 this->getName(), 00185 this->getId(), 00186 this->getNumSlots(), 00187 other.getName(), 00188 other.getId(), 00189 other.getNumSlots())); 00190 00191 bool bNeighborSwap = false; 00192 00193 if(this->getNumSlots() != other.getNumSlots()) 00194 { 00195 if( ( (this->getId() < other.getId() && 00196 this->getId() + this->getNumSlots() != other.getId()) || 00197 (other.getId() < this->getId() && 00198 other.getId() + other.getNumSlots() != this->getId()) ) ) 00199 { 00200 FWARNING(("Can only swap if #slots is equal or if" 00201 "the chunks are neighbors\n")); 00202 return; 00203 } 00204 else 00205 { 00206 bNeighborSwap = true; 00207 } 00208 } 00209 00210 std::string thisName = this->getName (); 00211 UInt32 thisNumSlots = this->getNumSlots(); 00212 00213 std::string otherName = other.getName (); 00214 UInt32 otherNumSlots = other.getNumSlots(); 00215 00216 if(bNeighborSwap == false) 00217 { 00218 UInt32 tmp; 00219 00220 tmp = this->_classId; 00221 this->_classId = other._classId; 00222 other._classId = tmp; 00223 } 00224 else 00225 { 00226 if(this->_classId < other._classId) 00227 { 00228 other._classId = this->_classId; 00229 this->_classId += otherNumSlots; 00230 } 00231 else 00232 { 00233 this->_classId = other._classId; 00234 other._classId += thisNumSlots; 00235 } 00236 } 00237 00238 for(UInt32 i = this->getId(); 00239 i < this->getId() + thisNumSlots; 00240 ++i) 00241 { 00242 (*_classNames)[i] = thisName; 00243 (*_numslots )[i] = thisNumSlots; 00244 } 00245 00246 for(UInt32 i = other.getId(); 00247 i < other.getId() + otherNumSlots; 00248 ++i) 00249 { 00250 (*_classNames)[i] = otherName; 00251 (*_numslots )[i] = otherNumSlots; 00252 } 00253 }
friend class TextureTransformChunk [friend] |
Definition at line 98 of file OSGStateChunk.h.
osg::StateChunkClass::_classId [private] |
The numerical ID associated with each StateChunkClass. It is used to uniquely identify and quickly compare the class.
Dev: The classId is consecutive in the number of slots allocated to the chunk class, i.e. if a class has id 4 and 4 chunks, the next registered class will get id 8. The classId is used as an index into the osg::State's chunk vector, which necessitates this behaviour.
Definition at line 104 of file OSGStateChunk.h.
Referenced by getId(), getName(), getNumSlots(), StateChunkClass(), and swap().
std::vector< std::string > * StateChunkClass::_classNames = NULL [static, private] |
The global vector of known StateChunkClasses' names. Use StateChunkClass::getName with the Classes ID to access it.
Dev: See the osg::StateChunkClass::_classId for details.
Definition at line 105 of file OSGStateChunk.h.
Referenced by begin(), end(), getName(), and StateChunkClass().
std::vector< UInt32 > * StateChunkClass::_numslots = NULL [static, private] |
The global vector of known StateChunkClasses' number of concurrently active slots. Use StateChunkClass::getNumSlots with the Class's ID to access it.
Dev: See the osg::StateChunkClass::_classId for details.
Definition at line 106 of file OSGStateChunk.h.
Referenced by getNumSlots(), getUsedSlots(), and StateChunkClass().
1.5.5