![]() Home Page Toolkit Overview Using GML User Input Services Finger Tracker Calibrator Frame Grabber Service protocol Obtaining GML Installing GML Licence Developer Documentation Tcl/Tk API The GML Canvas Image processing Tcl Scripts Library List of Classes List of Files C/C++ API List of Classes List of Files |
gml_NewList.h00001 /** gml_List.h 00002 * 00003 * Definition of gml_TList. 00004 * 00005 * Copyright (c) 2003-2004 CLIPS-IMAG 00006 * 00007 * See the file "gml_LicenseTerms.txt" for information on usage and redistribution 00008 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 00009 * 00010 * Created on May 21, 2003 (FB). 00011 */ 00012 00013 00014 #ifndef __GML_LIST__ 00015 #define __GML_LIST__ 00016 00017 #include "gml/base/gml_Types.h" 00018 #include "gml/base/gml_Errors.h" 00019 00020 /// 00021 /// gml_TListSortFunc -- 00022 /// The prototype of functions that compare two elements <left> and <right>, 00023 /// and return an integer that is greater than, equal to, or less than 0, according as 00024 /// <left> is greater than, equal to, or less than <right>. 00025 /// 00026 typedef int (gml_TListSortFunc) (void* left, void* right); 00027 00028 00029 /// 00030 /// gml_ListSortStringFunc -- 00031 /// 00032 /// Element-sorting routine that compares C (0-terminated) strings using strcmp. 00033 /// 00034 extern int gml_ListSortStringFunc (void* left, void* right); 00035 00036 /// 00037 /// gml_ListSortIntFunc -- 00038 /// 00039 /// Element-sorting routine that compares signed integers. 00040 /// 00041 extern int gml_ListSortIntFunc (void* left, void* right); 00042 00043 00044 00045 /// 00046 /// gml_TList -- 00047 /// A list of elements. 00048 /// 00049 template <class T> 00050 class gml_TList 00051 { 00052 class Elem 00053 { 00054 public: 00055 00056 void Dispose(); 00057 00058 Elem* Previous (); 00059 Elem* Next (); 00060 00061 void Set (T const value); 00062 T Get (); 00063 00064 gml_TError Append (T); 00065 gml_TError Append (gml_TList<T>*); 00066 gml_TError Prepend (T); 00067 gml_TError Prepend (gml_TList<T>*); 00068 00069 protected: 00070 void Init (); 00071 00072 T fValue; 00073 Elem* fNext; 00074 Elem* fPrevious; 00075 gml_TList<T>* fList; 00076 } 00077 00078 public: 00079 00080 gml_TError Init (); 00081 00082 void Dispose (); 00083 00084 Elem* Head (); 00085 Elem* Tail (); 00086 00087 Elem* Null (); 00088 00089 protected: 00090 00091 Elem* fHead; ///< the first element in this list 00092 Elem* fTail; ///< the last element in this list 00093 00094 Elem* fNull; 00095 00096 static 00097 gml_TBoolean fClassInited; 00098 00099 static 00100 void ClassInit(); 00101 }; 00102 00103 00104 template <class T> 00105 void gml_TList<T>::Elem::Dispose () 00106 { 00107 assert (fPrevious != NULL); 00108 assert (fNext != NULL); 00109 assert (fList != NULL); 00110 00111 if (fPrevious == gml_TList<T>::Null ()) { 00112 fList->fHead = fNext; 00113 } else { 00114 fPrevious->fNext = fNext; 00115 } 00116 00117 if (fNext == gml_TList<T>::Null ()) { 00118 fList->Tail = fPrevious; 00119 } else { 00120 fNext->fPrevious = fPrevious; 00121 } 00122 00123 fPrevious = (gml_TList<T>::Elem*)NULL; 00124 fNext = (gml_TList<T>::Elem*)NULL; 00125 fList = (gml_TList<T>*)NULL; 00126 gml_Zero (&fValue); 00127 } 00128 00129 00130 template <class T> 00131 gml_TList<T>::Elem* gml_TList<T>::Elem::Previous () 00132 { 00133 return fPrevious; 00134 } 00135 00136 template <class T> 00137 gml_TList<T>::Elem* gml_TList<T>::Elem::Next () 00138 { 00139 return fNext; 00140 } 00141 00142 template <class T> 00143 void gml_TList<T>::Elem::Set (T const value) 00144 { 00145 fValue = value; 00146 } 00147 00148 template <class T> 00149 T gml_TList<T>::Elem::Get () 00150 { 00151 return fValue; 00152 } 00153 00154 template <class T> 00155 T gml_TList<T>::Elem::Init () 00156 { 00157 fPrevious = gml_TList<T>::Null (); 00158 fNext = gml_TList<T>::Null (); 00159 fList = (gml_TList<T>*)NULL; 00160 00161 gml_Zero (&fValue); 00162 } 00163 00164 template <class T> 00165 gml_TBoolean gml_TList<T>::fClassInited = gml_cFalse; 00166 00167 #endif 00168
Generated on Tue Jun 12 14:03:27 2007 for gml by
Doxygen 1.5.2.
|
Contact: julien (dot) letessier (at) gmail (dot) com.
Copyright (c) 2000-2007 CLIPS-IMAG Laboratory, Grenoble, France. All rights reserved. W3CXHTML 1.0 W3CCSS 2.0 |