A vector holding GenObjects.  
 More...
#include <yateclass.h>
|  | 
|  | ObjVector (bool autodelete=true, unsigned int allocChunk=0) | 
|  | 
|  | ObjVector (unsigned int maxLen, bool autodelete=true, unsigned int allocChunk=0) | 
|  | 
|  | ObjVector (ObjList &list, bool move=true, unsigned int maxLen=0, bool autodelete=true, unsigned int allocChunk=0) | 
|  | 
| virtual | ~ObjVector () | 
|  | 
| virtual void * | getObject (const String &name) const | 
|  | 
| unsigned int | length () const | 
|  | 
| GenObject ** | data () | 
|  | 
| GenObject ** | data (unsigned int offs, unsigned int len=1) | 
|  | 
| const GenObject ** | data () const | 
|  | 
| const GenObject ** | data (unsigned int offs, unsigned int len=1) const | 
|  | 
| unsigned int | count () const | 
|  | 
| bool | null () const | 
|  | 
| GenObject * | at (unsigned int index) const | 
|  | 
| unsigned int | assign (ObjList &list, bool move=true, unsigned int maxLen=0) | 
|  | 
| unsigned int | insert (unsigned int pos, unsigned int items) | 
|  | 
| unsigned int | cut (unsigned int pos, unsigned int items, bool reAlloc=true) | 
|  | 
| unsigned int | cut (int items, bool reAlloc=true) | 
|  | 
| unsigned int | resize (unsigned int len, bool keepData=false, bool reAlloc=true) | 
|  | 
| unsigned int | compact (bool resizeToCount=false) | 
|  | 
| unsigned int | compact (unsigned int pos, int len) | 
|  | 
| GenObject * | take (unsigned int index) | 
|  | 
| bool | set (GenObject *obj, unsigned int index) | 
|  | 
| bool | appendObj (GenObject *obj) | 
|  | 
| bool | appendObj (GenObject *obj, bool fromStart, bool beforeNonNull=false) | 
|  | 
| bool | insertObj (GenObject *obj, unsigned int pos) | 
|  | 
| int | index (const GenObject *obj) const | 
|  | 
| int | index (const String &str) const | 
|  | 
| int | indexFree (bool fromStart, bool beforeNonNull=false) const | 
|  | 
| GenObject * | operator[] (unsigned int idx) const | 
|  | 
| GenObject * | operator[] (signed int idx) const | 
|  | 
| GenObject * | operator[] (const String &str) const | 
|  | 
| void | clear () | 
|  | 
| void | reset (unsigned int pos=0, int len=-1) | 
|  | 
| bool | autoDelete () | 
|  | 
| void | setDelete (bool autodelete) | 
|  | 
| unsigned int | allocChunk () const | 
|  | 
| void | allocChunk (unsigned int count) | 
|  | 
| unsigned int | size () const | 
|  | 
|  | 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) | 
|  | 
A vector holding GenObjects. 
Simple vector class that holds objects derived from GenObject 
◆ ObjVector() [1/3]
  
  | 
        
          | ObjVector | ( | bool | autodelete = true, |  
          |  |  | unsigned int | allocChunk = 0 ) |  | inlineexplicit | 
 
Constructor of a zero capacity vector 
- Parameters
- 
  
    | autodelete | True to delete objects on destruct, false otherwise |  | allocChunk | How many items to allocate when needed to make space |  
 
 
 
◆ ObjVector() [2/3]
      
        
          | ObjVector | ( | unsigned int | maxLen, | 
        
          |  |  | bool | autodelete = true, | 
        
          |  |  | unsigned int | allocChunk = 0 ) | 
      
 
Constructor of an empty vector 
- Parameters
- 
  
    | maxLen | Maximum number of objects the vector can hold |  | autodelete | True to delete objects on destruct, false otherwise |  | allocChunk | How many items to allocate when needed to make space |  
 
 
 
◆ ObjVector() [3/3]
      
        
          | ObjVector | ( | ObjList & | list, | 
        
          |  |  | bool | move = true, | 
        
          |  |  | unsigned int | maxLen = 0, | 
        
          |  |  | bool | autodelete = true, | 
        
          |  |  | unsigned int | allocChunk = 0 ) | 
      
 
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 |  | allocChunk | How many items to allocate when needed to make space |  
 
 
 
