00001 /* 00002 EyeDB Object Database Management System 00003 Copyright (C) 1994-2008 SYSRA 00004 00005 EyeDB is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 EyeDB is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00018 */ 00019 00020 /* 00021 Author: Eric Viara <viara@sysra.com> 00022 */ 00023 00024 00025 #ifndef _EYEDBLIB_LINKLIST_H 00026 #define _EYEDBLIB_LINKLIST_H 00027 00028 #ifndef NO_IDB_LINKED_LIST 00029 00030 namespace eyedb { 00031 00032 class LinkedListCursor; 00033 class Link; 00034 00035 class LinkedList { 00036 00037 // ---------------------------------------------------------------------- 00038 // LinkedList Interface 00039 // ---------------------------------------------------------------------- 00040 public: 00041 00045 LinkedList(); 00046 00052 int insertObject(void *o); 00053 00059 int insertObjectLast(void *o); 00060 00066 int insertObjectFirst(void *o); 00067 00073 void *getObject(int pos) const; 00074 00080 int deleteObject(void *o); 00081 00087 int deleteObject(int pos); 00088 00094 int getPos(void *o) const; 00095 00100 int getCount() const; 00101 00106 void *getFirstObject() const; 00107 00112 void *getLastObject() const; 00113 00118 LinkedListCursor *startScan() const; 00119 00126 int getNextObject(LinkedListCursor *cursor, void* &o) const; 00127 00132 void endScan(LinkedListCursor *cursor) const; 00133 00139 void applyToObjects(void (*f)(void *, void *), void *user_arg) const; 00140 00145 void empty(); 00146 00147 ~LinkedList(); 00148 00149 // ---------------------------------------------------------------------- 00150 // Linked Private Part 00151 // ---------------------------------------------------------------------- 00152 private: 00153 int link_cnt; 00154 Link *f_link, *l_link; 00155 void delete_realize(Link *); 00156 00157 friend class LinkedListCursor; 00158 }; 00159 00160 class LinkedListCursor { 00161 00162 // ---------------------------------------------------------------------- 00163 // LinkedListCursor Interface 00164 // ---------------------------------------------------------------------- 00165 public: 00166 LinkedListCursor(const LinkedList &); 00167 LinkedListCursor(const LinkedList *); 00168 00169 int getNext(void* &); 00170 00171 void restart(); 00172 00173 ~LinkedListCursor() {} 00174 00175 private: 00176 friend class LinkedList; 00177 Link *link; 00178 LinkedList *list; 00179 }; 00180 00181 } 00182 00183 #endif 00184 00185 #endif