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

plExternalMethod.h

00001 /*=============================================================================
00002  * Product        : OpenPL 
00003  * File           : plExternalMethod.h
00004  * Author         : Kamel Mekhnacha & Juan Manuel Ahuactzin
00005  * Creation       : Wed Feb  6 14:07:54 2002
00006  *
00007  *=============================================================================
00008  *     (c) Copyright 2000, Centre National de la Recherche Scientifique,
00009  *                              all rights reserved
00010  *=============================================================================
00011  *
00012  *------------------------- Description ---------------------------------------
00013  *   
00014  *   
00015  *-----------------------------------------------------------------------------
00016  */
00017 
00018 #ifndef _plExternalMethod_h_
00019 #define _plExternalMethod_h_
00020 
00021 
00022 #include <plDataValues.h>
00023 #include <plVariablesConjunction.h>
00024 #include <plValues.h>
00025 #include <plExternalFunctionAtKernel.h>
00026 
00027 // Defines the Ferivative Function of a Formal Function */
00028 template<class T>
00029 class kplDerivativeMethod :public kplDerivativeFunction{
00030 protected:
00031   /* Pointer to the object on which the method is called */
00032   T *user_object;
00033   
00035   void (T::*deriv_method)(plValues &output, 
00036               const plValues &input);
00037   
00038 public:
00039   kplDerivativeMethod(list <kplVariable*> der_variable, 
00040               list <kplVariable*> under_variables,
00041               T *obj,
00042               void (T::*method)(plValues &output, 
00043                     const plValues &input) )
00044     :kplDerivativeFunction(der_variable, under_variables),
00045      user_object(obj), deriv_method(method)
00046   {}
00047 
00048   virtual ~kplDerivativeMethod(){};
00049   
00050   void evaluate(plDataValues& o_values, 
00051         plDataValues *i_values) const
00052   {
00053 #ifdef PL_PARA_WITH_NEWF
00054 
00055     plValues input_values_copy(*input_values, i_values);
00056     plValues output_values_copy(*output_values, &o_values);
00057 
00058     (user_object->*deriv_method)(output_values_copy, input_values_copy);
00059 
00060 #else
00061     input_values->set_values_address(i_values);
00062     output_values->set_values_address(&o_values);
00063     (user_object->*deriv_method)(*output_values,
00064                  *input_values);
00065 
00066     //o_values = output_values->get_values();
00067 #endif
00068 
00069   }
00070 };
00071 
00072 
00073 // A formal Function is a function used to define a Dirac Function */
00074 template<class T>
00075 class kplFormalMethod : public kplFormalFunction {
00076 private:
00077   
00078   /* Pointer to the object on which the method is called */
00079   T *user_object;
00080 
00082   void (T::*user_method)(plValues &output, 
00083              const plValues &input);
00084 
00085   
00086 public:
00087   kplFormalMethod(){};
00088   kplFormalMethod(const list <kplVariable*>& known_params,
00089           T *obj,
00090           void (T::*method)(plValues &output, 
00091                     const plValues &input),
00092           const string& func_name)
00093     :kplFormalFunction(known_params, func_name),
00094      user_object(obj), user_method(method)
00095   {}
00096   
00097   kplFormalMethod(const list <kplVariable*>& search_params, 
00098           const list <kplVariable*>& known_params,
00099           T *obj,
00100           void (T::*method)(plValues &output, 
00101                     const plValues &input),
00102           const string& func_name)
00103     :kplFormalFunction(search_params, known_params, func_name),
00104      user_object(obj), user_method(method)
00105   {}
00106   
00107   kplFormalMethod(const list <kplVariable*>& search_params, 
00108           const list <kplVariable*>& known_params,
00109           T *obj,
00110           void (T::*method)(plValues &output, 
00111                     const plValues &input),
00112           const kplDerivativeMethod<T> *derivative,
00113           const string& func_name)
00114     :kplFormalFunction(search_params, known_params, func_name),
00115      user_object(obj), user_method(method)
00116   {
00117     /* insert the sent derivative at the list of derivatives */
00118     derivatives_list.push_back((kplDerivativeFunction*)derivative);
00119   }
00120 
00121   virtual ~kplFormalMethod(){};
00122   
00123   void evaluate(plDataValues& o_values,
00124         plDataValues *i_values) const
00125   {
00126 
00127 #ifdef PL_PARA_WITH_NEWF
00128     
00129     plValues input_values_copy(*input_values, i_values);
00130     plValues output_values_copy(*output_values, &o_values);
00131 
00132     (user_object->*user_method)(output_values_copy, input_values_copy);
00133 #else
00134     input_values->set_values_address(i_values);
00135     output_values->set_values_address(&o_values);
00136     (user_object->*user_method)(*output_values, 
00137                 *input_values);
00138 
00139     //o_values = output_values->get_values(); 
00140 #endif
00141   }
00142 
00143 };
00144 
00145 
00146 
00147 #endif

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