CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vertexlistwalker.h

00001 /*
00002   Copyright (C) 2005 by Marten Svanfeldt
00003 
00004   This library is free software; you can redistribute it and/or
00005   modify it under the terms of the GNU Library General Public
00006   License as published by the Free Software Foundation; either
00007   version 2 of the License, or (at your option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012   Library General Public License for more details.
00013 
00014   You should have received a copy of the GNU Library General Public
00015   License along with this library; if not, write to the Free
00016   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_CSGFX_VERTEXLISTWALKER_H__
00020 #define __CS_CSGFX_VERTEXLISTWALKER_H__
00021 
00026 template<class T>
00027 class csVertexListWalker
00028 {
00029 public:
00036   csVertexListWalker (void *listPointer, size_t elements, size_t dist = sizeof(T))
00037     : list ((uint8*)listPointer), elements (elements), dist (dist), currElement (0)
00038   {
00039     if (dist == 0)
00040       this->dist = sizeof(T);
00041   }
00042 
00044   T& operator*()
00045   {
00046     return *((T*)(list+currElement*dist));
00047   }
00048 
00050   T& operator[] (size_t n)
00051   {
00052     CS_ASSERT (n<elements);
00053     return *((T*)(list+n*dist));
00054   }
00055 
00057   void operator++ ()
00058   {
00059     currElement++;
00060     CS_ASSERT(currElement<elements);
00061   }
00062 
00063 private:
00065   uint8 *list;
00067   size_t elements;
00069   size_t dist;
00071   size_t currElement;
00072 };
00073 
00074 #endif

Generated for Crystal Space by doxygen 1.4.4