aboutsummaryrefslogtreecommitdiffstats
path: root/doc/datastores.txt
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-10 23:29:50 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-10 23:29:50 +0000
commit483e826311511fc52ec00a0155582a73fd2db625 (patch)
tree165b92004e41c726c99721800866bd38eb63faf7 /doc/datastores.txt
parent31b2a51bfb374fb3789b8b69abf2e0f428935d3c (diff)
Presenting a revised data stores and oh my, a generic speech recognition API! I wonder what we can do with this now...
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@18979 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'doc/datastores.txt')
-rw-r--r--doc/datastores.txt68
1 files changed, 68 insertions, 0 deletions
diff --git a/doc/datastores.txt b/doc/datastores.txt
new file mode 100644
index 000000000..a3aa9c27f
--- /dev/null
+++ b/doc/datastores.txt
@@ -0,0 +1,68 @@
+Asterisk Channel Data Stores
+============================
+
+* What is a data store?
+
+A data store is a way of storing complex data (such as a structure) on a channel
+so it can be retrieved at a later time by another application, or the same application.
+
+If the data store is not freed by said application though, a callback to a destroy function
+occurs which frees the memory used by the data in the data store so no memory loss occurs.
+
+* A datastore info structure
+static const struct example_datastore {
+ .type = "example",
+ .destroy = callback_destroy
+};
+
+This is a needed structure that contains information about a datastore, it's used by many API calls.
+
+* How do you create a data store?
+
+1. Use ast_channel_datastore_alloc function to return a pre-allocated structure
+ Ex: datastore = ast_channel_datastore_alloc(&example_datastore, "uid");
+ This function takes two arguments: (datastore info structure, uid)
+2. Attach data and destroy callback to pre-allocated structure.
+ Ex: datastore->data = mysillydata;
+ datastore->destroy = callback_destroy;
+3. Add datastore to the channel
+ Ex: ast_channel_datastore_add(chan, datastore);
+ This function takes two arguments: (pointer to channel, pointer to data store)
+
+Full Example:
+
+void callback_destroy(void *data)
+{
+ free(data);
+}
+
+struct ast_datastore *datastore = NULL;
+datastore = ast_channel_datastore_alloc(&example_datastore, NULL);
+datastore->data = mysillydata;
+datastore->destroy = callback_destroy;
+ast_channel_datastore_add(chan, datastore);
+
+NOTE: Because you're passing a pointer to a function in your module, you'll want to include
+this in your use count. When allocated increment, when destroyed decrement.
+
+* How do you remove a data store?
+
+1. Find the data store
+ Ex: datastore = ast_channel_datastore_find(chan, &example_datastore, NULL);
+ This function takes three arguments: (pointer to channel, datastore info structure, uid)
+2. Remove the data store from the channel
+ Ex: ast_channel_datastore_remove(chan, datastore);
+ This function takes two arguments: (pointer to channel, pointer to data store)
+3. If we want to now, free the memory or do stuff to the data on the data store
+ If we do then we will want to unset the data and callback
+ Ex: datastore->data = NULL;
+ datastore->destroy = NULL;
+4. Free the data store
+ Ex: ast_channel_datastore_free(datastore);
+ This function takes one argument: (pointer to data store)
+
+* How do you find a data store?
+
+1. Find the data store
+ Ex: datastore = ast_channel_datastore_find(chan, &example_datastore, NULL);
+ This function takes three arguments: (pointer to channel, datastore info structure, uid)