Yate: ObjList Class Reference

Yate

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | List of all members
ObjList Class Reference

An object list class. More...

`#include <yateclass.h>`

Inheritance diagram for ObjList:

## 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
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)
void | sort (int(*callbackCompare)(GenObject *obj1, GenObject *obj2, void *context), void *context=0)
Public Member Functions inherited from GenObject
| 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 Public Member Functions inherited from GenObject
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 ()

## Detailed Description

An object list class.

A simple single-linked object list handling class

## Constructor & Destructor Documentation

ObjList | ( |  | ) |

Creates a new, empty list.

virtual ~ObjList | ( |  | ) |
| virtual

Destroys the list and everything in it.

## Member Function Documentation

ObjList* append | ( | const GenObject * | obj,
|  | bool | compact = `true`
| ) |  |

Append an object to the end of the list

Parameters

  obj | Pointer to the object to append
  compact | True to replace NULL values in list if possible

Returns
  A pointer to the inserted list item

Referenced by MimeLinesBody::addLine(), ClientChannel::addSlave(), CapturedEvent::append(), MimeMultipartBody::appendBody(), and MimeBody::appendHdr().

GenObject* at | ( | int | index | ) | const

Get the object at a specific index in list

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the object or NULL

Referenced by ObjList::operator[]().

bool autoDelete | ( |  | ) |
| inline

Get the automatic delete flag

Returns
  True if will delete on destruct, false otherwise

void clear | ( |  | ) |

Clear the list and optionally delete all contained objects

Referenced by MessageDispatcher::clear(), XmlFragment::clearChildren(), and NamedList::clearParams().

void compact | ( |  | ) |

Remove all empty objects in the list

unsigned int count | ( |  | ) | const

Get the number of non-null objects in the list

Returns
  Count of items

Referenced by Configuration::count(), NamedList::count(), and ClientChannel::slavesCount().

static const ObjList& empty | ( |  | ) |
| static

A static empty object list

Returns
  Reference to a static empty list

Referenced by XmlParent::getChildren().

ObjList* find | ( | const GenObject * | obj | ) | const

Get the item in the list that holds an object

Parameters

  obj | Pointer to the object to search for

Returns
  Pointer to the found item or NULL

Referenced by ClientChannel::addSlave(), UIFactory::canBuild(), ClientDir::findChildName(), XmlElement::findNextChild(), and NamedInt::lookup().

ObjList* find | ( | const String & | str | ) | const

Get the item in the list that holds an object by String value

Parameters

  str | String value (toString) of the object to search for

Returns
  Pointer to the found item or NULL

GenObject* get | ( |  | ) | const
| inline

Get the object associated to this list item

Returns
  Pointer to the object or NULL

Referenced by ClientDir::findChildName(), MessageDispatcher::hasHandlers(), MessageDispatcher::hasHooks(), MessageDispatcher::hasMessages(), and NamedInt::lookup().

virtual void* getObject | ( | const String & | name | ) | const
| virtual

Get a pointer to a derived class given that class name

Parameters

  name | Name of the class we are asking for

Returns
  Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from GenObject.

int index | ( | const GenObject * | obj | ) | const

Get the position in list of a GenObject by a pointer to it

Parameters

  obj | Pointer to the object to search for

Returns
  Index of object in list, -1 if not found

int index | ( | const String & | str | ) | const

Get the position in list of the first GenObject with a given value

Parameters

  str | String value (toString) of the object to search for

Returns
  Index of object in list, -1 if not found

ObjList* insert | ( | const GenObject * | obj,
|  | bool | compact = `true`
| ) |  |

Insert an object at this point

Parameters

  obj | Pointer to the object to insert
  compact | True to replace NULL values in list if possible

Returns
  A pointer to the inserted list item

ObjList* last | ( |  | ) | const

Get the last item in the list

Returns
  Pointer to the last item in list

unsigned int length | ( |  | ) | const

Get the number of elements in the list

Returns
  Count of items

Referenced by NamedList::length(), and Configuration::sections().

ObjList* next | ( |  | ) | const
| inline

Get the next item in the list

Returns
  Pointer to the next item in list or NULL

Referenced by MessageDispatcher::hasHandlers(), MessageDispatcher::hasHooks(), and MessageDispatcher::hasMessages().

ObjList* operator+ | ( | int | index | ) | const

Pointer-like indexing operator

Parameters

  index | Index of the list item to retrieve

Returns
  Pointer to the list item or NULL

GenObject* operator[] | ( | signed int | index | ) | const
| inline

Array-like indexing operator with signed parameter

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the object or NULL

References ObjList::at().

GenObject* operator[] | ( | unsigned int | index | ) | const
| inline

Array-like indexing operator with unsigned parameter

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the object or NULL

References ObjList::at().

GenObject* operator[] | ( | const String & | str | ) | const

Array-like indexing operator

Parameters

  str | String value of the object to locate

Returns
  Pointer to the object or NULL

GenObject* remove | ( | bool | delobj = `true` | ) |

Delete this list item

Parameters

  delobj | True to delete the object (default)

Returns
  Pointer to the object if not destroyed

Referenced by XmlFragment::pop(), HashList::remove(), MimeMultipartBody::removeBody(), MimeBody::removeHdr(), and ClientChannel::removeSlave().

GenObject* remove | ( | GenObject * | obj,
|  | bool | delobj = `true`
| ) |  |

Delete the list item that holds a given object

Parameters

  obj | Object to search in the list
  delobj | True to delete the object (default)

Returns
  Pointer to the object if not destroyed

GenObject* remove | ( | const String & | str,
|  | bool | delobj = `true`
| ) |  |

Delete the first list item that holds an object with a iven value

Parameters

  str | String value (toString) of the object to remove
  delobj | True to delete the object (default)

Returns
  Pointer to the object if not destroyed

GenObject* set | ( | const GenObject * | obj,
|  | bool | delold = `true`
| ) |  |

Set the object associated to this list item

Parameters

  obj | Pointer to the new object to set
  delold | True to delete the old object (default)

Returns
  Pointer to the old object if not destroyed

void setDelete | ( | bool | autodelete | ) |
| inline

Set the automatic delete flag

Parameters

  autodelete | True to delete on destruct, false otherwise

ObjList* setUnique | ( | const GenObject * | obj,
|  | bool | compact = `true`
| ) |  |

Set unique entry in this list. If not found, append it to the list

Parameters

  obj | Pointer to the object to uniquely set in the list
  compact | True to replace NULL values in list if possible

Returns
  A pointer to the set list item

Referenced by NamedList::setParam().

ObjList* skipNext | ( |  | ) | const

Advance in the list skipping over NULL holding items

Returns
  Pointer to the next non NULL holding item in list or NULL

Referenced by XmlElement::findNextChild(), and NamedInt::lookupName().

ObjList* skipNull | ( |  | ) | const

Skip over NULL holding items in the list

Returns
  Pointer to the first non NULL holding item in list or NULL

Referenced by DataTranslator::getConsumers(), XmlParent::hasChildren(), NamedInt::lookupName(), ClientContact::online(), NamedIterator::operator=(), and NamedIterator::reset().

void sort | ( | int(*)(GenObject *obj1, GenObject *obj2, void *context) | callbackCompare,
|  | void * | context = `0`
| ) |  |

Sort this list

Parameters

  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.

The documentation for this class was generated from the following file:

- yateclass.h