cta_tree.h

Go to the documentation of this file.
00001 /*
00002 COSTA: Problem solving environment for data assimilation
00003 Copyright (C) 2005  Nils van Velzen
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 /**
00021 \file  cta_tree.h
00022 
00023 \brief Interface description of the COSTA tree component.
00024 
00025 Store data in a CTA_Tree object in tree form. Access the members in the following way:
00026  <I>branch1\\subbranch\\member</I> or <I>branch1/branch2/member</I>
00027 */
00028 
00029 #ifndef CTA_TREE_H
00030 #define CTA_TREE_H
00031 #include "cta_system.h"
00032 #include "cta_handles.h"
00033 #include "cta_datatypes.h"
00034 
00035 /* Tree instance handle */
00036 typedef CTA_Handle CTA_Tree;
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 /** \brief Create a new COSTA tree instance 
00041  *
00042  *  \note
00043  *
00044  *  \param htree  O  receives handle of created tree
00045  *  \return CTA_OK if successful
00046  */
00047 CTAEXPORT int CTA_Tree_Create(CTA_Tree *htree);
00048 
00049 
00050 /** \brief Free the COSTA tree instance 
00051  *
00052  *  \note 
00053  *
00054  *  \param htree  IO handle of the tree instance, replaced by CTA_NULL on return
00055  *  \return CTA_OK if successful
00056  */
00057 CTAEXPORT int CTA_Tree_Free(CTA_Tree *htree);
00058 
00059 
00060 /** \brief Add a COSTA handle to the COSTA tree
00061  *
00062  *  \note
00063  *
00064  *  \param htree  IO handle of the tree object (parent)
00065  *  \param name   I  name of the COSTA item
00066  *  \param hitem  I  handle of the COSTA item to add (do not free the object after adding it to the tree)
00067  *  \return CTA_OK if successful
00068  */
00069 CTAEXPORT int CTA_Tree_AddHandle(CTA_Tree htree, const char *name, CTA_Handle hitem);
00070 
00071 
00072 /** \brief Count the number of COSTA handles specified by the given path.
00073  *
00074  *  \param htree  I  handle of the tree object
00075  *  \param path   I  path of the item, separated by / or \\
00076  *  \param count  O  receives the number of items found
00077  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case of not found
00078  */
00079 CTAEXPORT int CTA_Tree_CountHandles(CTA_Tree htree, CTA_String path, int *count);
00080 
00081 /** \brief Count the number of COSTA handles specified by the given path.
00082  *
00083  *  \param htree  I  handle of the tree object
00084  *  \param path   I  path of the item, separated by / or \
00085  *  \param count  O  receives the number of items found
00086  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case of not found
00087  */
00088 CTAEXPORT int CTA_Tree_CountHandlesStr(CTA_Tree htree, char *path, int *count);
00089 
00090 
00091 /** \brief Get a COSTA handle from the COSTA tree (by path)
00092  *
00093  *  \note In case of trees with default values, returns the default value.
00094  *  \note The returned handle must not be freed.
00095  *
00096  *  \param htree  I  handle of the tree object
00097  *  \param path   I  path of the item, separated by / or \\
00098  *  \param hitem  O  receives the handle of the COSTA item, or CTA_NULL in case not found, do not free this handle.
00099  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case of not found
00100  */
00101 CTAEXPORT int CTA_Tree_GetHandle(CTA_Tree htree, CTA_String path, CTA_Handle *hitem);
00102 
00103 
00104 /** \brief Get the value of a COSTA handle from the COSTA tree (by path)
00105  *
00106  *  \note In case of trees with default values, returns the default value.
00107  *
00108  *  \param htree    I  handle of the tree object
00109  *  \param path     I  COSTA string describing path of the item, separated by / or \
00110  *  \param value    O  receives the value of the COSTA item, or CTA_NULL in case of not found
00111  *  \param datatype I  data type of parameter value, must be the same as item in tree
00112  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case of not found
00113  */
00114 CTAEXPORT int CTA_Tree_GetValue(CTA_Tree htree, CTA_String path, void *value, CTA_Datatype datatype);
00115 
00116 /** \brief Get a COSTA handle from the COSTA tree (by path)
00117  *
00118  *  \note In case of trees with default values, returns the default value.
00119  *  \note The returned handle must not be freed.
00120  *
00121  *  \param htree  I  handle of the tree object
00122  *  \param str    I  C string describing path of the item, separated by / or \
00123  *  \param hitem  O  receives the handle of the COSTA item, or CTA_NULL in case of not found, do not free this handle
00124  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case of not found
00125  */
00126 CTAEXPORT int CTA_Tree_GetHandleStr(CTA_Tree htree, char* str, CTA_Handle *hitem);
00127 
00128 
00129 /** \brief Get the value of a COSTA handle from the COSTA tree (by path)
00130  *
00131  *  \note In case of trees with default values, returns the default value.
00132  *
00133  *  \param htree    I  handle of the tree instance
00134  *  \param str      I  C string describing path of the item, separated by / or \
00135  *  \param value    O  receives the value of the COSTA item, or CTA_NULL in case of not found
00136  *  \param datatype I  data type of the value specified
00137  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case of not found
00138  */
00139 CTAEXPORT int CTA_Tree_GetValueStr(CTA_Tree htree, char* str, void *value, CTA_Datatype datatype);
00140 
00141 
00142 /** \brief Count the number of elements on the current level of the COSTA tree
00143  *
00144  *  \param htree  I  handle of the tree level
00145  *  \param count  O  receives the number of elements on the current tree level
00146  *  \return CTA_OK if successful
00147  */
00148 CTAEXPORT int CTA_Tree_CountItems(CTA_Tree htree, int *count);
00149 
00150 
00151 /** \brief Get a handle (by index) on the current level of the COSTA tree
00152  *
00153  *  \param htree  I  handle of the tree level
00154  *  \param index  I  index of the item to return, 1 <= index <= CTA_Tree_CountItems()
00155  *  \param hitem  O  receives handle of the item at given index
00156  *  \return CTA_OK if successful
00157  */
00158 CTAEXPORT int CTA_Tree_GetItem(CTA_Tree htree, int index, CTA_Handle *hitem);
00159 
00160 
00161 /** \brief Get the value of a COSTA handle from the COSTA tree (by index)
00162  *
00163  *  \note In case of trees with default values, returns the default value.
00164  *
00165  *  \param htree    I  handle of the tree instance
00166  *  \param index    I  index of the item
00167  *  \param value    O  receives value of the COSTA item, or CTA_NULL in case of not found
00168  *  \param datatype I  data type of the value specified
00169  *  \return CTA_OK if successful or CTA_ITEM_NOT_FOUND in case not found
00170  */
00171 CTAEXPORT int CTA_Tree_GetItemValue(CTA_Tree htree, int index, void *value, CTA_Datatype datatype);
00172 
00173 
00174 /** \brief Print a COSTA tree to STDOUT
00175  *
00176  *  \note
00177  *
00178  *  \param htree  I  handle of the tree
00179  *  \return CTA_OK if successful
00180  */
00181 CTAEXPORT int CTA_Tree_Print(CTA_Tree htree);
00182 
00183 /*=====================================================================*/
00184 #ifdef __cplusplus
00185 }
00186 #endif
00187 #endif

Generated on Mon Apr 6 14:05:58 2009 for COSTA by  doxygen 1.5.2