ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / ATcodec / ATcodec_Tree.h
diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/ATcodec/ATcodec_Tree.h b/mardrone/ARDrone_SDK_Version_1_8_20110726/ARDroneLib/VP_SDK/ATcodec/ATcodec_Tree.h
new file mode 100644 (file)
index 0000000..afde5f8
--- /dev/null
@@ -0,0 +1,139 @@
+/**
+ * @file ATcodec_tree.c
+ * @author aurelien.morelle@parrot.com
+ * @date 2007/08/20
+ */
+
+
+/*
+------- Builds a tree which factorises the beginning of AT command strings ------
+----  and allows quick search of the callback corresponding to an AT command ----
+
+Example:
+
+A\r
+ . T\r
+ .  . *\r
+ .  .  . A\r
+ .  .  .  . AT*ANIM=<\0>"\r
+ .  .  . C\r
+ .  .  .  . A\r
+ .  .  .  .  . D\r
+ .  .  .  .  .  . AT*CAD=<\0>"\r
+ .  .  .  .  . P\r
+ .  .  .  .  .  . AT*CAP=<\0>"\r
+ .  .  .  . O\r
+ .  .  .  .  . M\r
+ .  .  .  .  .  . AT*COMWDG=<\0>"\r
+ .  .  .  .  . N\r
+ .  .  .  .  .  . AT*CONFIG=<\0>"\r
+ .  .  .  . T\r
+ .  .  .  .  . AT*CTRL=<\0>"\r
+ .  .  . F\r
+ .  .  .  . AT*FTRIM=<\0>"\r
+ .  .  . G\r
+ .  .  .  . AT*GAIN=<\0>"\r
+ .  .  . L\r
+ .  .  .  . AT*LED=<\0>"\r
+ .  .  . M\r
+ .  .  .  . I\r
+ .  .  .  .  . AT*MISC=<\0>"\r
+ .  .  .  . T\r
+ .  .  .  .  . AT*MTRIM=<\0>"\r
+ .  .  . P\r
+ .  .  .  . C\r
+ .  .  .  .  . AT*PCMD=<\0>"\r
+ .  .  .  . O\r
+ .  .  .  .  . AT*POL=<\0>"\r
+ .  .  .  . W\r
+ .  .  .  .  . AT*PWM=<\0>"\r
+ .  .  . R\r
+ .  .  .  . AT*REF=<\0>"\r
+ .  .  . V\r
+ .  .  .  . I\r
+ .  .  .  .  . S\r
+ .  .  .  .  .  . O\r
+ .  .  .  .  .  .  . AT*VISO=<\0>"\r
+ .  .  .  .  .  . P\r
+ .  .  .  .  .  .  . AT*VISP=<\0>"\r
+ .  .  . Z\r
+ .  .  .  . AT*ZAP=<\0>"\r
+E\r
+ . ERROR<CR><\0>"\r
+O\r
+ . OK<CR><\0>"
+
+ ----------------------------------------------------------*/
+
+#ifndef _AT_CODEC_TREE_INCLUDE_
+#define _AT_CODEC_TREE_INCLUDE_
+
+
+//#include <ATcodec/ATcodec_api.h>
+#include <ATcodec/ATcodec_Buffer.h>
+#include <ATcodec/ATcodec.h>
+
+#define AT_CODEC_TREE_MAX_SONS 256
+
+typedef enum _ATCODEC_TREE_NODE_TYPE_
+{
+  ATCODEC_TREE_NODE_TYPE_EMPTY, // just for tree root, when nothing has been added yet
+  ATCODEC_TREE_NODE_TYPE_NODE,  
+  ATCODEC_TREE_NODE_TYPE_LEAF,
+  ATCODEC_TREE_NODE_TYPE_MULTILEAVES,
+}
+ATCODEC_TREE_NODE_TYPE;
+
+
+typedef struct _ATcodec_Tree_Node_
+{
+  ATCODEC_TREE_NODE_TYPE type;
+  int depth;
+  int strkey;
+
+  int sons[AT_CODEC_TREE_MAX_SONS];
+
+  int nb_sons; // only when type is MULTILEAVES
+
+  int data; // only when type is LEAF; index of the parameter string in the 'data' buffer.
+}
+ATcodec_Tree_Node_t;
+
+
+typedef struct _ATcodec_Tree_
+{
+  int root;
+
+  ATcodec_Buffer_t leaves;
+  ATcodec_Buffer_t strs;
+  ATcodec_Buffer_t sons;
+}
+ATcodec_Tree_t;
+
+
+void
+ATcodec_Tree_init(ATcodec_Tree_t *tree, size_t leaf_size, int nb_start);
+
+
+int
+ATcodec_Tree_insert(ATcodec_Tree_t *tree, char *str, void *data);
+
+
+ATcodec_Tree_Node_t *
+ATcodec_Tree_Node_get(ATcodec_Tree_t *tree, int node);
+
+
+void
+ATcodec_Tree_print(ATcodec_Tree_t *tree);
+
+
+/* void */
+/* ATcodec_Tree_remove(ATcodec_Tree_t *tree, char *str, void *data); */
+
+
+/* void */
+/* ATcodec_Tree_destroy(ATcodec_Tree_t *tree); */
+
+
+#endif // -> _AT_CODEC_TREE_INCLUDE_
+