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_functions.h 00022 \brief Functions for working with CTA_Function objects. CTA_Function objects can be used to address functions. 00023 */ 00024 00025 #ifndef CTA_FUNCTIONS_H 00026 #define CTA_FUNCTIONS_H 00027 #include "cta_system.h" 00028 #include "cta_datatypes.h" 00029 #include "cta_handles.h" 00030 #include "cta_interface.h" 00031 #include "ctai_xml.h" 00032 00033 /* Function Handle */ 00034 typedef CTA_Handle CTA_Func; 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 00041 /** \brief Create a new COSTA function. 00042 * 00043 * \note Argument name is only used for debugging and output. 00044 * 00045 * \param name I name of the new function for debugging purposes 00046 * \param function I pointer to function that has to be associated 00047 * with new COSTA function 00048 * \param hintf I handle of associated interface 00049 * \param hfunc O receives handle of created COSTA function 00050 * \return CTA_OK if successful 00051 */ 00052 CTAEXPORT int CTA_Func_Create(const char *name, CTA_Function *function , 00053 const CTA_Intf hintf, CTA_Func *hfunc); 00054 00055 /** \brief Create a COSTA function loaded from dynamic library 00056 * 00057 * 00058 00059 * \param libraryName I Name of the dynamic library excluding the extention (.dll, .so, .dylib) eg "libmyroutines" 00060 * \param functionName I Name of the function to load. 00061 * \param name I Name of the function used inside the OpenDA administration 00062 * \param id I Name (id) of the handle that is created (needed when stored as part of a tree 00063 * \return Handle to function or CTA_NULL in case of an error. 00064 * 00065 * \note When the load of the function fails, some decorated, typical Fortran variations are tried as well 00066 * 00067 */ 00068 CTAEXPORT CTA_Func CTA_CreateFuncDynamicLib(char *libraryName, char *functionName, char *name, char *id); 00069 00070 /** \brief Duplicates a user defined function 00071 * 00072 * \param hfunc I COSTA user function handle 00073 * \param hdupl I duplication of hfunc 00074 * \return error status: CTA_OK 00075 */ 00076 CTAEXPORT int CTA_Func_Duplicate(CTA_Func hfunc, CTA_Func *hdupl); 00077 00078 00079 00080 /** \brief Free a new COSTA function. 00081 * 00082 * \note 00083 * 00084 * \param hfunc IO handle of COSTA function, replaced by CTA_NULL on return 00085 * \return CTA_OK if sucessful 00086 */ 00087 CTAEXPORT int CTA_Func_Free(CTA_Func *hfunc); 00088 00089 /** \brief Get interface of COSTA function. 00090 * 00091 * \note For performance reasons, the interface is not a copy but a handle 00092 * to the actual interface, it should NOT be freed by the calling routine! 00093 * 00094 * \param hfunc I handle of COSTA function 00095 * \param hintf O receives handle of interface of function 00096 * \return CTA_OK if successful 00097 */ 00098 CTAEXPORT int CTA_Func_GetIntf(const CTA_Func hfunc, CTA_Intf *hintf); 00099 00100 /** \brief Get function pointer of function 00101 * 00102 * \note There is no FORTRAN verion of this function available 00103 * 00104 * \param hfunc I handle of COSTA function. 00105 * \param function O receives pointer to function 00106 * \return CTA_OK if successful 00107 */ 00108 CTAEXPORT int CTA_Func_GetFunc(const CTA_Func hfunc, CTA_Function **function); 00109 00110 /** \brief Get name of function 00111 * 00112 * \note Future versions will return a COSTA string handle. 00113 * 00114 * \param hfunc I handle of COSTA function. 00115 * \param name O handle of string object that is to receive function name, must exist before calling 00116 * \return CTA_OK if successful 00117 */ 00118 CTAEXPORT int CTA_Func_GetName(const CTA_Func hfunc, CTA_String name); 00119 00120 /** \brief Set userdata of function 00121 * 00122 * \note Frees existing user data and replaces it with userdata 00123 * 00124 * \param hfunc IO handle of COSTA function. 00125 * \param userdata I new userdata handles 00126 * \return CTA_OK if successful 00127 */ 00128 CTAEXPORT int CTA_Func_SetUserdata(const CTA_Func hfunc, const CTA_Handle userdata ); 00129 00130 /** \brief Get userdata of function 00131 * 00132 * \param hfunc I handle of COSTA function. 00133 * \param userdata O userdata handle 00134 * \return CTA_OK if successful 00135 */ 00136 CTAEXPORT int CTA_Func_GetUserdata(const CTA_Func hfunc, CTA_Handle userdata ); 00137 00138 /** \brief Create a COSTA function from XML 00139 * (load from dynamic load library). 00140 * 00141 * \param cur_node I Current XML node 00142 * \return Handle to create or CTA_NULL in case of an error. 00143 */ 00144 CTAEXPORT CTA_Func CTAI_XML_CreateFunc(xmlNode *cur_node); 00145 00146 00147 00148 #ifdef __cplusplus 00149 } 00150 #endif 00151 #endif 00152