Functor.h

Go to the documentation of this file.
00001 
00002 
00008 /*
00009 */
00011 
00012 #ifndef __SSF_FUNCTOR_H__
00013 #define __SSF_FUNCTOR_H__
00014 
00015 #include <Matrix.h>
00016 #include "Time.h"
00017 #include "OrbitState.h"
00018 #include "AttitudeState.h"
00019 
00020 namespace O_SESSAME {
00021 
00063 class Functor
00064 {
00065 public:
00066 
00067       // two possible functions to call member function. virtual cause derived
00068       // classes will use a pointer to an object and a pointer to a member function
00069       // to make the function call
00070       virtual Vector Call(const ssfTime&, const OrbitState&, const AttitudeState&) const =0;        // call using function
00071 };
00072 
00078 class SpecificFunctor : public Functor
00079 {
00080 private:
00081       Vector (*fpt)(const ssfTime&, const OrbitState&, const AttitudeState&);           // pointer to member function
00082 
00083 public:
00084 
00085       // constructor - takes pointer to a Function
00086       SpecificFunctor(Vector(*_fpt)(const ssfTime&, const OrbitState&, const AttitudeState&)):fpt(_fpt) {};
00087 
00088       // override function "Call"
00089       virtual Vector Call(const ssfTime &_ssfTime, const OrbitState &_orbState, const AttitudeState &_attState) const { return (*fpt)(_ssfTime, _orbState, _attState);};             // execute member function
00090 };
00091 
00097 template <class TClass> class ObjectFunctor : public Functor
00098 {
00099 private:
00100       TClass* pt2Object;                        
00101       Vector (TClass::*fpt)(const ssfTime&, const OrbitState&, const AttitudeState&);           
00103 public:
00104 
00107       ObjectFunctor(TClass* _pt2Object, Vector(TClass::*_fpt)(const ssfTime&, const OrbitState&, const AttitudeState&)): pt2Object(_pt2Object),  fpt(_fpt) {};
00108       ObjectFunctor(): pt2Object(NULL),  fpt(NULL) {};
00109       void Set(TClass* _pt2Object, Vector(TClass::*_fpt)(const ssfTime&, const OrbitState&, const AttitudeState&)){ pt2Object = _pt2Object;  fpt=_fpt; };
00110       
00111       // override function "Call"
00112       virtual Vector Call(const ssfTime &_ssfTime, const OrbitState &_orbState, const AttitudeState &_attState) const { return (*pt2Object.*fpt)(_ssfTime, _orbState, _attState);};             // execute member function
00113 };
00114 } // close namespace O_SESSAME
00115 
00116 #endif __SSF_FUNCTOR_H__
00117 
00118 // Do not change the comments below - they will be added automatically by CVS
00119 /*****************************************************************************
00120 *       $Log: Functor.h,v $
00121 *       Revision 1.9  2003/05/21 19:52:22  nilspace
00122 *       Updated comments.
00123 *       
00124 *       Revision 1.8  2003/05/20 17:44:20  nilspace
00125 *       Updated comments.
00126 *       
00127 *       Revision 1.7  2003/05/13 18:58:04  nilspace
00128 *       Cleaned up comments.
00129 *       
00130 *       Revision 1.6  2003/04/27 22:04:34  nilspace
00131 *       Created the namespace O_SESSAME.
00132 *       
00133 *       Revision 1.5  2003/04/25 18:55:45  nilspace
00134 *       Implemented ObjectFunctor body (empty), and moved constructor assignments to inline with constructor.
00135 *       
00136 *       Revision 1.4  2003/04/25 13:45:53  nilspace
00137 *       const'd Get() functions.
00138 *       
00139 *       Revision 1.3  2003/04/24 20:00:10  nilspace
00140 *       Made all Call() functions const to prevent warnings.
00141 *       
00142 *       Revision 1.2  2003/04/24 13:51:10  nilspace
00143 *       Added a Set function for setting the object & function afterwards, or by using the default constructor.
00144 *       
00145 *       Revision 1.1  2003/04/08 22:33:06  nilspace
00146 *       Initial Submission
00147 *       
00148 *
00149 ******************************************************************************/

Generated on Wed Aug 6 12:58:45 2003 for Open-Sessame Framework by doxygen1.3