- Main Page
- Classes
- Files
- Directories
- Related Pages

# imagenode.h

    00001 #ifndef KYRA_IMAGENODE_INCLUDED
    00002 #define KYRA_IMAGENODE_INCLUDED
    00003
    00004 #include "../util/kyralist.h"
    00005 #include "SDL.h"
    00006 #include "../util/glmath.h"
    00007
    00008 /*
    00009 class KrImage;
    00010
    00011
    00012 class KrImageNode
    00013 {
    00014         friend class KrImageNodeIterator;
    00015
    00016   public:
    00018         KrImageNode()                                   { next = this; prev = this; image = 0; }
    00019
    00021         KrImageNode( KrImage* _image )  { next = this; prev = this; image = _image; }
    00022
    00023         virtual ~KrImageNode()                  {}
    00024
    00025         KrImageNode*    Next() const    { return next; }
    00026         KrImageNode*    Prev() const    { return prev; }
    00027         KrImage*                Image() const   { return image; }
    00028         bool IsSentinel() const                 { return !image; }
    00029         bool InList() const                             { return !(( next == this ) && ( prev == this )); }
    00030
    00032         void InsertBefore( KrImageNode* addMe )
    00033         {
    00034                 GLASSERT( !addMe->IsSentinel() );
    00035                 addMe->prev = prev;
    00036                 prev->next = addMe;
    00037                 prev = addMe;
    00038                 addMe->next = this;
    00039         }
    00040
    00042         void InsertAfter( KrImageNode* addMe )
    00043         {
    00044                 GLASSERT( !addMe->IsSentinel() );
    00045                 addMe->prev = this;
    00046                 addMe->next = next;
    00047                 next->prev = addMe;
    00048                 next = addMe;
    00049         }
    00050
    00052         void Remove()
    00053         {
    00054                 prev->next = next;
    00055                 next->prev = prev;
    00056                 prev = next = this;             // assume sentinel, again.
    00057         }
    00058
    00059   private:
    00060         // Adding data members really stinks -- it increases the size
    00061         // of the sentinels, and a ScanList has a bunch of sentinels.
    00062         KrImageNode* next;
    00063         KrImageNode* prev;
    00064         KrImage*         image;
    00065 };
    00066
    00067
    00068 class KrImageNodeIterator
    00069 {
    00070   public:
    00071         KrImageNodeIterator( KrImageNode& _sentinel )    : sentinel( &_sentinel ), current( 0 ) { GLASSERT( sentinel->IsSentinel() ); }
    00072
    00073         KrImageNode*    CurrentNode()   { return current; }
    00074         KrImage*                CurrentImage()  { return current->image; }
    00075         void                    SetCurrent( KrImageNode* c )    { current = c; }
    00076
    00077         void Begin()    { current = sentinel->next; }
    00078         void Next()             { current = current->next; }
    00079         void Prev()             { current = current->prev; }
    00080         bool Done()             { return current->IsSentinel(); }
    00081
    00082         void InsertBefore( KrImageNode& addMe ) { current->InsertBefore( &addMe ); }
    00083         void InsertAfter(  KrImageNode& addMe ) { current->InsertAfter( &addMe ); }
    00084
    00085   private:
    00086         KrImageNode*    sentinel;
    00087         KrImageNode*    current;
    00088 };
    00089 */
    00090
    00091 #endif