MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OpFunc.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 _OPFUNC_H
11 #define _OPFUNC_H
12 
13 template< class T > class OpFunc0: public OpFunc0Base
14 {
15  public:
16  OpFunc0( void ( T::*func )( ) )
17  : func_( func )
18  {;}
19 
20  void op( const Eref& e ) const {
21  (reinterpret_cast< T* >( e.data() )->*func_)();
22  }
23  private:
24  void ( T::*func_ )( );
25 };
26 
27 template< class T, class A > class OpFunc1: public OpFunc1Base<A>
28 {
29  public:
30  OpFunc1( void ( T::*func )( A ) )
31  : func_( func )
32  {;}
33  void op( const Eref& e, A arg ) const {
34  (reinterpret_cast< T* >( e.data() )->*func_)( arg );
35  }
36  private:
37  void ( T::*func_ )( A );
38 };
39 
40 template< class T, class A1, class A2 > class OpFunc2:
41  public OpFunc2Base< A1, A2 >
42 {
43  public:
44  OpFunc2( void ( T::*func )( A1, A2 ) )
45  : func_( func )
46  {;}
47 
48  void op( const Eref& e, A1 arg1, A2 arg2 ) const {
49  (reinterpret_cast< T* >( e.data() )->*func_)( arg1, arg2 );
50  }
51 
52  private:
53  void ( T::*func_ )( A1, A2 );
54 };
55 
56 template< class T, class A1, class A2, class A3 > class OpFunc3:
57  public OpFunc3Base< A1, A2, A3 >
58 {
59  public:
60  OpFunc3( void ( T::*func )( A1, A2, A3 ) )
61  : func_( func )
62  {;}
63  void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3 ) const {
64  (reinterpret_cast< T* >( e.data() )->*func_)( arg1, arg2, arg3);
65  }
66  private:
67  void ( T::*func_ )( A1, A2, A3 );
68 };
69 
70 template< class T, class A1, class A2, class A3, class A4 > class OpFunc4:
71  public OpFunc4Base< A1, A2, A3, A4 >
72 {
73  public:
74  OpFunc4( void ( T::*func )( A1, A2, A3, A4 ) )
75  : func_( func )
76  {;}
77 
78  void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3, A4 arg4 ) const {
79  (reinterpret_cast< T* >( e.data() )->*func_)(
80  arg1, arg2, arg3, arg4 );
81  }
82 
83  private:
84  void ( T::*func_ )( A1, A2, A3, A4 );
85 };
86 
87 template< class T, class A1, class A2, class A3, class A4, class A5 >
88  class OpFunc5: public OpFunc5Base< A1, A2, A3, A4, A5 >
89 {
90  public:
91  OpFunc5( void ( T::*func )( A1, A2, A3, A4, A5 ) )
92  : func_( func )
93  {;}
94 
95  void op( const Eref& e,
96  A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5 ) const {
97  (reinterpret_cast< T* >( e.data() )->*func_)(
98  arg1, arg2, arg3, arg4, arg5 );
99  }
100 
101  private:
102  void ( T::*func_ )( A1, A2, A3, A4, A5 );
103 };
104 
105 
106 template< class T,
107  class A1, class A2, class A3, class A4, class A5, class A6 >
108  class OpFunc6: public OpFunc6Base< A1, A2, A3, A4, A5, A6 >
109 {
110  public:
111  OpFunc6( void ( T::*func )( A1, A2, A3, A4, A5, A6 ) )
112  : func_( func )
113  {;}
114 
115  void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3, A4 arg4,
116  A5 arg5, A6 arg6 ) const {
117  (reinterpret_cast< T* >( e.data() )->*func_)(
118  arg1, arg2, arg3, arg4, arg5, arg6 );
119  }
120 
121  private:
122  void ( T::*func_ )( A1, A2, A3, A4, A5, A6 );
123 };
124 
125 
134 template< class T, class A > class GetOpFunc: public GetOpFuncBase< A >
135 {
136  public:
137  GetOpFunc( A ( T::*func )() const )
138  : func_( func )
139  {;}
140 
141  void op( const Eref& e, vector< A >* ret ) const {
142  ret->push_back( returnOp( e ) );
143  }
144 
145  A returnOp( const Eref& e ) const {
146  return ( reinterpret_cast< T* >( e.data() )->*func_)();
147  }
148 
149  private:
150  A ( T::*func_ )() const;
151 };
152 
164 template< class T, class L, class A > class GetOpFunc1:
165  public LookupGetOpFuncBase< L, A >
166 {
167  public:
168  GetOpFunc1( A ( T::*func )( L ) const )
169  : func_( func )
170  {;}
171 
183  void op( const Eref& e, L index, ObjId recipient, FuncId fid )
184  const {
185  const OpFunc *f = recipient.element()->cinfo()->getOpFunc( fid);
186  const OpFunc1Base< A >* recvOpFunc =
187  dynamic_cast< const OpFunc1Base< A >* >( f );
188  assert( recvOpFunc );
189  recvOpFunc->op( recipient.eref(), returnOp( e, index ) );
190  }
191 
193  A returnOp( const Eref& e, const L& index ) const {
194  return ( reinterpret_cast< T* >( e.data() )->*func_)( index );
195  }
196 
197  private:
198  A ( T::*func_ )( L ) const;
199 };
200 
201 #endif // _OPFUNC_H
void op(const Eref &e, vector< A > *ret) const
Definition: OpFunc.h:141
char * data() const
Definition: Eref.cpp:41
const OpFunc * getOpFunc(FuncId fid) const
Definition: Cinfo.cpp:240
OpFunc0(void(T::*func)())
Definition: OpFunc.h:16
void(T::* func_)(A1, A2, A3, A4, A5)
Definition: OpFunc.h:102
virtual void op(const Eref &e, A arg) const =0
void op(const Eref &e, A1 arg1, A2 arg2) const
Definition: OpFunc.h:48
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) const
Definition: OpFunc.h:115
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3) const
Definition: OpFunc.h:63
void op(const Eref &e, A arg) const
Definition: OpFunc.h:33
Definition: OpFunc.h:56
OpFunc1(void(T::*func)(A))
Definition: OpFunc.h:30
OpFunc6(void(T::*func)(A1, A2, A3, A4, A5, A6))
Definition: OpFunc.h:111
Definition: ObjId.h:20
void op(const Eref &e) const
Definition: OpFunc.h:20
A returnOp(const Eref &e) const
Definition: OpFunc.h:145
GetOpFunc(A(T::*func)() const )
Definition: OpFunc.h:137
Definition: OpFunc.h:40
OpFunc4(void(T::*func)(A1, A2, A3, A4))
Definition: OpFunc.h:74
void(T::* func_)(A1, A2, A3)
Definition: OpFunc.h:67
OpFunc5(void(T::*func)(A1, A2, A3, A4, A5))
Definition: OpFunc.h:91
void(T::* func_)(A1, A2)
Definition: OpFunc.h:53
Definition: OpFunc.h:27
Definition: Eref.h:26
const Cinfo * cinfo() const
Definition: Element.cpp:66
Element * element() const
Definition: ObjId.cpp:124
A(T::* func_)() const
Definition: OpFunc.h:150
Definition: OpFunc.h:88
Eref eref() const
Definition: ObjId.cpp:66
OpFunc2(void(T::*func)(A1, A2))
Definition: OpFunc.h:44
void(T::* func_)()
Definition: OpFunc.h:24
A(T::* func_)(L) const
Definition: OpFunc.h:198
Definition: OpFunc.h:13
void op(const Eref &e, L index, ObjId recipient, FuncId fid) const
Definition: OpFunc.h:183
void(T::* func_)(A1, A2, A3, A4)
Definition: OpFunc.h:84
GetOpFunc1(A(T::*func)(L) const )
Definition: OpFunc.h:168
unsigned int FuncId
Definition: header.h:42
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) const
Definition: OpFunc.h:95
OpFunc3(void(T::*func)(A1, A2, A3))
Definition: OpFunc.h:60
void(T::* func_)(A)
Definition: OpFunc.h:37
void(T::* func_)(A1, A2, A3, A4, A5, A6)
Definition: OpFunc.h:122
A returnOp(const Eref &e, const L &index) const
Distinct reduceOp with the index.
Definition: OpFunc.h:193
Definition: OpFunc.h:70
void op(const Eref &e, A1 arg1, A2 arg2, A3 arg3, A4 arg4) const
Definition: OpFunc.h:78