Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members

plExternalFunction.h

00001 /*=============================================================================
00002  * Product        : OpenPL 
00003  * File           : plExternalFunction.h (before plFormalFunction.h)
00004  * Author         : Juan-Manuel Ahuactzin
00005  *
00006  *=============================================================================
00007  *     (c) Copyright 2000, Centre National de la Recherche Scientifique,
00008  *                              all rights reserved
00009  *=============================================================================
00010  *
00011  *------------------------- Description ---------------------------------------
00012  *   
00013  *   
00014  *-----------------------------------------------------------------------------
00015  */
00016 
00017 #ifndef _plExternalFunction_h_
00018 #define _plExternalFunction_h_
00019 
00020 
00021 #include <plObject.h>
00022 #include <plVariablesConjunction.h>
00023 #include <plValues.h>
00024 #include <plDataValues.h>
00025 
00026 /*****************************************************************************
00027  *                           External Classes
00028  *****************************************************************************/
00029 
00030 #include <plExternalMethod.h>
00031 
00032 /*****************************************************************************
00033  *                           Classes Definitions
00034  *****************************************************************************/
00035 
00036 
00041 class plExternalFunction : public plObject 
00042 {
00043 
00044 protected:
00045 
00047   void Output(ostream &out) const;
00048 
00049 
00051   kplFormalFunction *function_at_kernel;
00052   
00053 public:
00054   
00055   plDataValues operator()(const plValues &values) const;
00056 
00057   virtual ~plExternalFunction(){};
00058   
00061   plExternalFunction(const plVariablesConjunction &input_params, 
00062              void (*call_function)(plValues &output_values, 
00063                        const plValues &input_values));
00064   
00067   plExternalFunction(const plVariablesConjunction &output_params, 
00068              const plVariablesConjunction &input_params, 
00069              void (*call_function)(plValues &output_values, 
00070                        const plValues &input_values));
00071 
00072   
00073   template <class T>
00074   plExternalFunction(const plVariablesConjunction &input_params,
00075              T *obj,
00076              void (T::*method) (plValues &output_values, 
00077                     const plValues &input_values))
00078   {
00079     
00080     string name;
00081     
00082     char cbuff[42] = "AnonymousMethod"; 
00083     name = string( cbuff );
00084     
00085     
00086     /* create the formal function at kernel level */
00087     function_at_kernel = new kplFormalMethod<T>(input_params.get_variable_list(),
00088                  obj, method, name);
00089     
00090   }
00091   
00092   template <class T>
00093   plExternalFunction(const plVariablesConjunction &output_params, 
00094              const plVariablesConjunction &input_params,
00095              T *obj,
00096              void (T::*method) (plValues &output_values, 
00097                     const plValues &input_values))
00098   {
00099     
00100     string name;
00101     
00102     /* Construct a name for the function */
00103     /* TODO Construct a method to do this operation more eficinetly */
00104     char cbuff[42] = "AnonymousMethod"; 
00105     name = string( cbuff );
00106     
00107     
00108     /* create the formal function at kernel level */
00109     function_at_kernel = new kplFormalMethod<T>(output_params.get_variable_list(),
00110                  input_params.get_variable_list(),
00111                  obj, method, name);
00112     
00113   }
00114   
00115   plExternalFunction(const plVariablesConjunction &input_params, 
00116              void (*call_function)(plValues &output_values, 
00117                        const plValues &input_values),
00118              const string &func_name);
00119   
00122   plExternalFunction(const plVariablesConjunction &output_params, 
00123              const plVariablesConjunction &input_params, 
00124              void (*call_function)(plValues &output_values, 
00125                        const plValues &input_values),
00126              const string &func_name);
00127 
00128 
00129   template <class T>
00130   plExternalFunction(const plVariablesConjunction &input_params,
00131              T *obj,
00132              void (T::*method)(plValues &output_values, 
00133                        const plValues &input_values),
00134              const string &func_name)
00135   {
00136     /* create the formal function at kernel level */
00137     function_at_kernel = 
00138       new kplFormalMethod<T>(input_params.get_variable_list(),
00139                  obj, method, func_name );
00140   }
00141 
00142   template <class T>
00143   plExternalFunction(const plVariablesConjunction &output_params, 
00144              const plVariablesConjunction &input_params,
00145              T *obj,
00146              void (T::*method)(plValues &output_values, 
00147                        const plValues &input_values),
00148              const string &func_name)
00149   {
00150     /* create the formal function at kernel level */
00151     function_at_kernel = 
00152       new kplFormalMethod<T>(output_params.get_variable_list(),
00153                  input_params.get_variable_list(),
00154                  obj, method, func_name );
00155   }
00156   
00157   
00158 
00162   plExternalFunction(const plVariablesConjunction &output_params, 
00163              const plVariablesConjunction &input_params, 
00164              void (*call_function)(plValues &output_values, 
00165                        const plValues &input_values),
00166              const plVariablesConjunction derived_variable, 
00167              const plVariablesConjunction under_variables,
00168              void (*function_derivative)(plValues &output_values, 
00169                          const plValues &input_values));
00170 
00171   
00172   template <class T>
00173   plExternalFunction(const plVariablesConjunction &output_params, 
00174              const plVariablesConjunction &input_params, 
00175              T *obj,
00176              void (T::*method)(plValues output_values, 
00177                        const plValues &input_values),
00178              const plVariablesConjunction derived_variable, 
00179              const plVariablesConjunction under_variables,
00180              void (T::*deriv_method)(plValues &output_values, 
00181                          const plValues &input_values))
00182   {
00183     string name;
00184     
00185     /* Construct a name for the function */
00186     /* TODO Construct a method to do this operation more eficinetly */
00187     
00188     
00189     char cbuff[42] = "AnonymousMethod"; 
00190     name = string( cbuff );
00191 
00192     /* create the derivative function */
00193     kplDerivativeMethod <T>* derivative = 
00194       new kplDerivativeMethod<T>(derived_variable.get_variable_list,
00195                  input_params.get_variable_list(),
00196                  obj, deriv_method );
00197     
00198     
00199     
00200     /* create the formal function at kernel level */
00201     function_at_kernel = 
00202       new kplFormalMethod<T>(output_params.get_variable_list(),
00203                  input_params.get_variable_list(),
00204                  obj, method,derivative,name);
00205   }
00206   
00210   plExternalFunction(const plVariablesConjunction &output_params, 
00211              const plVariablesConjunction &input_params, 
00212              void (*call_function)(plValues &output_values, 
00213                        const plValues &input_values),
00214              const string &func_name,
00215              const plVariablesConjunction derived_variable, 
00216              const plVariablesConjunction under_variables,
00217              void (*function_derivative)(plValues &output_values, 
00218                          const plValues &input_values));
00219 
00220   template <class T>
00221   plExternalFunction(const plVariablesConjunction &output_params, 
00222              const plVariablesConjunction &input_params, 
00223              T *obj,
00224              void (T::*method)(plValues &output_values, 
00225                        const plValues &input_values),
00226              const string &func_name,
00227              const plVariablesConjunction derived_variable, 
00228              const plVariablesConjunction under_variables,
00229              void (T::*deriv_method)(plValues &output_values, 
00230                          const plValues &input_values))
00231     
00232   {
00233     /* create the derivative function */
00234     kplDerivativeMethod<T>* derivative = 
00235       new kplDerivativeMethod<T>(derived_variable.get_variable_list(),
00236                  input_params.get_variable_list(),
00237                  obj, deriv_method );
00238     
00239     
00240     
00241     /* create the formal function at kernel level */
00242     function_at_kernel = 
00243       new kplFormalMethod<T>(output_params.get_variable_list(),
00244                  input_params.get_variable_list(),
00245                  obj, method,derivative,func_name);
00246   }
00247 
00248   // TODO ack for MS C++
00249   void write_function_at_kernel(ostream &out) const;
00250 
00251   kplFormalFunction* get_function_at_kernel()const {return function_at_kernel;};
00252 
00253   friend class plFunctionalDirac;
00254   friend class plCndBellShape;
00255   friend class plCndProbTable;
00256   friend class plCndNormal;
00257 
00258   void destroy();
00259  
00260 
00261 };
00262 
00263 
00264 #endif

Generated on Fri Apr 1 10:58:12 2005 for ProBT by  doxygen 1.4.1