◆ ~ObjVector()
Destroys the vector and the objects if automatic delete is set 
 
 
◆ allocChunk() [1/2]
  
  | 
        
          | unsigned int allocChunk | ( |  | ) | const |  | inline | 
 
Retrieve the length of allocate chunk 
- Returns
- Allocate chunk size 
 
 
◆ allocChunk() [2/2]
  
  | 
        
          | void allocChunk | ( | unsigned int | count | ) |  |  | inline | 
 
Set the length of the allocate chunk 
- Parameters
- 
  
    | count | Length of allocate chunk |  
 
 
 
◆ appendObj() [1/2]
Append an object to vector 
- Parameters
- 
  
    | obj | Object to store in vector |  
 
- Returns
- True for success, false on failure (memory allocation error) 
 
 
◆ appendObj() [2/2]
  
  | 
        
          | bool appendObj | ( | GenObject * | obj, |  
          |  |  | bool | fromStart, |  
          |  |  | bool | beforeNonNull = false ) |  | inline | 
 
Append an object to vector. Trye to use a free (NULL) entry 
- Parameters
- 
  
    | obj | Object to store in vector |  | fromStart | True to check from vector start, false to check from vector end in backward direction |  | beforeNonNull | Stop on first NULL object before first non NULL object |  
 
- Returns
- True for success, false on failure (memory allocation error) 
 
 
◆ assign()
      
        
          | 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 
 
 
◆ at()
Get the object at a specific index in vector 
- Parameters
- 
  
    | index | Index of the object to retrieve |  
 
- Returns
- Pointer to the object or NULL 
 
 
◆ autoDelete()
Get the automatic delete flag 
- Returns
- True if will delete objects on destruct, false otherwise 
 
 
◆ clear()
Clear the vector and optionally delete all contained objects 
 
 
◆ compact() [1/2]
  
  | 
        
          | unsigned int compact | ( | bool | resizeToCount = false | ) |  |  | inline | 
 
Compact vector, move non NULL pointers in front 
- Parameters
- 
  
    | resizeToCount | Resize to non null items count, clears the list if empty |  
 
- Returns
- The number of non NULL pointers 
 
 
◆ compact() [2/2]
      
        
          | unsigned int compact | ( | unsigned int | pos, | 
        
          |  |  | int | len ) | 
      
 
Compact vector, move non NULL pointers at given position 
- Parameters
- 
  
    | pos | Vector position |  | len | Number of items to reset. Negative for all starting with given position |  
 
- Returns
- The number of non NULL pointers in given range 
 
 
◆ count()
      
        
          | unsigned int count | ( |  | ) | const | 
      
 
Get the number of non-null objects in the vector 
- Returns
- Count of items 
 
 
◆ cut() [1/2]
  
  | 
        
          | unsigned int cut | ( | int | items, |  
          |  |  | bool | reAlloc = true ) |  | inline | 
 
Remove items from vector 
- Parameters
- 
  
    | items | Number of items to remove. Negative to remove from start, positive to remove from end |  | reAlloc | Re-allocate buffer. Set it it to false to move/reset data only |  
 
- Returns
- Capacity of the vector 
 
 
◆ cut() [2/2]
      
        
          | unsigned int cut | ( | unsigned int | pos, | 
        
          |  |  | unsigned int | items, | 
        
          |  |  | bool | reAlloc = true ) | 
      
 
Remove items from vector 
- Parameters
- 
  
    | pos | Vector position |  | items | Number of items to remove |  | reAlloc | Re-allocate buffer. Set it it to false to move/reset data only |  
 
- Returns
- Capacity of the vector 
 
 
◆ data() [1/4]
Get a pointer to the stored data. 
- Returns
- A pointer to the data or NULL 
 
 
◆ data() [2/4]
Get a pointer to the stored data. 
- Returns
- A pointer to the data or NULL 
 
 
◆ data() [3/4]
  
  | 
        
          | GenObject ** data | ( | unsigned int | offs, |  
          |  |  | unsigned int | len = 1 ) |  | inline | 
 
Get a pointer to a byte range inside the stored data 
- Parameters
- 
  
    | offs | Byte offset inside the stored data |  | len | Number of bytes that must be valid starting at offset |  
 
