diff options
Diffstat (limited to 'mcast/netcv2dvbip/clist.h')
-rw-r--r-- | mcast/netcv2dvbip/clist.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mcast/netcv2dvbip/clist.h b/mcast/netcv2dvbip/clist.h new file mode 100644 index 0000000..d44da28 --- /dev/null +++ b/mcast/netcv2dvbip/clist.h @@ -0,0 +1,60 @@ +/* + * tools.h: Various tools + * + * See the main source file 'vdr.c' for copyright information and + * how to reach the author. + * + * $Id: tools.h 2.2 2009/04/14 20:41:39 kls Exp $ + */ + +#ifndef __LIST_H +#define __LIST_H + +//#include "misc.h" + +class cListObject { +private: + cListObject *prev, *next; +public: + cListObject(void); + virtual ~cListObject(); + virtual int Compare(const cListObject &ListObject) const { return 0; } + ///< Must return 0 if this object is equal to ListObject, a positive value + ///< if it is "greater", and a negative value if it is "smaller". + void Append(cListObject *Object); + void Insert(cListObject *Object); + void Unlink(void); + int Index(void) const; + cListObject *Prev(void) const { return prev; } + cListObject *Next(void) const { return next; } + }; + +class cListBase { +protected: + cListObject *objects, *lastObject; + cListBase(void); + int count; +public: + virtual ~cListBase(); + void Add(cListObject *Object, cListObject *After = NULL); + void Ins(cListObject *Object, cListObject *Before = NULL); + void Del(cListObject *Object, bool DeleteObject = true); + virtual void Move(int From, int To); + void Move(cListObject *From, cListObject *To); + virtual void Clear(void); + cListObject *Get(int Index) const; + int Count(void) const { return count; } + void Sort(void); + }; + +template<class T> class cList : public cListBase { +public: + T *Get(int Index) const { return (T *)cListBase::Get(Index); } + T *First(void) const { return (T *)objects; } + T *Last(void) const { return (T *)lastObject; } + T *Prev(const T *object) const { return (T *)object->cListObject::Prev(); } // need to call cListObject's members to + T *Next(const T *object) const { return (T *)object->cListObject::Next(); } // avoid ambiguities in case of a "list of lists" + }; + + +#endif //__LIST_H |