Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Typedefs | Enumerations | Functions
astobj2_container_private.h File Reference

Common, private definitions for astobj2 containers. More...

#include "asterisk/astobj2.h"

Go to the source code of this file.

Data Structures

struct  ao2_container
 Generic container type. More...
 
struct  ao2_container_methods
 
struct  ao2_container_node
 Generic container node. More...
 

Macros

#define __container_unlink_node(node, flags)   __container_unlink_node_debug(node, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define AO2_TRAVERSAL_STATE_SIZE   100
 

Typedefs

typedef struct ao2_container *(* ao2_container_alloc_empty_clone_fn) (struct ao2_container *self, const char *tag, const char *file, int line, const char *func)
 Create an empty copy of this container. More...
 
typedef void(* ao2_container_destroy_fn) (struct ao2_container *self)
 Destroy this container. More...
 
typedef void(* ao2_container_display) (struct ao2_container *self, void *where, ao2_prnt_fn *prnt, ao2_prnt_obj_fn *prnt_obj)
 Display contents of the specified container. More...
 
typedef void(* ao2_container_find_cleanup_fn) (void *v_state)
 Cleanup the container traversal state. More...
 
typedef struct ao2_container_node *(* ao2_container_find_first_fn) (struct ao2_container *self, enum search_flags flags, void *arg, void *v_state)
 Find the first container node in a traversal. More...
 
typedef struct ao2_container_node *(* ao2_container_find_next_fn) (struct ao2_container *self, void *v_state, struct ao2_container_node *prev)
 Find the next container node in a traversal. More...
 
typedef enum ao2_container_insert(* ao2_container_insert_fn) (struct ao2_container *self, struct ao2_container_node *node)
 Insert a node into this container. More...
 
typedef int(* ao2_container_integrity) (struct ao2_container *self)
 Perform an integrity check on the specified container. More...
 
typedef struct ao2_container_node *(* ao2_container_new_node_fn) (struct ao2_container *self, void *obj_new, const char *tag, const char *file, int line, const char *func)
 Create a new container node. More...
 
typedef void(* ao2_container_statistics) (struct ao2_container *self, void *where, ao2_prnt_fn *prnt)
 Display statistics of the specified container. More...
 
typedef struct ao2_container_node *(* ao2_iterator_next_fn) (struct ao2_container *self, struct ao2_container_node *prev, enum ao2_iterator_flags flags)
 Find the next non-empty iteration node in the container. More...
 
typedef void(* ao2_link_node_stat_fn) (struct ao2_container *container, struct ao2_container_node *node)
 
typedef void(* ao2_unlink_node_stat_fn) (struct ao2_container *container, struct ao2_container_node *node)
 

Enumerations

enum  ao2_callback_type { AO2_CALLBACK_DEFAULT, AO2_CALLBACK_WITH_DATA }
 
enum  ao2_container_insert { AO2_CONTAINER_INSERT_NODE_INSERTED, AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED, AO2_CONTAINER_INSERT_NODE_REJECTED }
 
enum  ao2_unlink_node_flags { AO2_UNLINK_NODE_UNLINK_OBJECT = (1 << 0), AO2_UNLINK_NODE_NOUNREF_OBJECT = (1 << 1), AO2_UNLINK_NODE_UNREF_NODE = (1 << 2), AO2_UNLINK_NODE_DEC_COUNT = (1 << 3) }
 

Functions

int __container_unlink_node_debug (struct ao2_container_node *node, uint32_t flags, const char *tag, const char *file, int line, const char *func)
 
void container_destruct (void *_c)
 
int container_init (void)
 

Detailed Description

Common, private definitions for astobj2 containers.

Author
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file astobj2_container_private.h.

Macro Definition Documentation

#define AO2_TRAVERSAL_STATE_SIZE   100

Allow enough room for container specific traversal state structs

Definition at line 60 of file astobj2_container_private.h.

Typedef Documentation

typedef struct ao2_container*(* ao2_container_alloc_empty_clone_fn) (struct ao2_container *self, const char *tag, const char *file, int line, const char *func)

Create an empty copy of this container.

Parameters
selfContainer to operate upon.
tagused for debugging.
fileDebug file name invoked from
lineDebug line invoked from
funcDebug function name invoked from
Returns
empty-container on success.
Return values
NULLon error.

Definition at line 96 of file astobj2_container_private.h.

typedef void(* ao2_container_destroy_fn) (struct ao2_container *self)

Destroy this container.

Parameters
selfContainer to operate upon.

Definition at line 82 of file astobj2_container_private.h.

typedef void(* ao2_container_display) (struct ao2_container *self, void *where, ao2_prnt_fn *prnt, ao2_prnt_obj_fn *prnt_obj)

Display contents of the specified container.

