00001 /********************************************************************** 00002 ** This program is part of 'MOOSE', the 00003 ** Messaging Object Oriented Simulation Environment. 00004 ** Copyright (C) 2003-2009 Upinder S. Bhalla. and NCBS 00005 ** It is made available under the terms of the 00006 ** GNU Lesser General Public License version 2.1 00007 ** See the file COPYING.LIB for the full notice. 00008 **********************************************************************/ 00009 00010 #ifndef _PROC_OPFUNC_H 00011 #define _PROC_OPFUNC_H 00012 00018 /* 00019 class ProcOpFuncBase: public OpFunc 00020 { 00021 public: 00022 // This key extra function does Process calls. 00023 virtual void proc( char* obj, const Eref& e, ProcPtr p ) const = 0; 00024 private: 00025 }; 00026 00027 template< class T > class ProcOpFunc: public ProcOpFuncBase 00028 { 00029 public: 00030 ProcOpFunc( void ( T::*func )( const Eref& e, ProcPtr ) ) 00031 : func_( func ) 00032 {;} 00033 00034 bool checkFinfo( const Finfo* s ) const { 00035 return dynamic_cast< const SrcFinfo1< ProcPtr >* >( s ); 00036 } 00037 00038 bool checkSet( const SetGet* s ) const { 00039 return dynamic_cast< const SetGet1< ProcPtr >* >( s ); 00040 } 00041 00042 bool strSet( const Eref& tgt, 00043 const string& field, const string& arg ) const { 00044 ProcInfo p; 00045 stringstream ss( arg ); 00046 double dt = 1; 00047 ss >> dt; 00048 if ( dt <= 0 ) 00049 dt = 1; 00050 p.dt = dt; 00051 return SetGet1< ProcPtr >::set( tgt.objId(), field, &p ); 00052 } 00053 00054 void op( const Eref& e, const double* buf ) const { 00055 Conv< ProcPtr > arg1( buf ); 00056 (reinterpret_cast< T* >( e.data() )->*func_)( e, *arg1 ) ; 00057 } 00058 00059 00060 // This key extra function does Process calls. 00061 void proc( char* obj, const Eref& e, ProcPtr p ) const { 00062 ( reinterpret_cast< T* >( obj )->*func_)( e, p ); 00063 } 00064 00065 string rttiType() const { 00066 return "void"; 00067 } 00068 00069 private: 00070 void ( T::*func_ )( const Eref& e, ProcPtr ); 00071 }; 00072 */ 00073 template< class T > class ProcOpFunc: public EpFunc1< T, ProcPtr > 00074 { 00075 public: 00076 ProcOpFunc( void ( T::*func )( const Eref& e, ProcPtr ) ) 00077 : EpFunc1< T, ProcPtr >( func ) 00078 {;} 00079 00080 string rttiType() const { 00081 return "const ProcInfo*"; 00082 } 00083 }; 00084 00085 #endif //_PROC_OPFUNC_H