MOOSE - Multiscale Object Oriented Simulation Environment
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SingleMsg Class Reference

#include <SingleMsg.h>

+ Inheritance diagram for SingleMsg:
+ Collaboration diagram for SingleMsg:

Public Member Functions

Msgcopy (Id origSrc, Id newSrc, Id newTgt, FuncId fid, unsigned int b, unsigned int n) const
 
ObjId findOtherEnd (ObjId end) const
 
Eref firstTgt (const Eref &src) const
 
DataId getI1 () const
 
DataId getI2 () const
 
unsigned int getTargetField () const
 
DataId i1 () const
 
DataId i2 () const
 
Id managerId () const
 
void setI1 (DataId di)
 
void setI2 (DataId di)
 
void setTargetField (unsigned int f)
 
 SingleMsg (const Eref &e1, const Eref &e2, unsigned int msgIndex)
 
void sources (vector< vector< Eref > > &v) const
 
void targets (vector< vector< Eref > > &v) const
 
 ~SingleMsg ()
 
- Public Member Functions inherited from Msg
Elemente1 () const
 
Elemente2 () const
 
ObjId getAdjacent (ObjId) const
 
vector< string > getDestFieldsOnE1 () const
 
vector< string > getDestFieldsOnE2 () const
 
Id getE1 () const
 
Id getE2 () const
 
vector< string > getSrcFieldsOnE1 () const
 
vector< string > getSrcFieldsOnE2 () const
 
bool isForward (const Element *src) const
 
ObjId mid () const
 
 Msg (ObjId mid, Element *e1, Element *e2)
 Constructor. More...
 
virtual ~Msg ()
 Destructor. More...
 

Static Public Member Functions

static const CinfoinitCinfo ()
 
static char * lookupMsg (unsigned int index)
 Static function for Msg access. More...
 
static unsigned int numMsg ()
 Msg lookup functions. More...
 
- Static Public Member Functions inherited from Msg
static void clearAllMsgs ()
 
static void deleteMsg (ObjId mid)
 
static const MsggetMsg (ObjId m)
 
static const CinfoinitCinfo ()
 
static unsigned int initMsgManagers ()
 
static bool isLastTrump ()
 True when MOOSE has been terminated and is being cleaned up. More...
 
static const MsglastMsg ()
 

Private Attributes

unsigned int f2_
 
DataId i1_
 
DataId i2_
 

Static Private Attributes

static Id managerId_
 
static vector< SingleMsg * > msg_
 

Friends

unsigned int Msg::initMsgManagers ()
 

Additional Inherited Members

- Protected Attributes inherited from Msg
Elemente1_
 Index of this Msg on the msg_ vector. More...
 
Elemente2_
 Element 1 attached to Msg. More...
 
ObjId mid_
 
- Static Protected Attributes inherited from Msg
static bool lastTrump_ = false
 Flag to indicate termination of program. More...
 
static Id msgManagerId_
 Element 2 attached to Msg. More...
 

Detailed Description

This is a message from a single source object to a single target object. The source object must be a DataEntry. The target object may be on a FieldElement, and the target specification includes the index of the field object.

Definition at line 20 of file SingleMsg.h.

Constructor & Destructor Documentation

SingleMsg::SingleMsg ( const Eref e1,
const Eref e2,
unsigned int  msgIndex 
)

Definition at line 21 of file SingleMsg.cpp.

References msg_.

Referenced by copy().

22  : Msg( ObjId( managerId_, (msgIndex != 0 ) ? msgIndex: msg_.size() ),
23  e1.element(), e2.element() ),
24  i1_( e1.dataIndex() ),
25  i2_( e2.dataIndex() ),
26  f2_( e2.fieldIndex() )
27 {
28  if ( msgIndex == 0 )
29  {
30  msg_.push_back( this );
31  return;
32  }
33  else if ( msg_.size() <= msgIndex )
34  {
35  msg_.resize( msgIndex + 1 );
36  }
37  msg_[ msgIndex ] = this;
38 }
unsigned int dataIndex() const
Definition: Eref.h:50
Definition: ObjId.h:20
Element * element() const
Definition: Eref.h:42
unsigned int fieldIndex() const
Definition: Eref.h:61
DataId i1_
Definition: SingleMsg.h:58
static vector< SingleMsg * > msg_
Definition: SingleMsg.h:62
DataId i2_
Definition: SingleMsg.h:59
unsigned int f2_
Definition: SingleMsg.h:60
Msg(ObjId mid, Element *e1, Element *e2)
Constructor.
Definition: Msg.cpp:30
static Id managerId_
Definition: SingleMsg.h:61

