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

#include <SharedFinfo.h>

+ Inheritance diagram for SharedFinfo:
+ Collaboration diagram for SharedFinfo:

Public Member Functions

bool addMsg (const Finfo *target, ObjId mid, Element *src) const
 
bool checkTarget (const Finfo *target) const
 
const vector< Finfo * > & dest () const
 
vector< string > innerDest () const
 
vector< string > innerSrc () const
 
void registerFinfo (Cinfo *c)
 
string rttiType () const
 This always returns void. We need to check the subsidiary Finfos. More...
 
 SharedFinfo (const string &name, const string &doc, Finfo **entries, unsigned int numEntries)
 
const vector< SrcFinfo * > & src () const
 
bool strGet (const Eref &tgt, const string &field, string &returnValue) const
 
bool strSet (const Eref &tgt, const string &field, const string &arg) const
 
 ~SharedFinfo ()
 
- Public Member Functions inherited from Finfo
const string & docs () const
 Returns documentation string. More...
 
 Finfo (const string &name, const string &doc)
 
const string & name () const
 
virtual void postCreationFunc (Id newId, Element *newElm) const
 
virtual ~Finfo ()
 

Private Attributes

vector< Finfo * > dest_
 
vector< SrcFinfo * > src_
 

Additional Inherited Members

- Static Public Member Functions inherited from Finfo
static const CinfoinitCinfo ()
 

Detailed Description

This is a SharedFinfo, which wraps an arbitrary set of regular Src and Dest Messages. Its main job is to do typechecking for setting up multiple data streams to go across the same Msg.

Definition at line 18 of file SharedFinfo.h.

Constructor & Destructor Documentation

SharedFinfo::SharedFinfo ( const string &  name,
const string &  doc,
Finfo **  entries,
unsigned int  numEntries 
)

This set of classes define Message Sources. Their main job is to supply a type-safe send operation, and to provide typechecking for it.

Definition at line 16 of file SharedFinfo.cpp.

References dest_, numEntries, and src_.

18  : Finfo( name, doc )
19 {
20  for ( unsigned int i = 0; i < numEntries; ++i )
21  {
22  Finfo* foo = entries[i];
23  SrcFinfo* s = dynamic_cast< SrcFinfo* >( foo );
24  // SrcFinfo* s = dynamic_cast< SrcFinfo* >( entries[i] );
25  if ( s != 0 )
26  src_.push_back( s );
27  else
28  dest_.push_back( entries[i] );
29  }
30 }
const int numEntries
Definition: proc.cpp:60
const string & name() const
Definition: Finfo.cpp:80
vector< SrcFinfo * > src_
Definition: SharedFinfo.h:59
Finfo(const string &name, const string &doc)
Definition: Finfo.cpp:13
vector< Finfo * > dest_
Definition: SharedFinfo.h:60
Definition: Finfo.h:12
SharedFinfo::~SharedFinfo ( )
inline

Definition at line 24 of file SharedFinfo.h.

24 {;}

Member Function Documentation

bool SharedFinfo::addMsg ( const Finfo target,
ObjId  mid,
Element src 
) const
virtual

First calls checkTarget on all targets, then sets up message. Returns true on success.

Reimplemented from Finfo.

Definition at line 95 of file SharedFinfo.cpp.

References checkTarget(), dest_, Msg::e1(), Msg::e2(), Msg::getMsg(), Element::getName(), Element::id(), and src_.

97 {
98  if ( !checkTarget( target ) )
99  return 0;
100  const SharedFinfo* tgt = dynamic_cast< const SharedFinfo* >( target );
101 
102  // We have a problem if the src and dest elms (e1 and e2) are the
103  // same, because this messes up the logic to assign the isForward flag.
104  // This is an issue only if the target Finfo wants to send data back.
105  // In other words, there are dest_ finfos on this SharedFinfo.
106  // Report this problem.
107  const Msg* m = Msg::getMsg( mid );
108  assert( m->e1() == srcElm );
109  Element* destElm = m->e2();
110  if ( srcElm == destElm && srcElm->id() != Id() ) {
111  if ( dest_.size() > 0 ) {
112  cout << "Error: SharedFinfo::addMsg: MessageId " << mid <<
113  endl <<
114  "Source Element == DestElement == " << srcElm->getName() <<
115  endl << "Recommend that you individually set up messages for" <<
116  " the components of the SharedFinfo, to ensure that the " <<
117  "direction of messaging is consistent.\n";
118  return 0;
119  }
120  }
121 
122 
123  for ( unsigned int i = 0; i < src_.size(); ++i ) {
124  if ( !src_[i]->addMsg( tgt->dest_[i], mid, srcElm ) ) {
125  // Should never happen. The checkTarget should preclude this.
126  cerr << "Error:SharedFinfo::addMsg: Failed on MessageId " <<
127  mid << ", unrecoverable\n";
128  exit(0);
129  }
130  }
131 
132 
133  for ( unsigned int i = 0; i < tgt->src_.size(); ++i ) {
134  if ( !tgt->src_[i]->addMsg( dest_[i], mid, destElm ) ) {
135  // Should never happen. The checkTarget should preclude this.
136  cerr << "Error:SharedFinfo::addMsg: Failed on MessageId " <<
137  mid << ", unrecoverable\n";
138  exit( 0 );
139  }
140  }
141  return 1;
142 }
Element * e2() const
Definition: Msg.h:68
bool addMsg(const Finfo *target, ObjId mid, Element *src) const
Definition: SharedFinfo.cpp:95
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
vector< SrcFinfo * > src_
Definition: SharedFinfo.h:59
Definition: Id.h:17
bool checkTarget(const Finfo *target) const
Definition: SharedFinfo.cpp:74
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
vector< Finfo * > dest_
Definition: SharedFinfo.h:60

