Yate
Public Member Functions | List of all members
Array Class Reference

A list based Array. More...

#include <yateclass.h>

Inheritance diagram for Array:
RefObject GenObject

Public Member Functions

 Array (int columns=0, int rows=0)
 
virtual ~Array ()
 
virtual void * getObject (const String &name) const
 
bool addRow (ObjList *row=0, int index=-1)
 
bool addColumn (ObjList *column=0, int index=-1)
 
bool delRow (int index)
 
bool delColumn (int index)
 
GenObjectget (int column, int row) const
 
GenObjecttake (int column, int row)
 
bool set (GenObject *obj, int column, int row)
 
int getRows () const
 
int getColumns () const
 
ObjListgetColumn (int column) const
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtoString () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Additional Inherited Members

- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- 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 NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 

Detailed Description

A list based Array.

A simple Array class derivated from RefObject It uses one ObjList to keep the pointers to other ObjList's. Data is organized in columns - the main ObjList holds pointers to one ObjList for each column. This class has been written by Diana

Constructor & Destructor Documentation

Array ( int  columns = 0,
int  rows = 0 
)
explicit

Creates a new empty array.

Parameters
columnsInitial number of columns
rowsInitial number of rows
virtual ~Array ( )
virtual

Destructor. Destructs all objects in the array

Member Function Documentation

bool addColumn ( ObjList column = 0,
int  index = -1 
)

Insert a column of objects

Parameters
columnList of objects to insert or NULL
indexNumber of the column to insert before, negative to append
Returns
True for success, false if index was larger than the array
bool addRow ( ObjList row = 0,
int  index = -1 
)

Insert a row of objects

Parameters
rowList of objects to insert or NULL
indexNumber of the row to insert before, negative to append
Returns
True for success, false if index was larger than the array
bool delColumn ( int  index)

Delete an entire column of objects

Parameters
indexNumber of the column to delete
Returns
True for success, false if index was out of bounds
bool delRow ( int  index)

Delete an entire row of objects

Parameters
indexNumber of the row to delete
Returns
True for success, false if index was out of bounds
GenObject* get ( int  column,
int  row 
) const

Retrieve an object from the array

Parameters
columnNumber of the column in the array
rowNumber of the row in the array
Returns
Pointer to the stored object, NULL for out of bound indexes
ObjList* getColumn ( int  column) const
inline

Retrieve a column. Note: Use the returned list only to get or set data. List items must not be removed or appended

Parameters
columnColumn to retrieve
Returns
Pointer to column list, NULL for out of bound indexes
int getColumns ( ) const
inline

Get the number of columns in the array

Returns
Total number of columns
virtual void* getObject ( const String name) const
virtual

Get a pointer to a derived class given that class name

Parameters
nameName of the class we are asking for
Returns
Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from RefObject.

int getRows ( ) const
inline

Get the number of rows in the array

Returns
Total number of rows
bool set ( GenObject obj,
int  column,
int  row 
)

Store an object in the array

Parameters
objObject to store in the array
columnNumber of the column in the array
rowNumber of the row in the array
Returns
True for success, false if indexes were out of bounds
GenObject* take ( int  column,
int  row 
)

Retrieve and remove an object from the array

Parameters
columnNumber of the column in the array
rowNumber of the row in the array
Returns
Pointer to the stored object, NULL for out of bound indexes

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