Merge another change from team/russell/events

This commit breaks out some logic from pbx.c into a simple API.  The hint
processing code had logic for taking the state from multiple devices and
turning that into the state for a single extension.  So, I broke this out
and made an API that lets you take multiple device states and determine
the aggregate device state.  I needed this for some core device state changes
to support distributed device state.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121501 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2008-06-10 14:06:29 +00:00
parent 51602928e3
commit 42c1e3601e
3 changed files with 160 additions and 65 deletions

View File

@@ -196,6 +196,54 @@ int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
*/
int ast_devstate_prov_del(const char *label);
/*!
* \brief An object to hold state when calculating aggregate device state
*/
struct ast_devstate_aggregate;
/*!
* \brief Initialize aggregate device state
*
* \arg agg the state object
*
* \return nothing
*/
void ast_devstate_aggregate_init(struct ast_devstate_aggregate *agg);
/*!
* \brief Add a device state to the aggregate device state
*
* \arg agg the state object
* \arg state the state to add
*
* \return nothing
*/
void ast_devstate_aggregate_add(struct ast_devstate_aggregate *agg, enum ast_device_state state);
/*!
* \brief Get the aggregate device state result
*
* \arg agg the state object
*
* \return the aggregate device state after adding some number of device states.
*/
enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg);
/*!
* \brief You shouldn't care about the contents of this struct
*
* This struct is only here so that it can be easily declared on the stack.
*/
struct ast_devstate_aggregate {
unsigned int all_unavail:1;
unsigned int all_busy:1;
unsigned int all_free:1;
unsigned int all_on_hold:1;
unsigned int busy:1;
unsigned int in_use:1;
unsigned int ring:1;
};
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif