00001 #ifndef INCLUDE_MATLABFUNCTIONHANDLE 00002 #define INCLUDE_MATLABFUNCTIONHANDLE 00003 00004 #include "mex.h" 00005 00006 // Class MatlabFunctionHandle. 00007 // ----------------------------------------------------------------- 00008 class MatlabFunctionHandle { 00009 public: 00010 00011 // This is the default constructor. It stores a null function 00012 // handle. 00013 MatlabFunctionHandle(); 00014 00015 // This constructor accepts as input a pointer to a Matlab array, 00016 // which must be of the function handle class. 00017 explicit MatlabFunctionHandle (const mxArray* ptr); 00018 00019 // The copy constructor makes a full copy of the source object. 00020 MatlabFunctionHandle (const MatlabFunctionHandle& source); 00021 00022 // The destructor. 00023 ~MatlabFunctionHandle(); 00024 00025 // Conversion operator for pointer to MATLAB array. 00026 operator mxArray* () const { return f; }; 00027 00028 // Returns false if and only if we have the null function handle. 00029 operator bool() const { return f != 0; }; 00030 00031 protected: 00032 mxArray* f; // The MATLAB array storing information concerning 00033 // the function handle. 00034 00035 // The copy assignment operator is not proper, thus remains protected. 00036 MatlabFunctionHandle& operator= (const MatlabFunctionHandle& source) 00037 { return *this; }; 00038 }; 00039 00040 #endif