+ Here is the caller graph for this function:

SingleMsg::~SingleMsg ( )

Definition at line 40 of file SingleMsg.cpp.

References ObjId::dataIndex, Msg::mid_, and msg_.

41 {
42  assert( mid_.dataIndex < msg_.size() );
43  msg_[ mid_.dataIndex ] = 0; // ensure deleted ptr isn't reused.
44 }
static vector< SingleMsg * > msg_
Definition: SingleMsg.h:62
ObjId mid_
Definition: Msg.h:178
unsigned int dataIndex
Definition: ObjId.h:99

Member Function Documentation

Msg * SingleMsg::copy ( Id  origSrc,
Id  newSrc,
Id  newTgt,
FuncId  fid,
unsigned int  b,
unsigned int  n 
) const
virtual

Make a copy of this Msg. The original msg was on origSrc. The new Msg should go from newSrc to newTgt, and have the function fid, on bindIndex b. The copy may have to be a higher-order Msg type to handle arrays if n > 1. Note that n is not the number of msgs, but the multiplier by which numData will be scaled.

Implements Msg.

Definition at line 111 of file SingleMsg.cpp.

References Element::addMsgAndFunc(), Msg::e1(), Msg::e2(), Id::element(), f2_, i1_, i2_, Msg::mid(), and SingleMsg().

113 {
114  const Element* orig = origSrc.element();
115  if ( n <= 1 )
116  {
117  SingleMsg* ret = 0;
118  if ( orig == e1() )
119  {
120  ret = new SingleMsg( Eref( newSrc.element(), i1_ ),
121  Eref( newTgt.element(), i2_, f2_ ), 0 );
122  ret->e1()->addMsgAndFunc( ret->mid(), fid, b );
123  }
124  else if ( orig == e2() )
125  {
126  ret = new SingleMsg( Eref( newTgt.element(), i1_ ),
127  Eref( newSrc.element(), i2_, f2_ ), 0 );
128  ret->e2()->addMsgAndFunc( ret->mid(), fid, b );
129  }
130  else
131  {
132  assert( 0 );
133  }
134  return ret;
135  }
136  else
137  {
138  // Here we need a SliceMsg which goes from one 2-d array to another.
139  cout << "Error: SingleMsg::copy: SliceMsg not yet implemented\n";
140  return 0;
141  }
142 }
Element * e2() const
Definition: Msg.h:68
ObjId mid() const
Definition: Msg.h:106
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
void addMsgAndFunc(ObjId mid, FuncId fid, BindIndex bindIndex)
Definition: Element.cpp:128
DataId i1_
Definition: SingleMsg.h:58
Definition: Eref.h:26
Element * e1() const
Definition: Msg.h:61
DataId i2_
Definition: SingleMsg.h:59
unsigned int f2_
Definition: SingleMsg.h:60
SingleMsg(const Eref &e1, const Eref &e2, unsigned int msgIndex)
Definition: SingleMsg.cpp:21

+ Here is the call graph for this function:

ObjId SingleMsg::findOtherEnd ( ObjId  ) const
virtual

Find the other end of this Msg. In most cases this is a straightforward return of e1 or e2, plus perhaps a DataId. But in some complex msgs we need to figure out DataIds that match with the target. In many-to-one cases we just return the first entry. If no Element match, return ObjId( Id(), DataId::bad() ) If Element e matches but not DataId, return ObjId( e.id(), DataId::bad() )

Implements Msg.

Definition at line 96 of file SingleMsg.cpp.

References BADINDEX, ObjId::dataIndex, Msg::e1(), Msg::e2(), ObjId::element(), i1_, and i2_.

97 {
98  if ( f.element() == e1() )
99  {
100  if ( f.dataIndex == i1_ )
101  return ObjId( e2()->id(), i2_ );
102  }
103  else if ( f.element() == e2() )
104  {
105  if ( f.dataIndex == i2_ )
106  return ObjId( e1()->id(), i1_ );
107  }
108  return ObjId( 0, BADINDEX );
109 }
Element * e2() const
Definition: Msg.h:68
Definition: ObjId.h:20
DataId i1_
Definition: SingleMsg.h:58
Element * e1() const
Definition: Msg.h:61
DataId i2_
Definition: SingleMsg.h:59
const unsigned int BADINDEX
Used by ObjId and Eref.
Definition: consts.cpp:25

+ Here is the call graph for this function:

Eref SingleMsg::firstTgt ( const Eref src) const
virtual

Obtain the first target Eref for the specified Src Eref It is really meant only to work with messages with a single target ObjId for each given src, typically OneToOne.

