class CCL::LinkableList

Overview

Container class for directly linkable objects. More…

#include <linkablelist.h>

class LinkableList:
    public CCL::Container,
    public Core::IntrusiveLinkedList< Linkable >
{
public:
    // typedefs

    typedef LinkableListIterator IteratorClass;

    // construction

    LinkableList ();
    LinkableList (const Container& objects);
    LinkableList (const LinkableList& objects);

    // methods

    bool mightContain (const Linkable& link) const;
    void swapContent (LinkableList& other);
    virtual Iterator* newIterator () const;
    virtual bool isEmpty () const;
    virtual int count () const;
    virtual Object* at (int idx) const;
    virtual int index (const Object& obj) const;
    virtual int index (const Object* obj) const;
    virtual bool add (Object* obj);
    virtual bool remove (Object* obj);
    virtual void removeAll ();
    virtual Object* findEqual (const Object& obj) const;
    virtual bool addSorted (Object* obj);

    template  <class Element = Object>
    RangeIterator <LinkableList, LinkableListIterator, Element*> begin () const;

    template  <class Element = Object>
    RangeIterator <LinkableList, LinkableListIterator, Element*> end () const;

    virtual bool add (Object* obj);
    void add (const Container& objects, CopyMode mode = kNormal);

    template  <class Predicate>
    Object* findIf (const Predicate& recognize) const;

    template  <class Class, class Predicate>
    Class* findIf (const Predicate& recognize) const;

    template  <class T, class Predicate>
    T* findIf (const Predicate& recognize) const;

    template  <class Predicate>
    int removeIf (const Predicate& recognize);

    template  <class Class, class Predicate>
    int removeIf (const Predicate& recognize);

    bool contains (const Object& obj) const;
    bool contains (const Object* obj) const;
};

Inherited Members

public:
    // typedefs

    typedef CStringRef MemberID;
    typedef Iterator IteratorClass;

    // enums

    enum CopyMode;

    // fields

     IContainer;

    // methods

    virtual tresult CCL_API queryInterface (UIDRef iid, void** ptr) = 0;
    virtual unsigned int CCL_API retain () = 0;
    virtual unsigned int CCL_API release () = 0;
    Unknown& operator = (const Unknown&);
    unsigned int getRetainCount () const;
    virtual Object*CCL_API revealObject (const void* moduleAddress) = 0;
    virtual void CCL_API addObserver (IObserver* observer) = 0;
    virtual void CCL_API removeObserver (IObserver* observer) = 0;
    virtual void CCL_API signal (MessageRef msg) = 0;
    virtual void CCL_API deferSignal (IMessage* msg) = 0;
    static ISubject void addObserver (IUnknown* unknown, IObserver* observer);
    static void removeObserver (IUnknown* unknown, IObserver* observer);
    virtual void CCL_API notify (ISubject* subject, MessageRef msg) = 0;

    static IObserver void notify (
        IUnknown* unknown,
        ISubject* subject,
        MessageRef msg
    );

    virtual const ITypeInfo&CCL_API getTypeInfo () const = 0;
    virtual tbool CCL_API getProperty (Variant& var, MemberID propertyId) const = 0;
    virtual tbool CCL_API setProperty (MemberID propertyId, const Variant& var) = 0;
    virtual tbool CCL_API getPropertyNames (IPropertyCollector& collector) const = 0;
    virtual tbool CCL_API invokeMethod (Variant& returnValue, MessageRef msg) = 0;
    DECLARE_BASE_CLASS (Object);
    virtual void CCL_API removeObserver (IObserver* observer);
    virtual void CCL_API signal (MessageRef msg);
    virtual void CCL_API deferSignal (IMessage* msg);
    virtual void deferChanged ();
    virtual void CCL_API notify (ISubject* subject, MessageRef msg);
    virtual bool equals (const Object& obj) const;
    virtual int compare (const Object& obj) const;
    virtual bool load (const Storage& storage);
    virtual bool save (const Storage& storage) const;
    virtual bool save (const OutputStorage& storage) const;
    virtual bool toString (String& string, int flags = 0) const;
    virtual int getHashCode (int size) const;
    IUnknown* asUnknown ();
    static void addGarbageCollected (Object* obj, bool globalScope = true);
    static void deferDestruction (Object* obj);
    static const void* getModuleAddress ();
    virtual IUnknownIterator*CCL_API createIterator () const = 0;
    DECLARE_CLASS_ABSTRACT (Container, Object);
    void objectCleanup (bool state = true);
    bool isObjectCleanup () const;
    virtual Iterator* newIterator () const = 0;
    virtual bool isEmpty () const = 0;
    virtual int count () const = 0;
    virtual Object* at (int idx) const = 0;
    virtual int index (const Object& obj) const = 0;
    virtual int index (const Object* obj) const = 0;
    virtual bool add (Object* obj) = 0;
    virtual bool remove (Object* obj) = 0;
    virtual void removeAll () = 0;
    virtual Object* findEqual (const Object& obj) const = 0;
    virtual bool addSorted (Object* obj) = 0;

    template  <class Class, class Predicate>
    Class* findIf (const Predicate& recognize) const;

    void add (const Container& objects, CopyMode mode = kNormal);
    virtual bool load (const Storage& storage);
    virtual bool save (const Storage& storage) const;

    template  <class Element = Object>
    RangeIterator <CCL::Container, CCL::Iterator, Element*> begin () const;

    template  <class Element = Object>
    RangeIterator <CCL::Container, CCL::Iterator, Element*> end () const;

Detailed Documentation

Container class for directly linkable objects.

Methods

bool mightContain (const Linkable& link) const

a fast check: false: link is definitely not in list; true: it might be in list (not sure)

virtual Iterator* newIterator () const

Create new iterator.

virtual bool isEmpty () const

Check if container is empty.

virtual int count () const

Count number of items in container.

virtual Object* at (int idx) const

Get object at given index.

virtual int index (const Object& obj) const

Get index of object, compares via Object::equals.

virtual int index (const Object* obj) const

Get index of object, compares object address.

virtual bool add (Object* obj)

Add object.

virtual bool remove (Object* obj)

Remove object, ownership is transfered to caller.

virtual void removeAll ()

Remove (and optionally release) all object.

virtual Object* findEqual (const Object& obj) const

Find equal object.

virtual bool addSorted (Object* obj)

Add object sorted using Object::compare.

virtual bool add (Object* obj)

Add object.

void add (const Container& objects, CopyMode mode = kNormal)

Add from other container using given copy mode.

template  <class Predicate>
Object* findIf (const Predicate& recognize) const

Check if object is contained using lamda function.

Predicate: (Object*) -> bool.

template  <class Class, class Predicate>
Class* findIf (const Predicate& recognize) const

Check if object is contained using lamda function; performs ccl_cast to check type.

Predicate: (Class&) -> bool.

template  <class Predicate>
int removeIf (const Predicate& recognize)

Delete all objects satisfying lambda function, releases object optionally.

Predicate: (Object*) -> bool.

Returns:

number of removed elements

template  <class Class, class Predicate>
int removeIf (const Predicate& recognize)

Delete all objects satisfying lambda function; performs ccl_cast to check type, releases object optionally.

Predicate: (Class&) -> bool.

Returns:

number of removed elements

bool contains (const Object& obj) const

Check if object is contained, compares via Object::equals.

bool contains (const Object* obj) const

Check if object is contained, compares object address.