Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: VDR Plugin System - First Step



Excuse me for my unqualified comment, but wouldn't it be way better and safer 
to use STL containers like vector instead of implementing your own linked 
list ? The behaviour of these containers is well known to every C++ 
developer, they are well tested and offer a good range of access methods.

On Friday 10 May 2002 11:53, you wrote:
> Stefan Huelswitt wrote:
> > On 09 May 2002 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:
> > > I suggest that the authors of VDR patches try to implement the "command
> > > line", "menu", "setup" and "i18n" parts of their patches, using the new
> > > plugin features, and let me know which remaining functions they would
> > > still need to patch VDR source files for. What I already am planning to
> > > implement are generalized
> >
> > Just had a quick view at the documentation. Sounds goods. I
> > haven't created any code until now, but I see something missing
> > for me: you cannot insert a listobject in the middle of a list. I
> > would suggest:
> >
> > void cListObject::Insert(cListObject *Object)
> > {
> >   if(next) { // Allow inserting an object in the middle of the list
> >     next->prev = Object;
> >     Object->next = next;
> >     }
> >   Append(Object);
> > }
> >
> > void cListBase::Add(cListObject *Object, cListObject *AfterThis)
> > {
> >   if (lastObject) {
> >      if(AfterThis) { AfterThis->Insert(Object); return; }
> >      lastObject->Append(Object);
> >      }
> >   else
> >      objects = Object;
> >   lastObject = Object;
> > }
> >
> > with the declaration (for default behaviour):
> >
> >   void Add(cListObject *Object, cListObject *AfterThis=NULL);
> >
> > And for the MenuItem handling (to add an item below the current):
> >
> > void cOsdMenu::Insert(cOsdItem *Item, bool Current)
> > {
> >   cList<cOsdItem>::Add(Item,Get(current));
> >   if (Current)
> >      current = Item->Index();
> > }
>
> I'm not sure if this is the right way to do this.
>
> With your method you won't be able to insert an item before the very first
> item of a list - and I guess a common solution should provide this
> capability.
>
> So I'd suggest that cListObject::Insert(cListObject *Object) should insert
> 'Object' *before* the cListObject, and maybe it would be better to call
> that function cListObject::Prepend(cListObject *Object) then (according to
> the other function being called 'Append()').
>
> Consequently cListBase::Add(cListObject *Object, cListObject *AfterThis)
> should be accompanied by a new cListBase::Ins(cListObject *Object,
> cListObject *BeforeThis) to allow full flexibility.
>
> Finally, cOsdMenu::Add() should be the one offering to add *after* a given
> item, and cOsdMenu::Ins() should insert *before* a given item.
>
> Klaus




Home | Main Index | Thread Index