- Returns
- A pointer to the data or NULL if the range is not available 
 
 
◆ data() [4/4]
  
  | 
        
          | const GenObject ** data | ( | unsigned int | offs, |  
          |  |  | unsigned int | len = 1 ) const |  | inline | 
 
Get a pointer to a byte range inside the stored data 
- Parameters
- 
  
    | offs | Byte offset inside the stored data |  | len | Number of bytes that must be valid starting at offset |  
 
- Returns
- A pointer to the data or NULL if the range is not available 
 
 
◆ getObject()
  
  | 
        
          | 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.
 
 
◆ index() [1/2]
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 
 
 
◆ index() [2/2]
      
        
          | 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 
 
 
◆ indexFree()
      
        
          | int indexFree | ( | bool | fromStart, | 
        
          |  |  | bool | beforeNonNull = false ) const | 
      
 
Get the position in vector of the first or last NULL object 
- Parameters
- 
  
    | fromStart | True to check from vector start, false to check from vector end in backward direction |  | beforeNonNull | Stop on first NULL object before first non NULL object |  
 
- Returns
- Index of object in vector, -1 if not found 
 
 
◆ insert()
      
        
          | unsigned int insert | ( | unsigned int | pos, | 
        
          |  |  | unsigned int | items ) | 
      
 
Insert NULL items in vector 
- Parameters
- 
  
    | pos | Vector position. Append if past vector length |  | items | Number of items to insert |  
 
- Returns
- Capacity of the vector 
 
 
◆ insertObj()
  
  | 
        
          | bool insertObj | ( | GenObject * | obj, |  
          |  |  | unsigned int | pos ) |  | inline | 
 
Insert an object in vector 
- Parameters
- 
  
    | obj | Object to store in vector |  | pos | Vector position. Append if past vector length |  
 
- Returns
- True for success, false on failure (memory allocation error) 
 
 
◆ length()
  
  | 
        
          | unsigned int length | ( |  | ) | const |  | inline | 
 
Get the capacity of the vector 
- Returns
- Number of items the vector can hold 
 
 
◆ null()
Check if the vector is empty 
- Returns
- True if the vector contains no objects 
 
 
◆ operator[]() [1/3]
Indexing operator with GenObject string value to search 
- Parameters
- 
  
    | str | String value (toString) of the object to search for |  
 
- Returns
- Pointer to the object or NULL 
 
 
◆ operator[]() [2/3]
  
  | 
        
          | GenObject * operator[] | ( | signed int | idx | ) | const |  | inline | 
 
Indexing operator with signed parameter 
- Parameters
- 
  
    | idx | Index of the object to retrieve |  
 
- Returns
- Pointer to the object or NULL 
 
 
◆ operator[]() [3/3]
  
  | 
        
          | GenObject * operator[] | ( | unsigned int | idx | ) | const |  | inline | 
 
Indexing operator with unsigned parameter 
- Parameters
- 
  
    | idx | Index of the object to retrieve |  
 
- Returns
- Pointer to the object or NULL 
 
 
◆ reset()
      
        
          | void reset | ( | unsigned int | pos = 0, | 
        
          |  |  | int | len = -1 ) | 
      
 
Reset vector data. Delete reset item(s) if owned 
- Parameters
- 
  
    | pos | Vector position |  | len | Number of items to reset. Negative to reset all items after given position |  
 
 
 
◆ resize()
  
  | 
        
          | unsigned int resize | ( | unsigned int | len, |  
          |  |  | bool | keepData = false, |  
          |  |  | bool | reAlloc = true ) |  | inline | 
 
Resize the vector. Reset data if not kept Reset (release) vector data if same length and data is not kept 
- Parameters
- 
  
    | len | New vector length |  | keepData | Keep old data |  | reAlloc | Re-allocate buffer. Set it it to false to move/reset data only |  
 
- Returns
- Capacity of the vector 
 
 
◆ set()
      
        
          | 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 
 
 
◆ setDelete()
  
  | 
        
          | void setDelete | ( | bool | autodelete | ) |  |  | inline | 
 
Set the automatic delete flag 
- Parameters
- 
  
    | autodelete | True to delete objects on destruct, false otherwise |  
 
 
 
◆ size()
  
  | 
        
          | unsigned int size | ( |  | ) | const |  | inline | 
 
Retrieve vector size (total allocated items, including over alloc) 
- Returns
- Vector size 
 
 
◆ take()
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: