[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3.2 Typed Vectors

Typed vectors are the type-safe equivalent to the csVector class. They work similar to templates, but use #define's instead. Using one of these macros, you can create a vector class for a specific type of objects. There are several different macros which produce slightly different behaviour:

CS_DECLARE_TYPED_VECTOR
The standard macro. The elements of the vector are accessible like those of csVector. Objects which are removed with the DeleteIt parameter set to true, or objects left in the vector at destruction are deleted with the delete operator.

CS_DECLARE_TYPED_VECTOR_NODELETE
Like the above, but removed objects are never deleted. Instead, the pointer is just thrown away.

CS_DECLARE_TYPED_VECTOR_DECREF
Like the above, but removed objects are cast to iBase and DecRef() is called.

CS_DECLARE_TYPED_RESTRICTED_ACCESS_VECTOR
This vector is completely different from the above. Its elements cannot be accessed directly (i.e. with operator[]), but only by real methods. For every added object, PrepareItem() is called; for every removed object, FreeItem() is called. This time it really applies to every object, since there is no DeleteIt parameter for methods that can remove elements.

CS_DECLARE_TYPED_IBASE_VECTOR
An example where restricted access vectors are useful. This vector holds a counted reference to all contained objects.

In addition, so-called object vectors are provided. They are specially suited to contain objects of type csObject and add special methods, for example to find an object by name. These macros are:

CS_DECLARE_OBJECT_VECTOR_NOREF(NAME,TYPE)
Object vector equivalent to CS_DECLARE_TYPED_VECTOR_NODELETE.

CS_DECLARE_RESTRICTED_ACCESS_OBJECT_VECTOR(NAME,TYPE)
Object vector equivalent to CS_DECLARE_TYPED_RESTRICTED_ACCESS_VECTOR.

CS_DECLARE_OBJECT_VECTOR(NAME,TYPE)
Object vector equivalent to CS_DECLARE_TYPED_IBASE_VECTOR.



This document was generated using texi2html