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_interface.h 00022 \brief Description of the COSTA interface componennt used for 00023 communication with user implementation classes. 00024 00025 To create an object of your user implementation go through the following steps: 00026 00027 1: Create a new class (=implementation) of a COSTA component by calling the 00028 appropriate DefineClass() function providing the name of the class, a matrix with 00029 CTA_Function objects describing the user functions. 00030 00031 example: 00032 00033 <code>void Usr_Object_initialise(CTA_MatClass *hmatcl){ 00034 CTA_Intf hintf=0;\n 00035 CTA_Func h_func[CTA_MATRIX_NUMFUNC];\n 00036 // CTA_Func h_create_size;\n 00037 // CTA_Func h_Create_Init;\n 00038 int ierr;\n 00039 00040 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Create_Size, hintf,&h_func[CTA_MATRIX_CREATE_SIZE]);\n 00041 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Create_Init, hintf,&h_func[CTA_MATRIX_CREATE_INIT]);\n 00042 ierr=CTA_Func_Create(" ",&CTAI_Matrix_getvals, hintf,&h_func[CTA_MATRIX_GETVALS] );\n 00043 ierr=CTA_Func_Create(" ",&CTAI_Matrix_getval, hintf,&h_func[CTA_MATRIX_GETVAL] );\n 00044 ierr=CTA_Func_Create(" ",&CTAI_Matrix_setcol, hintf,&h_func[CTA_MATRIX_SETCOL] );\n 00045 ierr=CTA_Func_Create(" ",&CTAI_Matrix_setvals, hintf,&h_func[CTA_MATRIX_SETVALS] );\n 00046 ierr=CTA_Func_Create(" ",&CTAI_Matrix_setval, hintf,&h_func[CTA_MATRIX_SETVAL] );\n 00047 ierr=CTA_Func_Create(" ",&CTAI_Matrix_setconst, hintf,&h_func[CTA_MATRIX_SETCONST] );\n 00048 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Export, hintf,&h_func[CTA_MATRIX_EXPORT] );\n 00049 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Ger, hintf,&h_func[CTA_MATRIX_GER] );\n 00050 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Inv, hintf,&h_func[CTA_MATRIX_INV] );\n 00051 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Gemv, hintf,&h_func[CTA_MATRIX_GEMV] );\n 00052 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Gemm, hintf,&h_func[CTA_MATRIX_GEMM] );\n 00053 ierr=CTA_Func_Create(" ",&CTAI_Matrix_Axpy, hintf,&h_func[CTA_MATRIX_AXPY] );\n 00054 ierr=CTA_Func_Create(" ",&CTAI_Matrix_free, hintf,&h_func[CTA_MATRIX_FREE] );\n 00055 00056 ierr=CTA_Object_DefineClass("cta_matrix_blas",h_func,hmatcl);\n 00057 }</code> 00058 00059 2: use the resulting class object for creating the user object in following way: 00060 00061 <code>int CTA_Matrix_Create(classobject, ..., *userdata, Usr_Object *usrObject);</code> 00062 00063 */ 00064 00065 #ifndef CTA_INTERFACE_H 00066 #define CTA_INTERFACE_H 00067 #include "cta_system.h" 00068 #include "cta_datatypes.h" 00069 #include "cta_handles.h" 00070 00071 CTAEXPORT typedef int CTA_Intf; 00072 00073 #ifdef __cplusplus 00074 extern "C" { 00075 #endif 00076 00077 /** \brief Create a new interface 00078 * 00079 * \param name I name of the new interface 00080 * \param argtyp I list with the data types of arguments 00081 * \param narg I number of arguments of interface 00082 * \param hintf O receives the new COSTA interface handle 00083 * \return error status: CTA_OK 00084 */ 00085 CTAEXPORT int CTA_Intf_Create(const char *name, const CTA_Datatype *argtyp, 00086 const int narg,CTA_Intf *hintf); 00087 00088 /** \brief Free an interface 00089 * 00090 * \note Freeing CTA_NULL is allowed. 00091 * 00092 * \param hintf IO handle of interface, replaced by CTA_NULL on return 00093 * \return error status: CTA_OK, CTA_ILLEGAL_HANDLE, CTA_INCOMPATIBLE_HANDLE 00094 */ 00095 CTAEXPORT int CTA_Intf_Free(CTA_Intf *hintf); 00096 00097 /** \brief Match two interfaces for compatibility argumentlist-argumentlist 00098 * 00099 * \note Two interfaces are compatible if all arguments have the same datatype, 00100 * CTA_VOID is compatible with all other arguments except for CTA_FSTRING 00101 * 00102 * \param argtyp1 I list with the data types of arguments of first interface 00103 * \param narg1 I number of arguments in first interface 00104 * \param argtyp2 I list with the data types of arguments of second interface 00105 * \param narg2 I number of arguments in second interface 00106 * \param flag O receives TRUE if interfaces are compatible FALSE ortherwise 00107 * \return error status: CTA_OK 00108 */ 00109 CTAEXPORT int CTA_Intf_Match_aa(const CTA_Datatype *argtyp1, const int narg1, 00110 const CTA_Datatype *argtyp2, const int narg2, 00111 BOOL *flag); 00112 00113 /** \brief Match two interfaces for compatibility handle-argumentlist 00114 * 00115 * \note Two interfaces are compatible if all arguments have the same datatype, 00116 * CTA_VOID is compatible with all other arguments except for CTA_FSTRING 00117 * 00118 * \param hintf1 I handle of first interface 00119 * \param argtyp2 I list with the data types of arguments of second interface 00120 * \param narg2 I number of arguments in second interface 00121 * \param flag O receives TRUE if interfaces are compatible FALSE ortherwise 00122 * \return error status: CTA_OK, CTA_ILLEGAL_HANDLE, CTA_INCOMPATIBLE_HANDLE 00123 */ 00124 CTAEXPORT int CTA_Intf_Match_ha(const CTA_Intf hintf1, 00125 const CTA_Datatype *argtyp2, const int narg2, BOOL *flag); 00126 00127 /** \brief Match two interfaces for compatibility handle-handle 00128 * 00129 * \note two interfaces are compatible if all arguments have the same datatype, 00130 * CTA_VOID is compatible with all other arguments except for CTA_FSTRING 00131 * 00132 * \param hintf1 I handle of first interface 00133 * \param hintf2 I handle of second interface 00134 * \param flag O receives TRUE if interfaces are compatible FALSE ortherwise 00135 * \return error status: CTA_OK, CTA_ILLEGAL_HANDLE, CTA_INCOMPATIBLE_HANDLE 00136 */ 00137 CTAEXPORT int CTA_Intf_Match_hh(const CTA_Intf hintf1, const CTA_Intf hintf2, BOOL *flag); 00138 00139 #ifdef __cplusplus 00140 } 00141 #endif 00142 #endif 00143