+ Here is the call graph for this function:

bool SharedFinfo::checkTarget ( const Finfo target) const
virtual

Checks that the type of target Finfo matches self, and is safe to exchange messages with.

It is possible that we have DestFinfos in this SharedFinfo, that have not been registered. So we need to scan through. Note that the register operation overwrites values if they already exist. Best not to have conflicts!.

Reimplemented from Finfo.

Definition at line 74 of file SharedFinfo.cpp.

References dest_, and src_.

Referenced by addMsg().

75 {
76  const SharedFinfo* tgt = dynamic_cast< const SharedFinfo* >( target );
77  if ( tgt ) {
78  if ( src_.size() != tgt->dest_.size() &&
79  dest_.size() != tgt->src_.size() )
80  return 0;
81  for ( unsigned int i = 0; i < src_.size(); ++i ) {
82  if ( !src_[i]->checkTarget( tgt->dest_[i] ) )
83  return 0;
84  }
85  for ( unsigned int i = 0; i < tgt->src_.size(); ++i ) {
86  if ( !tgt->src_[i]->checkTarget( dest_[i] ) )
87  return 0;
88  }
89 
90  return 1;
91  }
92  return 0;
93 }
vector< SrcFinfo * > src_
Definition: SharedFinfo.h:59
bool checkTarget(const Finfo *target) const
Definition: SharedFinfo.cpp:74
vector< Finfo * > dest_
Definition: SharedFinfo.h:60

+ Here is the caller graph for this function:

const vector< Finfo * > & SharedFinfo::dest ( ) const

Definition at line 150 of file SharedFinfo.cpp.

References dest_.

Referenced by Element::getNeighbors(), and insertSharedMsgs().

151 {
152  return dest_;
153 }
vector< Finfo * > dest_
Definition: SharedFinfo.h:60

+ Here is the caller graph for this function:

vector< string > SharedFinfo::innerDest ( ) const
virtual

Returns subsidiary DestFinfos

Reimplemented from Finfo.

Definition at line 167 of file SharedFinfo.cpp.

References dest_.

168 {
169  vector< string > ret;
170  for ( vector< Finfo* >::const_iterator i = dest_.begin();
171  i != dest_.end(); ++i )
172  ret.push_back( (*i)->name() );
173  return ret;
174 }
vector< Finfo * > dest_
Definition: SharedFinfo.h:60
vector< string > SharedFinfo::innerSrc ( ) const
virtual

Returns subsidiary SrcFinfos

Reimplemented from Finfo.

Definition at line 158 of file SharedFinfo.cpp.

References src_.

159 {
160  vector< string > ret;
161  for ( vector< SrcFinfo* >::const_iterator i = src_.begin();
162  i != src_.end(); ++i )
163  ret.push_back( (*i)->name() );
164  return ret;
165 }
vector< SrcFinfo * > src_
Definition: SharedFinfo.h:59
void SharedFinfo::registerFinfo ( Cinfo c)
virtual

Returns string-ified form to handle template expectations for name field string getName() const; Assign function Ids, bindIndex and so on.

Implements Finfo.

Definition at line 32 of file SharedFinfo.cpp.

References dest_, Cinfo::registerFinfo(), and src_.

33 {
34  for( vector< SrcFinfo* >::iterator i =
35  src_.begin(); i != src_.end(); ++i)
36  c->registerFinfo( *i );
37  for( vector< Finfo* >::iterator i =
38  dest_.begin(); i != dest_.end(); ++i)
39  c->registerFinfo( *i );
40 }
void registerFinfo(Finfo *f)
Definition: Cinfo.cpp:114
vector< SrcFinfo * > src_
Definition: SharedFinfo.h:59
vector< Finfo * > dest_
Definition: SharedFinfo.h:60

+ Here is the call graph for this function:

string SharedFinfo::rttiType ( ) const
virtual

This always returns void. We need to check the subsidiary Finfos.

Reimplemented from Finfo.

Definition at line 176 of file SharedFinfo.cpp.

177 {
178  return "void";
179 }
const vector< SrcFinfo * > & SharedFinfo::src ( ) const

Definition at line 144 of file SharedFinfo.cpp.

References src_.

Referenced by Element::getNeighbors().

145 {
146  return src_;
147 }
vector< SrcFinfo * > src_
Definition: SharedFinfo.h:59

+ Here is the caller graph for this function:

bool SharedFinfo::strGet ( const Eref tgt,
const string &  field,
string &  returnValue 
) const
virtual

Function to return value of field into a string argument. Returns true on success. Normally called only from SetGet::strGet.

Implements Finfo.

Definition at line 48 of file SharedFinfo.cpp.

50 {
51  return 0;
52 }
bool SharedFinfo::strSet ( const Eref tgt,
const string &  field,
const string &  arg 
) const
virtual

Function to set this field using a string argument. Returns true on success. Normally called only from SetGet::strSet.

Implements Finfo.

Definition at line 42 of file SharedFinfo.cpp.

44 {
45  return 0;
46 }

Member Data Documentation

vector< Finfo* > SharedFinfo::dest_
private

Definition at line 60 of file SharedFinfo.h.

Referenced by addMsg(), checkTarget(), dest(), innerDest(), registerFinfo(), and SharedFinfo().

vector< SrcFinfo* > SharedFinfo::src_
private

Definition at line 59 of file SharedFinfo.h.

Referenced by addMsg(), checkTarget(), innerSrc(), registerFinfo(), SharedFinfo(), and src().


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