Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

linklist.hh

Go to the documentation of this file.
00001 
00002 #ifndef LINKED_LIST_HH
00003 #define LINKED_LIST_HH
00004 
00005 #ifndef DO_NOT_USE_RCSLIB
00006 #include "rcs_defs.hh"          /* RCS_EXPORT, EXTERN_C_STD_HEADERS */
00007 #else
00008 #define RCS_EXPORT
00009 #endif
00010 
00011 #ifdef EXTERN_C_STD_HEADERS
00012 extern "C"
00013 {
00014 #endif
00015 
00016 #ifndef UNDER_CE
00017 #include <stddef.h>
00018 #endif
00019 
00020 #ifdef EXTERN_C_STD_HEADERS
00021 }
00022 #endif
00023 
00024 
00025 enum IS_EMPTY
00026 {
00027   LIST_EMPTY,
00028   LIST_NOT_EMPTY
00029 };
00030 
00031 enum LIST_SIZING_MODE
00032 {
00033   DELETE_FROM_HEAD,
00034   DELETE_FROM_TAIL,
00035   STOP_AT_MAX,
00036   NO_MAXIMUM_SIZE
00037 };
00038 
00039 class RCS_EXPORT RCS_LINKED_LIST_NODE
00040 {
00041 public:
00042   void *data;
00043   size_t size;
00044   int id;
00045   int copied;
00046   RCS_LINKED_LIST_NODE *next;
00047   RCS_LINKED_LIST_NODE *last;
00048   friend class LINKED_LIST;
00049     RCS_LINKED_LIST_NODE (void *_data, size_t _size);
00050    ~RCS_LINKED_LIST_NODE ();
00051 };
00052 
00053 class RCS_EXPORT RCS_LINKED_LIST
00054 {
00055 protected:
00056   RCS_LINKED_LIST_NODE * head;
00057   RCS_LINKED_LIST_NODE *tail;
00058   RCS_LINKED_LIST_NODE *current_node;
00059   RCS_LINKED_LIST_NODE *extra_node;
00060   int next_node_id;
00061 public:
00062   int get_current_id ();
00063   int list_size;
00064   int max_list_size;
00065   LIST_SIZING_MODE sizing_mode;
00066   void set_list_sizing_mode (int, LIST_SIZING_MODE);
00067   void set_max_list_size (int);
00068   size_t last_size_retrieved;
00069   int delete_data_not_copied;
00070   void *last_data_retrieved;
00071   int last_copied_retrieved;
00072   void *retrieve_head ();
00073   void *retrieve_tail ();
00074   size_t last_size_stored;
00075   void *last_data_stored;
00076 #ifdef USE_TEMPLATES
00077     template < class T > void store_at_head (T *, int _copy);
00078     template < class T > void store_at_tail (T *, int _copy);
00079   T *get_head_member ();
00080   T *get_tail_member ();
00081   T *get_next_member ();
00082   T *get_last_member ();
00083 #endif                          /* USE_TEMPLATES */
00084   int store_at_head (void *_data, size_t _size, int _copy);
00085   int store_at_tail (void *_data, size_t _size, int _copy);
00086   int store_after_current_node (void *_data, size_t _size, int _copy);
00087   int store_before_current_node (void *_data, size_t _size, int _copy);
00088   int get_newest_id ()
00089   {
00090     return (next_node_id - 1);
00091   }
00092   void *get_head ();
00093   void *get_tail ();
00094   void *get_next ();
00095   void *get_last ();
00096   void *find_node (int _node_number);
00097   void delete_node (int _id);
00098   void delete_current_node ();
00099   void *get_by_id (int _id);
00100   void *get_first_newer (int _id);
00101   void *get_last_newer (int _id);
00102   IS_EMPTY is_empty ();
00103   void flush_list ();
00104   void delete_members ();
00105     RCS_LINKED_LIST ();
00106    ~RCS_LINKED_LIST ();
00107 
00108 private:
00109     RCS_LINKED_LIST (RCS_LINKED_LIST & list);   // Don't copy me.
00110 };
00111 
00112 #ifdef USE_TEMPLATES
00113 /* NOTE:  actual code for template member function definitions must
00114    be included in the header file, since this code does not generate
00115    any executable when compiled-- it needs to be templated before this
00116    can occur. */
00117 
00118 template < class T > void
00119 RCS_LINKED_LIST::store_at_head (T * _Tptr, int _copy)
00120 {
00121   store_at_head ((void *) _Tptr, sizeof (T), _copy);
00122 }
00123 
00124 template < class T > void
00125 RCS_LINKED_LIST::store_at_tail (T * _Tptr, int _copy)
00126 {
00127   store_at_tail ((void *) _Tptr, sizeof (T), _copy);
00128 }
00129 
00130 template < class T > T * RCS_LINKED_LIST::get_head_member ();
00131 {
00132   return ((T *) get_head ());
00133 }
00134 
00135 template < class T > T * RCS_LINKED_LIST::get_tail_member ();
00136 {
00137   return ((T *) get_tail ());
00138 }
00139 
00140 template < class T > T * RCS_LINKED_LIST::get_next_member ();
00141 {
00142   return ((T *) get_next ());
00143 }
00144 
00145 template < class T > T * RCS_LINKED_LIST::get_last_member ();
00146 {
00147   return ((T *) get_last ());
00148 }
00149 
00150 #endif /* USE_TEMPLATES */
00151 
00152 
00153 #endif /* LINKED_LIST_HH */

Generated on Sun Dec 2 15:56:50 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001