Implements Msg.

Definition at line 46 of file SingleMsg.cpp.

References Msg::e1_, Msg::e2_, Eref::element(), f2_, i1_, and i2_.

47 {
48  if ( src.element() == e1_ )
49  return Eref( e2_, i2_, f2_ );
50  else if ( src.element() == e2_ )
51  return Eref( e1_, i1_ );
52  return Eref( 0, 0 );
53 }
Element * element() const
Definition: Eref.h:42
DataId i1_
Definition: SingleMsg.h:58
Definition: Eref.h:26
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
DataId i2_
Definition: SingleMsg.h:59
Element * e2_
Element 1 attached to Msg.
Definition: Msg.h:181
unsigned int f2_
Definition: SingleMsg.h:60

+ Here is the call graph for this function:

DataId SingleMsg::getI1 ( ) const

Definition at line 187 of file SingleMsg.cpp.

References i1_.

Referenced by initCinfo().

188 {
189  return i1_;
190 }
DataId i1_
Definition: SingleMsg.h:58

+ Here is the caller graph for this function:

DataId SingleMsg::getI2 ( ) const

Definition at line 199 of file SingleMsg.cpp.

References i2_.

Referenced by initCinfo().

200 {
201  return i2_;
202 }
DataId i2_
Definition: SingleMsg.h:59

+ Here is the caller graph for this function:

unsigned int SingleMsg::getTargetField ( ) const

Definition at line 217 of file SingleMsg.cpp.

References f2_.

218 {
219  return f2_;
220 }
unsigned int f2_
Definition: SingleMsg.h:60
DataId SingleMsg::i1 ( ) const

Definition at line 81 of file SingleMsg.cpp.

References i1_.

82 {
83  return i1_;
84 }
DataId i1_
Definition: SingleMsg.h:58
DataId SingleMsg::i2 ( ) const

Definition at line 86 of file SingleMsg.cpp.

References i2_.

87 {
88  return i2_;
89 }
DataId i2_
Definition: SingleMsg.h:59
const Cinfo * SingleMsg::initCinfo ( )
static

Definition at line 148 of file SingleMsg.cpp.

References getI1(), getI2(), Msg::initCinfo(), setI1(), setI2(), and singleMsgCinfo.

Referenced by Msg::initMsgManagers().

149 {
151  // Field definitions.
153  static ValueFinfo< SingleMsg, DataId > index1(
154  "i1",
155  "Index of source object.",
158  );
159  static ValueFinfo< SingleMsg, DataId > index2(
160  "i2",
161  "Index of dest object.",
164  );
165 
166  static Finfo* singleMsgFinfos[] =
167  {
168  &index1, // value
169  &index2, // value
170  };
171 
172  static Dinfo< short > dinfo;
173  static Cinfo singleMsgCinfo (
174  "SingleMsg", // name
175  Msg::initCinfo(), // base class
176  singleMsgFinfos,
177  sizeof( singleMsgFinfos ) / sizeof( Finfo* ), // num Fields
178  &dinfo
179  );
180 
181  return &singleMsgCinfo;
182 }
void setI2(DataId di)
Definition: SingleMsg.cpp:204
Definition: Dinfo.h:60
void setI1(DataId di)
Definition: SingleMsg.cpp:192
DataId getI1() const
Definition: SingleMsg.cpp:187
static const Cinfo * singleMsgCinfo
Definition: SingleMsg.cpp:184
Definition: Cinfo.h:18
DataId getI2() const
Definition: SingleMsg.cpp:199
static const Cinfo * initCinfo()
Definition: Msg.cpp:165
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char * SingleMsg::lookupMsg ( unsigned int  index)
static

Static function for Msg access.

Definition at line 229 of file SingleMsg.cpp.

References msg_.

Referenced by Msg::clearAllMsgs(), and Msg::initMsgManagers().

230 {
231  assert( index < msg_.size() );
232  return reinterpret_cast< char* >( msg_[index] );
233 }
static vector< SingleMsg * > msg_
Definition: SingleMsg.h:62

+ Here is the caller graph for this function:

Id SingleMsg::managerId ( ) const

Definition at line 91 of file SingleMsg.cpp.

References managerId_.

92 {
93  return SingleMsg::managerId_;
94 }
static Id managerId_
Definition: SingleMsg.h:61
unsigned int SingleMsg::numMsg ( )
static

Msg lookup functions.

Static function for Msg access.

Definition at line 223 of file SingleMsg.cpp.

References msg_.

Referenced by Msg::clearAllMsgs(), and Msg::initMsgManagers().

