datastore.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2007 - 2008, Digium, Inc.
00005  *
00006  * See http://www.asterisk.org for more information about
00007  * the Asterisk project. Please do not directly contact
00008  * any of the maintainers of this project for assistance;
00009  * the project provides a web site, mailing lists and IRC
00010  * channels for your use.
00011  *
00012  * This program is free software, distributed under the terms of
00013  * the GNU General Public License Version 2. See the LICENSE file
00014  * at the top of the source tree.
00015  */
00016 
00017 /*! \file
00018  * \brief Asterisk datastore objects
00019  */
00020 
00021 #ifndef _ASTERISK_DATASTORE_H
00022 #define _ASTERISK_DATASTORE_H
00023 
00024 #if defined(__cplusplus) || defined(c_plusplus)
00025 extern "C" {
00026 #endif
00027 
00028 #include "asterisk/linkedlists.h"
00029 
00030 /*! \brief Structure for a data store type */
00031 struct ast_datastore_info {
00032    const char *type;       /*!< Type of data store */
00033    void *(*duplicate)(void *data);     /*!< Duplicate item data (used for inheritance) */
00034    void (*destroy)(void *data);     /*!< Destroy function */
00035 
00036    /*!
00037     * \brief Fix up channel references on the masquerading channel
00038     *
00039     * \arg data The datastore data
00040     * \arg old_chan The old channel owning the datastore
00041     * \arg new_chan The new channel owning the datastore
00042     *
00043     * This is exactly like the fixup callback of the channel technology interface.
00044     * It allows a datastore to fix any pointers it saved to the owning channel
00045     * in case that the owning channel has changed.  Generally, this would happen
00046     * when the datastore is set to be inherited, and a masquerade occurs.
00047     *
00048     * \return nothing.
00049     */
00050    void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
00051 
00052    /*!
00053     * \brief Fix up channel references on the channel being masqueraded into
00054     *
00055     * \arg data The datastore data
00056     * \arg old_chan The old channel owning the datastore
00057     * \arg new_chan The new channel owning the datastore
00058     *
00059     * This is the same as the above callback, except it is called for the channel
00060     * being masqueraded into instead of the channel that is masquerading.
00061     *
00062     * \return nothing.
00063     */
00064    void (*chan_breakdown)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
00065 };
00066 
00067 /*! \brief Structure for a data store object */
00068 struct ast_datastore {
00069    const char *uid;        /*!< Unique data store identifier */
00070    void *data;          /*!< Contained data */
00071    const struct ast_datastore_info *info; /*!< Data store type information */
00072    unsigned int inheritance;     /*!< Number of levels this item will continue to be inherited */
00073    AST_LIST_ENTRY(ast_datastore) entry;   /*!< Used for easy linking */
00074 };
00075 
00076 /*!
00077  * \brief Create a data store object
00078  * \param[in] info information describing the data store object
00079  * \param[in] uid unique identifer
00080  * \param file, line, function
00081  * \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc
00082  */
00083 struct ast_datastore * attribute_malloc __ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid,
00084                            const char *file, int line, const char *function);
00085 
00086 #define ast_datastore_alloc(info, uid) __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
00087 
00088 /*!
00089  * \brief Free a data store object
00090  * \param[in] datastore datastore to free
00091  * \version 1.6.1 moved here and renamed from ast_channel_datastore_free
00092  */
00093 int ast_datastore_free(struct ast_datastore *datastore);
00094 
00095 #if defined(__cplusplus) || defined(c_plusplus)
00096 }
00097 #endif
00098 
00099 #endif /* _ASTERISK_DATASTORE_H */

Generated on Thu Apr 16 06:27:32 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6