00001 /*--License: 00002 Kyra Sprite Engine 00003 Copyright Lee Thomason (Grinning Lizard Software) 2001-2002 00004 www.grinninglizard.com/kyra 00005 www.sourceforge.net/projects/kyra 00006 00007 Kyra is provided under 2 licenses: 00008 00009 - The GPL, with no additional restrictions. 00010 - The LGPL, provided you display the Kyra splash screen, described below. 00011 00012 00013 --- GPL License -- 00014 This program is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License 00016 as published by the Free Software Foundation; either version 2 00017 of the License, or (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 00028 The full text of the license can be found in license.txt 00029 00030 00031 --- LGPL License -- 00032 **Provided you kindly display the Kyra splash screen (details below), 00033 you may use the LGPL license:** 00034 00035 This library is free software; you can redistribute it and/or 00036 modify it under the terms of the GNU Lesser General Public 00037 License as published by the Free Software Foundation; either 00038 version 2.1 of the License, or (at your option) any later version. 00039 00040 This library is distributed in the hope that it will be useful, 00041 but WITHOUT ANY WARRANTY; without even the implied warranty of 00042 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00043 Lesser General Public License for more details. 00044 00045 You should have received a copy of the GNU Lesser General Public 00046 License along with this library; if not, write to the Free Software 00047 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00048 00049 The full text of the license can be found in lgpl.txt 00050 00051 00052 --- Kyra Splash Screen. 00053 00054 It would be appreciate if you display the Kyra splash screen when using 00055 either license, however it is only required for the LGPL. All the 00056 resources for the splash are compiled into the library, and it can be 00057 accessed through the following API: 00058 00059 KrEngine::StartSplash 00060 KrEngine::UpdateSplash 00061 KrEngine::EndSplash 00062 00063 Full documentation is provided with the KrEngine class. The splash screen 00064 should be displayed for 2 seconds. 00065 00066 Thank you. 00067 */ 00068 00069 #ifndef INPLACE_IMAGENODE_INCLUDED 00070 #define INPLACE_IMAGENODE_INCLUDED 00071 00072 #include "../util/gldebug.h" 00073 00074 // The type of this must be a pointer. 00075 template <class T> 00076 class GlInsideNode 00077 { 00078 public: 00080 GlInsideNode() { next = this; prev = this; data = 0; } 00081 00083 GlInsideNode( T _data ) { next = this; prev = this; data = _data; } 00084 00085 virtual ~GlInsideNode() {} 00086 00087 bool IsSentinel() const { return !data; } 00088 bool InList() const { return !(( next == this ) && ( prev == this )); } 00089 00091 void InsertBefore( GlInsideNode<T>* addMe ) 00092 { 00093 GLASSERT( !addMe->IsSentinel() ); 00094 addMe->prev = prev; 00095 prev->next = addMe; 00096 prev = addMe; 00097 addMe->next = this; 00098 } 00099 00101 void InsertAfter( GlInsideNode<T>* addMe ) 00102 { 00103 GLASSERT( !addMe->IsSentinel() ); 00104 addMe->prev = this; 00105 addMe->next = next; 00106 next->prev = addMe; 00107 next = addMe; 00108 } 00109 00111 void Remove() 00112 { 00113 prev->next = next; 00114 next->prev = prev; 00115 prev = next = this; // assume sentinel, again. 00116 } 00117 00118 // Should be private, but I don't feel like fighting with 00119 // making templates friends. 00120 00121 GlInsideNode<T>* next; 00122 GlInsideNode<T>* prev; 00123 T data; 00124 }; 00125 00126 00127 template <class T> 00128 class GlInsideNodeIt 00129 { 00130 public: 00131 GlInsideNodeIt( GlInsideNode<T>& _sentinel ) 00132 : sentinel( &_sentinel ), current( 0 ) 00133 { 00134 GLASSERT( sentinel->IsSentinel() ); 00135 } 00136 00137 GlInsideNode<T>* CurrentNode() { return current; } 00138 T CurrentData() { return current->data; } 00139 void SetCurrent( GlInsideNode<T>* c ) { current = c; } 00140 00141 void Begin() { current = sentinel->next; } 00142 void Last() { current = sentinel->prev; } 00143 void Next() { current = current->next; } 00144 void Prev() { current = current->prev; } 00145 bool Done() { return current->IsSentinel(); } 00146 00147 void InsertBefore( GlInsideNode<T>& addMe ) { current->InsertBefore( &addMe ); } 00148 void InsertAfter( GlInsideNode<T>& addMe ) { current->InsertAfter( &addMe ); } 00149 00150 private: 00151 GlInsideNode<T>* sentinel; 00152 GlInsideNode<T>* current; 00153 }; 00154 00155 00156 #endif