Parameters
selfContainer to dump.
whereUser data needed by prnt to determine where to put output.
prntPrint output callback function to use.
prnt_objCallback function to print the given object's key. (NULL if not available)

Definition at line 179 of file astobj2_container_private.h.

typedef void(* ao2_container_find_cleanup_fn) (void *v_state)

Cleanup the container traversal state.

Parameters
v_stateTraversal state to cleanup.

Definition at line 154 of file astobj2_container_private.h.

typedef struct ao2_container_node*(* ao2_container_find_first_fn) (struct ao2_container *self, enum search_flags flags, void *arg, void *v_state)

Find the first container node in a traversal.

Parameters
selfContainer to operate upon.
flagssearch_flags to control traversing the container
argComparison callback arg parameter.
v_stateTraversal state to restart container traversal.
Returns
node-ptr of found node (Reffed).
Return values
NULLwhen no node found.

Definition at line 134 of file astobj2_container_private.h.

typedef struct ao2_container_node*(* ao2_container_find_next_fn) (struct ao2_container *self, void *v_state, struct ao2_container_node *prev)

Find the next container node in a traversal.

Parameters
selfContainer to operate upon.
v_stateTraversal state to restart container traversal.
prevPrevious node returned by the traversal search functions. The ref ownership is passed back to this function.
Returns
node-ptr of found node (Reffed).
Return values
NULLwhen no node found.

Definition at line 147 of file astobj2_container_private.h.

typedef enum ao2_container_insert(* ao2_container_insert_fn) (struct ao2_container *self, struct ao2_container_node *node)

Insert a node into this container.

Parameters
selfContainer to operate upon.
nodeContainer node to insert into the container.
Returns
enum ao2_container_insert value.

Definition at line 121 of file astobj2_container_private.h.

typedef int(* ao2_container_integrity) (struct ao2_container *self)

Perform an integrity check on the specified container.

Parameters
selfContainer to check integrity.
Note
The container is already locked for reading.
Return values
0on success.
-1on error.

Definition at line 202 of file astobj2_container_private.h.

typedef struct ao2_container_node*(* ao2_container_new_node_fn) (struct ao2_container *self, void *obj_new, const char *tag, const char *file, int line, const char *func)

Create a new container node.

Parameters
selfContainer to operate upon.
obj_newObject to put into the node.
tagused for debugging.
fileDebug file name invoked from
lineDebug line invoked from
funcDebug function name invoked from
Returns
initialized-node on success.
Return values
NULLon error.

Definition at line 111 of file astobj2_container_private.h.

typedef void(* ao2_container_statistics) (struct ao2_container *self, void *where, ao2_prnt_fn *prnt)

Display statistics of the specified container.

Parameters
selfContainer to display statistics.
whereUser data needed by prnt to determine where to put output.
prntPrint output callback function to use.
Note
The container is already locked for reading.

Definition at line 190 of file astobj2_container_private.h.

typedef struct ao2_container_node*(* ao2_iterator_next_fn) (struct ao2_container *self, struct ao2_container_node *prev, enum ao2_iterator_flags flags)

Find the next non-empty iteration node in the container.

Parameters
selfContainer to operate upon.
prevPrevious node returned by the iterator.
flagssearch_flags to control iterating the container. Only AO2_ITERATOR_DESCENDING is useful by the method.
Note
The container is already locked.
Returns
node on success.
Return values
NULLon error or no more nodes in the container.

Definition at line 169 of file astobj2_container_private.h.

Enumeration Type Documentation

Enumerator
AO2_CONTAINER_INSERT_NODE_INSERTED 

The node was inserted into the container.

AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED 

The node object replaced an existing node object.

AO2_CONTAINER_INSERT_NODE_REJECTED 

The node was rejected (duplicate).

Definition at line 50 of file astobj2_container_private.h.

50  {
51  /*! The node was inserted into the container. */
53  /*! The node object replaced an existing node object. */
55  /*! The node was rejected (duplicate). */
57 };
Enumerator
AO2_UNLINK_NODE_UNLINK_OBJECT 

Remove the node from the object's weak link list OR unref the object if it's a strong reference.

AO2_UNLINK_NODE_NOUNREF_OBJECT 

Modified unlink_object to skip the unref of the object.

AO2_UNLINK_NODE_UNREF_NODE 

Unref the node.

AO2_UNLINK_NODE_DEC_COUNT 

Decrement the container's element count.

Definition at line 33 of file astobj2_container_private.h.

33  {
34  /*! Remove the node from the object's weak link list
35  * OR unref the object if it's a strong reference. */
37  /*! Modified unlink_object to skip the unref of the object. */
39  /*! Unref the node. */
40  AO2_UNLINK_NODE_UNREF_NODE = (1 << 2),
41  /*! Decrement the container's element count. */
42  AO2_UNLINK_NODE_DEC_COUNT = (1 << 3),
43 };