00001 /* 00002 * 00003 * Copyright (C) 1994-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmdata 00019 * 00020 * Author: Gerd Ehlers 00021 * 00022 * Purpose: generic list class 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:28:20 $ 00026 * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dclist.h,v $ 00027 * CVS/RCS Revision: $Revision: 1.16 $ 00028 * Status: $State: Exp $ 00029 * 00030 * CVS/RCS Log at end of file 00031 * 00032 */ 00033 00034 #ifndef DCLIST_H 00035 #define DCLIST_H 00036 00037 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00038 #include "dcmtk/dcmdata/dcerror.h" 00039 #include "dcmtk/dcmdata/dctypes.h" 00040 00041 #define INCLUDE_CSTDDEF 00042 #define INCLUDE_CSTDLIB 00043 #include "dcmtk/ofstd/ofstdinc.h" 00044 00045 00046 const unsigned long DCM_EndOfListIndex = OFstatic_cast(unsigned long, -1L); 00047 00048 00049 class DcmObject; // forward declaration 00050 00051 00052 class DcmListNode { 00053 friend class DcmList; 00054 DcmListNode *nextNode; 00055 DcmListNode *prevNode; 00056 DcmObject *objNodeValue; 00057 00058 // --- declarations to avoid compiler warnings 00059 00060 DcmListNode(const DcmListNode &); 00061 DcmListNode &operator=(const DcmListNode &); 00062 00063 public: 00064 DcmListNode( DcmObject *obj ); 00065 ~DcmListNode(); 00066 inline DcmObject *value() { return objNodeValue; } 00067 }; 00068 00069 00070 typedef enum 00071 { 00072 ELP_atpos, 00073 ELP_first, 00074 ELP_last, 00075 ELP_prev, 00076 ELP_next 00077 } E_ListPos; 00078 00079 /* this class only manages pointers to elements. 00080 * remove() does not delete the element pointed to. 00081 * Upon destruction of the list, all elements pointed to are also deleted. 00082 */ 00083 00084 class DcmList { 00085 DcmListNode *firstNode; 00086 DcmListNode *lastNode; 00087 DcmListNode *currentNode; 00088 unsigned long cardinality; 00089 00090 // --- declarations to avoid compiler warnings 00091 00092 DcmList &operator=(const DcmList &); 00093 DcmList(const DcmList &newList); 00094 00095 public: 00096 DcmList(); 00097 ~DcmList(); 00098 00099 DcmObject *append( DcmObject *obj ); 00100 DcmObject *prepend( DcmObject *obj ); 00101 DcmObject *insert( DcmObject *obj, 00102 E_ListPos pos = ELP_next ); 00103 DcmObject *remove(); 00104 DcmObject *get( E_ListPos pos = ELP_atpos ); 00105 DcmObject *seek( E_ListPos pos = ELP_next ); 00106 DcmObject *seek_to(unsigned long absolute_position); 00107 inline unsigned long card() const { return cardinality; } 00108 inline OFBool empty(void) const { return firstNode == NULL; } 00109 inline OFBool valid(void) const { return currentNode != NULL; } 00110 }; 00111 00112 #endif // DCLIST_H 00113 00114 00115 /* 00116 * CVS/RCS Log: 00117 * $Log: dclist.h,v $ 00118 * Revision 1.16 2005/12/08 16:28:20 meichel 00119 * Changed include path schema for all DCMTK header files 00120 * 00121 * Revision 1.15 2003/08/08 13:32:45 joergr 00122 * Adapted type casts to new-style typecast operators defined in ofcast.h. 00123 * 00124 * Revision 1.14 2003/08/08 12:30:38 joergr 00125 * Made DcmListNode::value() inline. 00126 * Renamed member variable "actualNode" to "currentNode". 00127 * 00128 * Revision 1.13 2002/11/27 12:07:22 meichel 00129 * Adapted module dcmdata to use of new header file ofstdinc.h 00130 * 00131 * Revision 1.12 2001/06/01 15:48:41 meichel 00132 * Updated copyright header 00133 * 00134 * Revision 1.11 2000/03/08 16:26:15 meichel 00135 * Updated copyright header. 00136 * 00137 * Revision 1.10 2000/02/23 15:11:38 meichel 00138 * Corrected macro for Borland C++ Builder 4 workaround. 00139 * 00140 * Revision 1.9 2000/02/01 10:12:02 meichel 00141 * Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4, 00142 * workaround for bug in compiler header files. 00143 * 00144 * Revision 1.8 1999/03/31 09:24:41 meichel 00145 * Updated copyright header in module dcmdata 00146 * 00147 * 00148 */