224 {
225  return msg_.size();
226 }
static vector< SingleMsg * > msg_
Definition: SingleMsg.h:62

+ Here is the caller graph for this function:

void SingleMsg::setI1 ( DataId  di)

Definition at line 192 of file SingleMsg.cpp.

References Msg::e1(), Msg::e2(), i1_, and Element::markRewired().

Referenced by initCinfo().

193 {
194  i1_ = di;
195  e1()->markRewired();
196  e2()->markRewired();
197 }
void markRewired()
Definition: Element.cpp:706
Element * e2() const
Definition: Msg.h:68
DataId i1_
Definition: SingleMsg.h:58
Element * e1() const
Definition: Msg.h:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SingleMsg::setI2 ( DataId  di)

Definition at line 204 of file SingleMsg.cpp.

References Msg::e1(), Msg::e2(), i2_, and Element::markRewired().

Referenced by initCinfo().

205 {
206  i2_ = di;
207  e1()->markRewired();
208  e2()->markRewired();
209 }
void markRewired()
Definition: Element.cpp:706
Element * e2() const
Definition: Msg.h:68
Element * e1() const
Definition: Msg.h:61
DataId i2_
Definition: SingleMsg.h:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SingleMsg::setTargetField ( unsigned int  f)

Definition at line 211 of file SingleMsg.cpp.

References Msg::e1(), f2_, and Element::markRewired().

212 {
213  f2_ = f;
214  e1()->markRewired();
215 }
void markRewired()
Definition: Element.cpp:706
Element * e1() const
Definition: Msg.h:61
unsigned int f2_
Definition: SingleMsg.h:60

+ Here is the call graph for this function:

void SingleMsg::sources ( vector< vector< Eref > > &  v) const
virtual

Return all the sources of e2 from e1, that is, all the msgs coming into specified entries on e2 from e1.

ALLDATA used when the sources include all data entries on a source. Indexing is v[dataId in range e2.numData][src list]

Implements Msg.

Definition at line 55 of file SingleMsg.cpp.

References Msg::e1_, Msg::e2_, i1_, i2_, and Element::numData().

56 {
57  v.clear();
58  v.resize( e2_->numData() );
59  v[i2_].resize( 1, Eref( e1_, i1_ ) );
60 }
DataId i1_
Definition: SingleMsg.h:58
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
DataId i2_
Definition: SingleMsg.h:59
Element * e2_
Element 1 attached to Msg.
Definition: Msg.h:181

+ Here is the call graph for this function:

void SingleMsg::targets ( vector< vector< Eref > > &  v) const
virtual

Return all the targets of e1 on e2, that is, all the msgs going from specified entries on e1 to e2. ALLDATA used when the targets include all data entries on a target. Indexing is v[dataId in range e1.numData][tgt list]

Implements Msg.

Definition at line 62 of file SingleMsg.cpp.

References Msg::e1_, Msg::e2_, f2_, i1_, i2_, and Element::numData().

63 {
64  v.clear();
65  v.resize( e1_->numData() );
66  v[i1_].resize( 1, Eref( e2_, i2_, f2_ ) );
67 }
DataId i1_
Definition: SingleMsg.h:58
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
DataId i2_
Definition: SingleMsg.h:59
Element * e2_
Element 1 attached to Msg.
Definition: Msg.h:181
unsigned int f2_
Definition: SingleMsg.h:60

+ Here is the call graph for this function:

Friends And Related Function Documentation

unsigned int Msg::initMsgManagers ( )
friend

Member Data Documentation

unsigned int SingleMsg::f2_
private

Definition at line 60 of file SingleMsg.h.

Referenced by copy(), firstTgt(), getTargetField(), setTargetField(), and targets().

DataId SingleMsg::i1_
private

Definition at line 58 of file SingleMsg.h.

Referenced by copy(), findOtherEnd(), firstTgt(), getI1(), i1(), setI1(), sources(), and targets().

DataId SingleMsg::i2_
private

Definition at line 59 of file SingleMsg.h.

Referenced by copy(), findOtherEnd(), firstTgt(), getI2(), i2(), setI2(), sources(), and targets().

Id SingleMsg::managerId_
staticprivate

Definition at line 61 of file SingleMsg.h.

Referenced by Msg::initMsgManagers(), and managerId().

vector< SingleMsg * > SingleMsg::msg_
staticprivate

Definition at line 62 of file SingleMsg.h.

Referenced by lookupMsg(), numMsg(), SingleMsg(), and ~SingleMsg().


The documentation for this class was generated from the following files: