Yate
|
An object list class. More...
#include <yateclass.h>
Public Member Functions | |
ObjList () | |
virtual | ~ObjList () |
virtual void * | getObject (const String &name) const |
unsigned int | length () const |
unsigned int | count () const |
GenObject * | get () const |
GenObject * | set (const GenObject *obj, bool delold=true) |
ObjList * | next () const |
ObjList * | last () const |
ObjList * | skipNull () const |
ObjList * | skipNext () const |
GenObject * | at (int index) const |
ObjList * | operator+ (int index) const |
GenObject * | operator[] (signed int index) const |
GenObject * | operator[] (unsigned int index) const |
GenObject * | operator[] (const String &str) const |
ObjList * | find (const GenObject *obj) const |
GenObject * | findObj (const GenObject *obj) const |
ObjList * | find (const String &str) const |
int | index (const GenObject *obj) const |
int | index (const String &str) const |
ObjList * | insert (const GenObject *obj, bool compact=true) |
ObjList * | append (const GenObject *obj, bool compact=true) |
ObjList * | setUnique (const GenObject *obj, bool compact=true) |
GenObject * | remove (bool delobj=true) |
GenObject * | remove (GenObject *obj, bool delobj=true) |
GenObject * | remove (const String &str, bool delobj=true) |
void | clear () |
void | compact () |
bool | autoDelete () |
void | setDelete (bool autodelete) |
GenObject * | find (Lockable &lock, const GenObject *obj, bool ref=false, long maxwait=-1) const |
GenObject * | find (Lockable &lock, const String &str, bool ref=false, long maxwait=-1) const |
ObjList * | insert (Lockable &lock, const GenObject *obj, bool autoDelete=true, long maxwait=-1, bool compact=true) |
ObjList * | append (Lockable &lock, const GenObject *obj, bool autoDelete=true, long maxwait=-1, bool compact=true) |
ObjList * | setUnique (Lockable &lock, const GenObject *obj, bool autoDelete=true, long maxwait=-1, bool compact=true) |
GenObject * | remove (Lockable &lock, bool delobj=true, long maxwait=-1) |
GenObject * | remove (Lockable &lock, GenObject *obj, bool delobj=true, long maxwait=-1) |
GenObject * | remove (Lockable &lock, const String &str, bool delobj=true, long maxwait=-1) |
void | clear (Lockable &lock, long maxwait=-1) |
void | compact (Lockable &lock, long maxwait=-1) |
ObjList * | move (ObjList *dest, Lockable *lock=0, long maxwait=-1) |
ObjList * | copy (ObjList *dest, Lockable *lock=0, long maxwait=-1) const |
void | sort (int(*callbackCompare)(GenObject *obj1, GenObject *obj2, void *context), void *context=0) |
![]() | |
GenObject () | |
virtual | ~GenObject () |
virtual bool | alive () const |
virtual void | destruct () |
virtual const String & | toString () const |
virtual const String & | traceId () const |
NamedCounter * | getObjCounter () const |
NamedCounter * | setObjCounter (NamedCounter *counter) |
Static Public Member Functions | |
static const ObjList & | empty () |
![]() | |
static void * | getObject (const String &name, const GenObject *obj) |
static bool | getObjCounting () |
static void | setObjCounting (bool enable) |
static NamedCounter * | getObjCounter (const String &name, bool create=true) |
static ObjList & | getObjCounters () |
An object list class.
A simple single-linked object list handling class
ObjList | ( | ) |
Creates a new, empty list.
|
virtual |
Destroys the list and everything in it.
Append an object to the end of the list
obj | Pointer to the object to append |
compact | True to replace NULL values in list if possible |
Referenced by MimeLinesBody::addLine(), ClientChannel::addSlave(), MimeMultipartBody::appendBody(), and MimeBody::appendHdr().
ObjList * append | ( | Lockable & | lock, |
const GenObject * | obj, | ||
bool | autoDelete = true, | ||
long | maxwait = -1, | ||
bool | compact = true ) |
Append an object to the end of the list
lock | Lockable to protect the operation. A RWLock will be write locked |
obj | Pointer to the object to set |
autoDelete | Object autoDelete flag |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
compact | True to replace NULL values in list if possible |
GenObject * at | ( | int | index | ) | const |
Get the object at a specific index in list
index | Index of the object to retrieve |
|
inline |
Get the automatic delete flag
void clear | ( | ) |
Clear the list and optionally delete all contained objects
Referenced by XmlFragment::clearChildren().
void clear | ( | Lockable & | lock, |
long | maxwait = -1 ) |
void compact | ( | ) |
Remove all empty objects in the list
void compact | ( | Lockable & | lock, |
long | maxwait = -1 ) |
Reference all items in this into another one
dest | Destination list. Create a new one if not given |
lock | Optional Lockable to protect the operation. A RWLock will be read locked |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
unsigned int count | ( | ) | const |
Get the number of non-null objects in the list
Referenced by GenericVector< Obj >::append(), MatchingItemList::append(), GenericVector< Obj >::assign(), Configuration::count(), and ClientChannel::slavesCount().
|
static |
A static empty object list
Referenced by XmlParent::getChildren().
Get the item in the list that holds an object
obj | Pointer to the object to search for |
Referenced by ClientChannel::addSlave(), UIFactory::canBuild(), ClientDir::findChildName(), XmlElement::findNextChild(), and NamedInt::lookup().
GenObject * find | ( | Lockable & | lock, |
const GenObject * | obj, | ||
bool | ref = false, | ||
long | maxwait = -1 ) const |
Get the item in the list that holds an object
lock | Lockable to protect the operation. A RWLock will be read locked |
obj | Pointer to the object to search for |
ref | True to reference a found RefObject. the method will return NULL if a found object is not a RefObject one |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
Get the item in the list that holds an object by String value
lock | Lockable to protect the operation. A RWLock will be read locked |
str | String value (toString) of the object to search for |
ref | True to reference a found RefObject. the method will return NULL if a found object is not a RefObject one |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
Find an object by pointer
obj | Pointer to the object to search for |
References get().
|
inline |
Get the object associated to this list item
Referenced by ClientDir::findChildName(), findObj(), XmlFragment::getText(), MessageDispatcher::hasHandlers(), MessageDispatcher::hasHooks(), MessageDispatcher::hasMessages(), NamedInt::lookup(), and operator[]().
|
virtual |
Get a pointer to a derived class given that class name
name | Name of the class we are asking for |
Reimplemented from GenObject.
int index | ( | const GenObject * | obj | ) | const |
Get the position in list of a GenObject by a pointer to it
obj | Pointer to the object to search for |
int index | ( | const String & | str | ) | const |
Insert an object at this point
obj | Pointer to the object to insert |
compact | True to replace NULL values in list if possible |
ObjList * insert | ( | Lockable & | lock, |
const GenObject * | obj, | ||
bool | autoDelete = true, | ||
long | maxwait = -1, | ||
bool | compact = true ) |
Insert an object at this point
lock | Lockable to protect the operation. A RWLock will be write locked |
obj | Pointer to the object to set |
autoDelete | Object autoDelete flag |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
compact | True to replace NULL values in list if possible |
ObjList * last | ( | ) | const |
Get the last item in the list
unsigned int length | ( | ) | const |
Get the number of elements in the list
Referenced by Configuration::sections().
Move or copy this list into another one autoDelete() is set in destination as found for each item in list
dest | Destination list. Create a new one if not given |
lock | Optional Lockable to protect the operation. A RWLock will be write locked |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
|
inline |
Get the next item in the list
Referenced by MessageDispatcher::hasHandlers(), MessageDispatcher::hasHooks(), and MessageDispatcher::hasMessages().
ObjList * operator+ | ( | int | index | ) | const |
Pointer-like indexing operator
index | Index of the list item to retrieve |
|
inline |
Array-like indexing operator with signed parameter
index | Index of the object to retrieve |
|
inline |
Array-like indexing operator with unsigned parameter
index | Index of the object to retrieve |
GenObject * remove | ( | bool | delobj = true | ) |
Delete this list item
delobj | True to delete the object (default) |
Referenced by MatchingItemList::append(), XmlFragment::pop(), HashList::remove(), HashList::remove(), MimeMultipartBody::removeBody(), MimeBody::removeHdr(), and ClientChannel::removeSlave().
Delete the first list item that holds an object with a iven value
str | String value (toString) of the object to remove |
delobj | True to delete the object (default) |
Delete the list item that holds a given object
obj | Object to search in the list |
delobj | True to delete the object (default) |
Delete the first list item that holds an object with a iven value
lock | Optional Lockable to protect the operation. A RWLock will be write locked |
str | String value (toString) of the object to remove |
delobj | True to delete the object (default) |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
Delete the list item that holds a given object
lock | Optional Lockable to protect the operation. A RWLock will be write locked |
obj | Object to search in the list |
delobj | True to delete the object (default) |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
Set the object associated to this list item
obj | Pointer to the new object to set |
delold | True to delete the old object (default) |
|
inline |
Set the automatic delete flag
autodelete | True to delete on destruct, false otherwise |
Set unique entry in this list. If not found, append it to the list
obj | Pointer to the object to uniquely set in the list |
compact | True to replace NULL values in list if possible |
ObjList * setUnique | ( | Lockable & | lock, |
const GenObject * | obj, | ||
bool | autoDelete = true, | ||
long | maxwait = -1, | ||
bool | compact = true ) |
Set unique entry in this list. If not found, append it to the list
lock | Lockable to protect the operation. A RWLock will be write locked |
obj | Pointer to the object to set |
autoDelete | Object autoDelete flag |
maxwait | Time in microseconds to wait for locking, -1 wait forever |
compact | True to replace NULL values in list if possible |
ObjList * skipNext | ( | ) | const |
Advance in the list skipping over NULL holding items
Referenced by XmlElement::findNextChild(), XmlFragment::getText(), Module::itemComplete(), and NamedInt::lookupName().
ObjList * skipNull | ( | ) | const |
Skip over NULL holding items in the list
Referenced by MatchingItemList::append(), DataTranslator::getConsumers(), XmlParent::hasChildren(), Module::itemComplete(), NamedInt::lookupName(), ClientContact::online(), and NamedIterator::operator=().
void sort | ( | int(* | callbackCompare )(GenObject *obj1, GenObject *obj2, void *context), |
void * | context = 0 ) |
Sort this list
callbackCompare | pointer to a callback function that should compare two objects. obj1 First object of the comparation obj2 Second object of the comparation context Data context return 0 if the objects are equal; positive value if obj2 > obj1; negative value if obj1 > obj2 Note: the function should expect receiving null pointers |
context | Context data. |