cta_usr_method.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_usr_method.h
00022 
00023 \brief In this file a description is given of the interface of user method functions.
00024 When creating your own user method class use the following as template.
00025 
00026 The Usr_Meth to which is being referred in this template can be substituted by your own user method object.
00027 
00028 <b>Step 1</b>: for creating your own user method class call the function CTA_Meth_DefineClass().
00029 
00030 Example:
00031 
00032 \code
00033 typedef CTA_Handle CTA_MethClass;
00034 
00035 CTA_Func h_func[CTA_METH_NUMFUNC];
00036 CTA_MethClass my_own_meth_class;
00037 
00038 ierr=CTA_Func_Create(" ",&usr_meth_create_size, hintf, &h_func[CTA_METH_CREATE_SIZE]);
00039 //...for all implementation functions...
00040 
00041 CTA_Meth_DefineClass("classname", h_func, &my_own_meth_class);\endcode
00042 
00043 Making a user method class involves the implementation of the following functions:
00044 
00045 CTA_METH_CREATE_SIZE  \n
00046 CTA_METH_CREATE_INIT  \n
00047 CTA_METH_RUN          \n
00048 CTA_METH_FREE         \n
00049 
00050 For creating an implementation function see documentation of CTA_Func_Create().
00051 
00052 <b>Step 2</b>: to create an object of the newly defined method class call CTA_Meth_Create() in the
00053 same way as creating a CTA_Meth object but with a different class handle, i.e. the user class handle from step 1 above.
00054 
00055 Example:
00056 
00057 \code
00058 Usr_Meth usrmeth; //user method object
00059 CTA_Handle userdata = CTA_NULL;
00060 CTA_Meth_Create(my_own_meth_class, &userdata, &usrmeth);
00061 \endcode
00062 \n
00063 <b>Note 1: </b> with object data is meant only the object itself including pointer(s) to its contents, but
00064 not the contents themselves.\n\n
00065 */
00066 
00067 
00068 //#define CTA_METH_CREATE_SIZE  ( 1)
00069 /** \brief Implementation that forms part of the create process.
00070  * 
00071  * Must give the memory size of a new method user object.
00072  *
00073  * Example:
00074  *  \code
00075 //in header file:
00076 typedef struct {
00077    //your own user object data goes here...
00078 }USR_METH;
00079 
00080 //user implementation:
00081 void usr_meth_create_size(...){
00082    *memsize = sizeof(USR_METH);
00083    *retval = CTA_OK;
00084 }
00085  \endcode
00086  *
00087  * \note At index CTA_METH_CREATE_SIZE in the function list of the class descriptor.
00088  *
00089  * \param memsize  O must receive the number of bytes which are necessary to store one
00090                      user method class, with a pointer to the contents (data), but without the
00091                      contents themselves
00092  * \param retval   O must receive return value of user implementation function
00093  * \return no return value
00094  */
00095 void usr_meth_create_size(int *memsize, int *retval);
00096 
00097 
00098 
00099 //#define CTA_METH_CREATE_INIT  ( 2)
00100 /** \brief Implementation that forms part of the create process.
00101  *
00102  * The user method object needs to be made ready for use.
00103  *
00104  * \note At index CTA_METH_CREATE_INIT in the function list of the class descriptor.
00105  *
00106  * \param objectdata I  pointer to user method object data
00107  * \param userdata   IO user data
00108  * \param retval     O  must receive return value of user implementation function
00109  * \return no return value
00110  */
00111 void usr_meth_create_init(Usr_Meth *objectdata, void *userdata, int *retval);
00112 
00113 
00114 
00115 //#define CTA_METH_RUN          ( 3)
00116 /** \brief Implementation for running user method.
00117  *
00118  * \note At index CTA_METH_RUN in the function list of the class descriptor.
00119  *
00120  * \param objectdata I pointer to user method object data
00121  * \param retval     O must receive return value of user implementation function
00122  * \return no return value
00123  */
00124 void usr_meth_run(Usr_Meth *objectdata, int *retval);
00125 
00126 
00127 
00128 //#define CTA_METH_FREE         ( 4)
00129 /** \brief Implementation for freeing the object data and associated resources.
00130  *
00131  * \note At index CTA_METH_FREE in the function list of the class descriptor.
00132  *
00133  * \param objectdata I pointer to user method object data
00134  * \param retval     O must receive return value of user implementation function
00135  * \return no return value
00136  */
00137 void usr_meth_free(Usr_Meth *objectdata, int *retval);
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 

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