MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OpFuncBase.cpp
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-2013 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 #include "header.h"
10 #include "HopFunc.h"
11 
12 const unsigned char MooseSendHop = 0;
13 const unsigned char MooseSetHop = 1;
14 const unsigned char MooseSetVecHop = 2;
15 const unsigned char MooseGetHop = 4;
16 const unsigned char MooseGetVecHop = 5;
17 const unsigned char MooseReturnHop = 8;
18 const unsigned char MooseTestHop = 255;
19 
20 vector< OpFunc* >& OpFunc::ops()
21 {
22  static vector< OpFunc* > op;
23  return op;
24 }
25 
27 {
28  opIndex_ = ops().size();
29  ops().push_back( this );
30 }
31 
32 const OpFunc* OpFunc0Base::makeHopFunc( HopIndex hopIndex ) const
33 {
34  return new HopFunc0( hopIndex );
35 }
36 
37 void OpFunc0Base::opBuffer( const Eref& e, double* buf ) const
38 {
39  op( e );
40 }
41 
42 const OpFunc* OpFunc::lookop( unsigned int opIndex )
43 {
44  assert ( opIndex < ops().size() );
45  return ops()[ opIndex ];
46 }
47 
48 // Static function
49 unsigned int OpFunc::rebuildOpIndex()
50 {
51  for( vector< OpFunc* >::iterator
52  i = ops().begin(); i != ops().end(); ++i ) {
53  (*i)->opIndex_ = ~0U;
54  }
55  return ops().size();
56 }
57 
58 bool OpFunc::setIndex( unsigned int i ) // Should only be called by Cinfo.
59 {
60  if( opIndex_ == ~0U ) {
61  opIndex_ = i;
62  ops()[i] = this;
63  return true;
64  }
65  /*
66  cout << " OpFunc " << rttiType() <<
67  " already setup. (old,new) index = (" <<
68  opIndex_ << ", " << i << " )\n";
69  */
70  return false;
71 }
const unsigned char MooseGetVecHop
Definition: OpFuncBase.cpp:16
static const OpFunc * lookop(unsigned int opIndex)
Definition: OpFuncBase.cpp:42
const unsigned char MooseSendHop
Definition: OpFuncBase.cpp:12
static double op(double x)
bool setIndex(unsigned int i)
Used when rebuilding the Fid->OpFunc mapping.
Definition: OpFuncBase.cpp:58
const unsigned char MooseReturnHop
Definition: OpFuncBase.cpp:17
virtual void op(const Eref &e) const =0
const unsigned char MooseGetHop
Definition: OpFuncBase.cpp:15
unsigned int opIndex_
Definition: OpFuncBase.h:75
static vector< OpFunc * > & ops()
Definition: OpFuncBase.cpp:20
Definition: Eref.h:26
const unsigned char MooseSetVecHop
Definition: OpFuncBase.cpp:14
const unsigned char MooseSetHop
Definition: OpFuncBase.cpp:13
static unsigned int rebuildOpIndex()
cleans out the entire Ops vector. Returns size of orig vector.
Definition: OpFuncBase.cpp:49
void opBuffer(const Eref &e, double *buf) const
Executes the OpFunc by converting args.
Definition: OpFuncBase.cpp:37
const unsigned char MooseTestHop
Definition: OpFuncBase.cpp:18
const OpFunc * makeHopFunc(HopIndex hopIndex) const
Definition: OpFuncBase.cpp:32
unsigned int opIndex() const
Definition: OpFuncBase.h:66