00001 /* 00002 * 00003 * Copyright (C) 1994-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmdata 00015 * 00016 * Author: Gerd Ehlers 00017 * 00018 * Purpose: generic list class 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:15:41 $ 00022 * CVS/RCS Revision: $Revision: 1.22 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCLIST_H 00030 #define DCLIST_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 00034 #include "dcmtk/ofstd/ofcast.h" 00035 #include "dcmtk/ofstd/oftypes.h" 00036 00037 #define INCLUDE_CSTDDEF 00038 #define INCLUDE_CSTDLIB 00039 #include "dcmtk/ofstd/ofstdinc.h" 00040 #include "dcmtk/dcmdata/dcobject.h" 00041 00043 const unsigned long DCM_EndOfListIndex = OFstatic_cast(unsigned long, -1L); 00044 00047 class DcmListNode 00048 { 00049 00050 public: 00054 DcmListNode( DcmObject *obj ); 00055 00057 ~DcmListNode(); 00058 00060 inline DcmObject *value() { return objNodeValue; } 00061 00062 private: 00063 friend class DcmList; 00064 00066 DcmListNode *nextNode; 00067 00069 DcmListNode *prevNode; 00070 00072 DcmObject *objNodeValue; 00073 00075 DcmListNode(const DcmListNode &); 00076 00078 DcmListNode &operator=(const DcmListNode &); 00079 00080 }; 00081 00083 typedef enum 00084 { 00086 ELP_atpos, 00087 00089 ELP_first, 00090 00092 ELP_last, 00093 00095 ELP_prev, 00096 00098 ELP_next 00099 } E_ListPos; 00100 00105 class DcmList 00106 { 00107 public: 00109 DcmList(); 00110 00112 ~DcmList(); 00113 00118 DcmObject *append( DcmObject *obj ); 00119 00124 DcmObject *prepend( DcmObject *obj ); 00125 00131 DcmObject *insert( DcmObject *obj, 00132 E_ListPos pos = ELP_next ); 00133 00137 DcmObject *remove(); 00138 00143 DcmObject *get( E_ListPos pos = ELP_atpos ); 00144 00150 DcmObject *seek( E_ListPos pos = ELP_next ); 00151 00157 DcmObject *seek_to(unsigned long absolute_position); 00158 00163 void deleteAllElements(); 00164 00166 inline unsigned long card() const { return cardinality; } 00167 00169 inline OFBool empty(void) const { return firstNode == NULL; } 00170 00172 inline OFBool valid(void) const { return currentNode != NULL; } 00173 00174 private: 00176 DcmListNode *firstNode; 00177 00179 DcmListNode *lastNode; 00180 00182 DcmListNode *currentNode; 00183 00185 unsigned long cardinality; 00186 00188 DcmList &operator=(const DcmList &); 00189 00191 DcmList(const DcmList &newList); 00192 }; 00193 00194 #endif // DCLIST_H 00195 00196 00197 /* 00198 * CVS/RCS Log: 00199 * $Log: dclist.h,v $ 00200 * Revision 1.22 2010-10-14 13:15:41 joergr 00201 * Updated copyright header. Added reference to COPYRIGHT file. 00202 * 00203 * Revision 1.21 2010-03-24 11:52:55 onken 00204 * Introduced new function to delete all elements (including memory de-allocation) 00205 * from DcmList. 00206 * 00207 * Revision 1.20 2010-03-01 09:08:44 uli 00208 * Removed some unnecessary include directives in the headers. 00209 * 00210 * Revision 1.19 2010-02-22 11:39:53 uli 00211 * Remove some unneeded includes. 00212 * 00213 * Revision 1.18 2009-11-04 09:58:07 uli 00214 * Switched to logging mechanism provided by the "new" oflog module 00215 * 00216 * Revision 1.17 2007-11-29 14:30:35 meichel 00217 * Updated doxygen API documentation 00218 * 00219 * Revision 1.16 2005/12/08 16:28:20 meichel 00220 * Changed include path schema for all DCMTK header files 00221 * 00222 * Revision 1.15 2003/08/08 13:32:45 joergr 00223 * Adapted type casts to new-style typecast operators defined in ofcast.h. 00224 * 00225 * Revision 1.14 2003/08/08 12:30:38 joergr 00226 * Made DcmListNode::value() inline. 00227 * Renamed member variable "actualNode" to "currentNode". 00228 * 00229 * Revision 1.13 2002/11/27 12:07:22 meichel 00230 * Adapted module dcmdata to use of new header file ofstdinc.h 00231 * 00232 * Revision 1.12 2001/06/01 15:48:41 meichel 00233 * Updated copyright header 00234 * 00235 * Revision 1.11 2000/03/08 16:26:15 meichel 00236 * Updated copyright header. 00237 * 00238 * Revision 1.10 2000/02/23 15:11:38 meichel 00239 * Corrected macro for Borland C++ Builder 4 workaround. 00240 * 00241 * Revision 1.9 2000/02/01 10:12:02 meichel 00242 * Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4, 00243 * workaround for bug in compiler header files. 00244 * 00245 * Revision 1.8 1999/03/31 09:24:41 meichel 00246 * Updated copyright header in module dcmdata 00247 * 00248 * 00249 */