osg::StateChunkClass Class Reference
[OpenGL State Handling]

The classification class for StateChunks, see StateChunkClass for a description. More...

#include <OSGStateChunk.h>

List of all members.

Class Access



typedef std::vector
< std::string >
::const_iterator 
iterator
static const Char8getName (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 Char8getName (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


Detailed Description

See StateChunkClass for the conceptual background.

Definition at line 60 of file OSGStateChunk.h.


Member Typedef Documentation

Iterator type to access the chunk class list.

Definition at line 88 of file OSGStateChunk.h.


Constructor & Destructor Documentation

StateChunkClass::StateChunkClass ( Char8 name,
UInt32  numslots = 1 
)

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 }


Member Function Documentation

UInt32 StateChunkClass::getId ( void   )  const

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

const Char8 * StateChunkClass::getName ( UInt32  index  )  [static]

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 }

Int32 StateChunkClass::getNumSlots ( UInt32  index  )  [static]

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 }


Friends And Related Function Documentation

friend class TextureTransformChunk [friend]

Definition at line 98 of file OSGStateChunk.h.


Member Data Documentation

The numerical ID associated with each StateChunkClass. It is used to uniquely identify and quickly compare the class.

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.

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.

Definition at line 106 of file OSGStateChunk.h.

Referenced by getNumSlots(), getUsedSlots(), and StateChunkClass().


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 11:18:39 2008 for OpenSG by  doxygen 1.5.5