MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MsgElement.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-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 #ifndef _MSG_ELEMENT_H
10 #define _MSG_ELEMENT_H
11 
12 class SrcFinfo;
13 class FuncOrder;
14 
20 class MsgElement: public Element
21 {
22  public:
31  MsgElement( Id id, const Cinfo* c, const string& name,
32  unsigned int( *numMsg )(),
33  char* ( *lookupMsg )( unsigned int ) )
34  :
35  Element( id, c, name ),
36  numMsg_( numMsg ),
37  lookupMsg_( lookupMsg )
38  {;}
39 
44  {;}
45 
51  Element* copyElement( Id newParent, Id newId, unsigned int n,
52  bool toGlobal ) const
53  {
54  return 0;
55  }
56 
58  // Information access fields
60 
62  unsigned int numData() const
63  {
64  return numMsg_();
65  }
66 
68  unsigned int numLocalData() const
69  {
70  return numMsg_();
71  }
72 
74  unsigned int localDataStart() const
75  {
76  return 0;
77  }
78 
80  unsigned int numField( unsigned int rawIndex ) const
81  {
82  return 1;
83  }
84 
85  unsigned int totNumLocalField() const
86  {
87  return numMsg_();
88  }
89 
91  unsigned int getNode( unsigned int dataIndex ) const
92  {
93  return Shell::myNode();
94  }
95 
97  unsigned int startDataIndex( unsigned int node ) const
98  {
99  return 0;
100  }
101 
103  unsigned int rawIndex( unsigned int dataIndex ) const
104  {
105  return dataIndex;
106  }
107 
113  bool hasFields() const {
114  return false;
115  }
116 
117  bool isGlobal() const {
118  return true;
119  }
120 
121  unsigned int getNumOnNode( unsigned int node ) const {
122  return numMsg_();
123  }
124 
126  // data access stuff
128 
145  char* data( unsigned int rawIndex,
146  unsigned int fieldIndex = 0 ) const
147  {
148  return lookupMsg_( rawIndex );
149  }
150 
156  void resize( unsigned int newNumData )
157  {;}
158 
164  void resizeField( unsigned int rawIndex, unsigned int newNumField )
165  {;}
166 
168 
172  void zombieSwap( const Cinfo* newCinfo ) {
173  replaceCinfo( newCinfo );
174  Element::zombieSwap( newCinfo );
175  }
176 
177 
178  private:
182  unsigned int( *numMsg_ )();
183 
187  char* ( *lookupMsg_ )( unsigned int );
188 };
189 
190 #endif // _Msg_ELEMENT_H
Element * copyElement(Id newParent, Id newId, unsigned int n, bool toGlobal) const
Definition: MsgElement.h:51
void zombieSwap(const Cinfo *newCinfo)
Definition: MsgElement.h:172
unsigned int numField(unsigned int rawIndex) const
Inherited virtual. Returns number of field entries for specified data.
Definition: MsgElement.h:80
unsigned int localDataStart() const
Inherited virtual. Returns index of first data entry on node.
Definition: MsgElement.h:74
void resize(unsigned int newNumData)
Definition: MsgElement.h:156
unsigned int startDataIndex(unsigned int node) const
Inherited virtual. As this is a global we always return zero.
Definition: MsgElement.h:97
unsigned int getNode(unsigned int dataIndex) const
Inherited virtual. Just returns current node.
Definition: MsgElement.h:91
bool isGlobal() const
True if there is a copy of every dataEntry on all nodes.
Definition: MsgElement.h:117
MsgElement(Id id, const Cinfo *c, const string &name, unsigned int(*numMsg)(), char *(*lookupMsg)(unsigned int))
Definition: MsgElement.h:31
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
unsigned int rawIndex(unsigned int dataIndex) const
Inherited virtual. Just returns index.
Definition: MsgElement.h:103
unsigned int totNumLocalField() const
Definition: MsgElement.h:85
unsigned int getNumOnNode(unsigned int node) const
Definition: MsgElement.h:121
static char dataIndex[]
Definition: mfield.cpp:406
void resizeField(unsigned int rawIndex, unsigned int newNumField)
Definition: MsgElement.h:164
static char name[]
Definition: mfield.cpp:401
unsigned int(* numMsg_)()
Definition: MsgElement.h:182
char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const
Definition: MsgElement.h:145
Definition: Id.h:17
static unsigned int myNode()
unsigned int numData() const
Inherited virtual. Returns number of data entries.
Definition: MsgElement.h:62
unsigned int numLocalData() const
Inherited virtual. Returns number of data entries.
Definition: MsgElement.h:68
char *(* lookupMsg_)(unsigned int)
Definition: MsgElement.h:187
bool hasFields() const
Definition: MsgElement.h:113
void replaceCinfo(const Cinfo *newCinfo)
Support function for zombieSwap, replaces Cinfo.
Definition: Element.cpp:740
Definition: Cinfo.h:18