MOOSE - Multiscale Object Oriented Simulation Environment
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
EpFunc.h
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2009 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #ifndef _EPFUNC_H
11 #define _EPFUNC_H
12 
18 template< class T > T* getEpFuncData( const Eref& e )
19 {
20  return reinterpret_cast< T* >( e.data() ) ;
21 }
22 
39 template<> Neutral* getEpFuncData< Neutral >( const Eref& e );
40 // Function is implemented in EpFunc.cpp.
41 
42 
43 
49 template< class T > class EpFunc0: public OpFunc0Base
50 {
51  public:
52  EpFunc0( void ( T::*func )( const Eref& e ) )
53  : func_( func )
54  {;}
55 
56  void op( const Eref& e ) const {
57  ( reinterpret_cast< T* >( e.data() )->*func_ )( e );
58  }
59 
60  private:
61  void ( T::*func_ )( const Eref& e );
62 };
63 
64 template< class T, class A > class EpFunc1: public OpFunc1Base< A >
65 {
66  public:
67  EpFunc1( void ( T::*func )( const Eref&, A ) )
68  : func_( func )
69  {;}
70 
71  void op( const Eref& e, A arg ) const {
72  ( reinterpret_cast< T* >( e.data() )->*func_ )( e, arg );
73  }
74 
75  private:
76  void ( T::*func_ )( const Eref& e, A );
77 };
78 
79 template< class T, class A1, class A2 > class EpFunc2:
80  public OpFunc2Base< A1, A2 >
81 {
82  public:
83  EpFunc2( void ( T::*func )( const Eref&, A1, A2 ) )
84  : func_( func )
85  {;}
86 
87  void op( const Eref& e, A1 arg1, A2 arg2 ) const {
88  ( reinterpret_cast< T* >( e.data() )->*func_ )( e, arg1, arg2 );
89  }
90 
91  private:
92  void ( T::*func_ )( const Eref& e, A1, A2 );
93 };
94 
95 template< class T, class A1, class A2, class A3 > class EpFunc3:
96  public OpFunc3Base< A1, A2, A3 >
97 {
98  public:
99  EpFunc3( void ( T::*func )( const Eref&, A1, A2, A3 ) )
100  : func_( func )
101  {;}
102 
103  void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3 ) const {
104  ( reinterpret_cast< T* >( e.data() )->*func_ )(
105  e, arg1, arg2, arg3 );
106  }
107 
108  private:
109  void ( T::*func_ )( const Eref& e, A1, A2, A3 );
110 };
111 
112 template< class T, class A1, class A2, class A3, class A4 > class EpFunc4:
113  public OpFunc4Base< A1, A2, A3, A4 >
114 {
115  public:
116  EpFunc4( void ( T::*func )( const Eref&, A1, A2, A3, A4 ) )
117  : func_( func )
118  {;}
119 
120  void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3, A4 arg4 ) const {
121  ( reinterpret_cast< T* >( e.data() )->*func_ )(
122  e, arg1, arg2, arg3, arg4 );
123  }
124 
125  private:
126  void ( T::*func_ )( const Eref& e, A1, A2, A3, A4 );
127 };
128 
129 template< class T, class A1, class A2, class A3, class A4, class A5 >
130  class EpFunc5: public OpFunc5Base< A1, A2, A3, A4, A5 >
131 {
132  public:
133  EpFunc5( void ( T::*func )( const Eref&, A1, A2, A3, A4, A5 ) )
134  : func_( func )
135  {;}
136 
137  void op( const Eref& e,
138  A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5 ) const {
139  ( reinterpret_cast< T* >( e.data() )->*func_ )(
140  e, arg1, arg2, arg3, arg4, arg5 );
141  }
142  private:
143  void ( T::*func_ )( const Eref& e, A1, A2, A3, A4, A5 );
144 };
145 
146 template< class T,
147  class A1, class A2, class A3, class A4, class A5, class A6 >
148  class EpFunc6: public OpFunc6Base< A1, A2, A3, A4, A5, A6 >
149 {
150  public:
151  EpFunc6( void ( T::*func )( const Eref&, A1, A2, A3, A4, A5, A6 ) )
152  : func_( func )
153  {;}
154 
155  void op( const Eref& e,
156  A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6 )
157  const {
158  ( reinterpret_cast< T* >( e.data() )->*func_ )(
159  e, arg1, arg2, arg3, arg4, arg5, arg6 );
160  }
161 
162  private:
163  void ( T::*func_ )( const Eref& e, A1, A2, A3, A4, A5, A6 );
164 };
165 
174 template< class T, class A > class GetEpFunc: public GetOpFuncBase< A >
175 {
176  public:
177  GetEpFunc( A ( T::*func )( const Eref& e ) const )
178  : func_( func )
179  {;}
180 
181  void op( const Eref& e, vector< A >* ret ) const {
182  ret->push_back( returnOp( e ) );
183  }
184  /*
185  void op( const Eref& e, ObjId recipient, FuncId fid ) const {
186  const OpFunc *f = recipient.element()->cinfo()->getOpFunc( fid);
187  const OpFunc1Base< A >* recvOpFunc =
188  dynamic_cast< const OpFunc1Base< A >* >( f );
189  assert( recvOpFunc );
190  recvOpFunc->op( recipient.eref(), returnOp( e ) );
191  }
192  */
193 
194  A returnOp( const Eref& e ) const {
195  return ( getEpFuncData< T >( e )->*func_ )( e );
196  }
197 
198  private:
199  A ( T::*func_ )( const Eref& e ) const;
200 };
201 
202 
212 template< class T, class L, class A > class GetEpFunc1:
213  public LookupGetOpFuncBase< L, A >
214 {
215  public:
216  GetEpFunc1( A ( T::*func )( const Eref& e, L ) const )
217  : func_( func )
218  {;}
219 
220 
221  void op( const Eref& e, L index, ObjId recipient, FuncId fid )
222  const {
223  const OpFunc *f = recipient.element()->cinfo()->getOpFunc( fid);
224  const OpFunc1Base< A >* recvOpFunc =
225  dynamic_cast< const OpFunc1Base< A >* >( f );
226  assert( recvOpFunc );
227  recvOpFunc->op( recipient.eref(), returnOp( e, index ) );
228  }
229 
230  A returnOp( const Eref& e, const L& index ) const {
231  return ( reinterpret_cast< T* >( e.data() )->*func_)(
232  e, index );
233  }
234 
235  private:
236  A ( T::*func_ )( const Eref& e, L ) const;
237 };
238 
239 #endif //_EPFUNC_H
A(T::* func_)(const Eref &e) const
Definition: EpFunc.h:199
void(T::* func_)(const Eref &e, A1, A2)
Definition: EpFunc.h:92
void(T::* func_)(const Eref &e, A1, A2, A3, A4, A5)
Definition: EpFunc.h:143
GetEpFunc1(A(T::*func)(const Eref &e, L) const )
Definition: EpFunc.h:216
GetEpFunc(A(T::*func)(const Eref &e) const )
Definition: EpFunc.h:177
char * data() const
Definition: Eref.cpp:41
const OpFunc * getOpFunc(FuncId fid) const
Definition: Cinfo.cpp:240
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3) const
Definition: EpFunc.h:103
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3, A4 arg4) const
Definition: EpFunc.h:120
EpFunc0(void(T::*func)(const Eref &e))
Definition: EpFunc.h:52
virtual void op(const Eref &e, A arg) const =0
Definition: EpFunc.h:64
void op(const Eref &e, L index, ObjId recipient, FuncId fid) const
Definition: EpFunc.h:221
Definition: ObjId.h:20
A returnOp(const Eref &e, const L &index) const
Definition: EpFunc.h:230
Definition: EpFunc.h:95
A(T::* func_)(const Eref &e, L) const
Definition: EpFunc.h:236
void(T::* func_)(const Eref &e, A1, A2, A3)
Definition: EpFunc.h:109
void(T::* func_)(const Eref &e, A)
Definition: EpFunc.h:76
EpFunc2(void(T::*func)(const Eref &, A1, A2))
Definition: EpFunc.h:83
Neutral * getEpFuncData< Neutral >(const Eref &e)
Definition: EpFunc.cpp:13
void(T::* func_)(const Eref &e, A1, A2, A3, A4)
Definition: EpFunc.h:126
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) const
Definition: EpFunc.h:155
void op(const Eref &e, A1 arg1, A2 arg2) const
Definition: EpFunc.h:87
EpFunc4(void(T::*func)(const Eref &, A1, A2, A3, A4))
Definition: EpFunc.h:116
Definition: EpFunc.h:49
EpFunc5(void(T::*func)(const Eref &, A1, A2, A3, A4, A5))
Definition: EpFunc.h:133
T * getEpFuncData(const Eref &e)
Definition: EpFunc.h:18
EpFunc6(void(T::*func)(const Eref &, A1, A2, A3, A4, A5, A6))
Definition: EpFunc.h:151
Definition: Eref.h:26
void op(const Eref &e) const
Definition: EpFunc.h:56
const Cinfo * cinfo() const
Definition: Element.cpp:66
void(T::* func_)(const Eref &e)
Definition: EpFunc.h:61
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) const
Definition: EpFunc.h:137
void op(const Eref &e, vector< A > *ret) const
Definition: EpFunc.h:181
Element * element() const
Definition: ObjId.cpp:124
Eref eref() const
Definition: ObjId.cpp:66
EpFunc1(void(T::*func)(const Eref &, A))
Definition: EpFunc.h:67
EpFunc3(void(T::*func)(const Eref &, A1, A2, A3))
Definition: EpFunc.h:99
unsigned int FuncId
Definition: header.h:42
A returnOp(const Eref &e) const
Definition: EpFunc.h:194
void op(const Eref &e, A arg) const
Definition: EpFunc.h:71
Definition: EpFunc.h:79
void(T::* func_)(const Eref &e, A1, A2, A3, A4, A5, A6)
Definition: EpFunc.h:163