Yate

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
ObjVector Class Reference

A vector holding GenObjects. More...

`#include <yateclass.h>`

Inheritance diagram for ObjVector:

## Public Member Functions
| ObjVector (bool autodelete=true)
| ObjVector (unsigned int maxLen, bool autodelete=true)
| ObjVector (ObjList &list, bool move=true, unsigned int maxLen=0, bool autodelete=true)
virtual | ~ObjVector ()
virtual void * | getObject (const String &name) const
unsigned int | length () const
unsigned int | count () const
bool | null () const
GenObject * | at (int index) const
GenObject * | operator[] (signed int index) const
GenObject * | operator[] (unsigned int index) const
unsigned int | assign (ObjList &list, bool move=true, unsigned int maxLen=0)
GenObject * | take (unsigned int index)
bool | set (GenObject *obj, unsigned int index)
int | index (const GenObject *obj) const
int | index (const String &str) const
void | clear ()
bool | autoDelete ()
void | setDelete (bool autodelete)
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)

## Additional Inherited Members
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

A vector holding GenObjects.

Simple vector class that holds objects derived from GenObject

## Constructor & Destructor Documentation

ObjVector | ( | bool | autodelete = `true` | ) |
| inline explicit

Constructor of a zero capacity vector

Parameters

  autodelete | True to delete objects on destruct, false otherwise

ObjVector | ( | unsigned int | maxLen,
|  | bool | autodelete = `true`
| ) |  |

Constructor of an empty vector

Parameters

  maxLen | Maximum number of objects the vector can hold
  autodelete | True to delete objects on destruct, false otherwise

ObjVector | ( | ObjList & | list,
|  | bool | move = `true`,
|  | unsigned int | maxLen = `0`,
|  | bool | autodelete = `true`
| ) |  |

Constructor from an object list

Parameters

  list | List of objects to store in vector
  move | True to move elements from list, false to just copy the pointer
  maxLen | Maximum number of objects to put in vector, zero to put all
  autodelete | True to delete objects on destruct, false otherwise

virtual ~ObjVector | ( |  | ) |
| virtual

Destroys the vector and the objects if automatic delete is set

## Member Function Documentation

unsigned int assign | ( | ObjList & | list,
|  | bool | move = `true`,
|  | unsigned int | maxLen = `0`
| ) |  |

Clear the vector and assign objects from a list

Parameters

  list | List of objects to store in vector
  move | True to move elements from list, false to just copy the pointer
  maxLen | Maximum number of objects to put in vector, zero to put all

Returns
  Capacity of the vector

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

Get the object at a specific index in vector

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the object or NULL

References ObjVector::index().

Referenced by ObjVector::operator[]().

bool autoDelete | ( |  | ) |
| inline

Get the automatic delete flag

Returns
  True if will delete objects on destruct, false otherwise

void clear | ( |  | ) |

Clear the vector and optionally delete all contained objects

unsigned int count | ( |  | ) | const

Get the number of non-null objects in the vector

Returns
  Count of items

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 vector of a GenObject by a pointer to it

Parameters

  obj | Pointer to the object to search for

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

Referenced by ObjVector::at().

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

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

Parameters

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

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

unsigned int length | ( |  | ) | const
| inline

Get the capacity of the vector

Returns
  Number of items the vector can hold

bool null | ( |  | ) | const

Check if the vector is empty

Returns
  True if the vector contains no objects

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

Indexing operator with signed parameter

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the object or NULL

References ObjVector::at().

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

Indexing operator with unsigned parameter

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the object or NULL

References ObjVector::at().

bool set | ( | GenObject * | obj,
|  | unsigned int | index
| ) |  |

Store an object in the vector

Parameters

  obj | Object to store in vector
  index | Index of the object to store

Returns
  True for success, false if index was out of bounds

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

Set the automatic delete flag

Parameters

  autodelete | True to delete objects on destruct, false otherwise

GenObject* take | ( | unsigned int | index | ) |

Retrieve and remove an object from the vector

Parameters

  index | Index of the object to retrieve

Returns
  Pointer to the stored object, NULL for out of bound index

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

- yateclass.h