Wed Oct 28 11:46:23 2009

Asterisk developer's documentation


AstObj2 Containers

Containers are data structures meant to store several objects, and perform various operations on them. Internally, objects are stored in lists, hash tables or other data structures depending on the needs.

Note:
NOTA BENE: at the moment the only container we support is the hash table and its degenerate form, the list.
Operations on container include:

       struct ao2_container *c = ... // our container
       struct ao2_iterator i;
       void *o;

       i = ao2_iterator_init(c, flags);
     
       while ( (o = ao2_iterator_next(&i)) ) {
      ... do something on o ...
      ao2_ref(o, -1);
       }

       ao2_iterator_destroy(&i);

The difference with the callback is that the control on how to iterate is left to us.

Containers are ao2 objects themselves, and this is why their implementation is simple too.

Before declaring containers, we need to declare the types of the arguments passed to the constructor - in turn, this requires to define callback and hash functions and their arguments.


Generated on Wed Oct 28 11:46:23 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6