MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Eref.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-2010 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 #include "header.h"
11 #include "../shell/Shell.h"
12 
14  : e_( 0 ), i_( 0 ), f_( 0 )
15 {
16  ;
17 }
18 
19 Eref::Eref( Element* e, unsigned int index, unsigned int field )
20  : e_( e ), i_( index ), f_( field )
21 {
22  ;
23 }
24 
25 ostream& operator <<( ostream& s, const Eref& e )
26 {
27  if ( e.i_ == 0 ) {
28  if ( e.f_ == 0 )
29  s << e.e_->getName();
30  else
31  s << e.e_->getName() << "[0][" << e.f_ << "]";
32  } else {
33  if ( e.f_ == 0 )
34  s << e.e_->getName() << "[" << e.i_ << "]";
35  else
36  s << e.e_->getName() << "[" << e.i_ << "][" << e.f_ << "]";
37  }
38  return s;
39 }
40 
41 char* Eref::data() const
42 {
43  assert( isDataHere() );
44  return e_->data( e_->rawIndex( i_ ), f_ );
45 }
46 
47 bool Eref::isDataHere() const
48 {
49  return ( e_->getNode( i_ ) == Shell::myNode() );
50 }
51 
52 unsigned int Eref::getNode() const
53 {
54  return e_->getNode( i_ );
55 }
56 
58 {
59  return ObjId( e_->id(), i_, f_ );
60 }
61 
62 Id Eref::id() const
63 {
64  return e_->id();
65 }
66 
67 const vector< MsgDigest >& Eref::msgDigest( unsigned int bindIndex ) const
68 {
69  return e_->msgDigest( i_ * e_->cinfo()->numBindIndex() + bindIndex );
70 }
Id id() const
Definition: Eref.cpp:62
char * data() const
Definition: Eref.cpp:41
bool isDataHere() const
Definition: Eref.cpp:47
unsigned int getNode() const
Definition: Eref.cpp:52
Eref()
Definition: Eref.cpp:13
Definition: ObjId.h:20
unsigned int f_
Definition: Eref.h:95
Id id() const
Definition: Element.cpp:71
const vector< MsgDigest > & msgDigest(unsigned int bindIndex) const
Definition: Eref.cpp:67
const vector< MsgDigest > & msgDigest(unsigned int index)
Definition: Element.cpp:289
ObjId objId() const
Definition: Eref.cpp:57
Definition: Eref.h:26
unsigned int i_
Definition: Eref.h:94
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const =0
Definition: Id.h:17
virtual unsigned int rawIndex(unsigned int dataIndex) const =0
virtual unsigned int getNode(unsigned int dataIndex) const =0
Returns node number of specified dataIndex.
static unsigned int myNode()
unsigned int numBindIndex() const
Definition: Cinfo.cpp:265
ostream & operator<<(ostream &s, const Eref &e)
Definition: Eref.cpp:25
Element * e_
Definition: Eref.h:93
const string & getName() const
Definition: Element.cpp:56