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

#include <Id.h>

+ Collaboration diagram for Id:

Public Member Functions

void bindIdToElement (Element *e)
 
void destroy () const
 
Elementelement () const
 Synonym for Id::operator()() More...
 
Eref eref () const
 
 Id ()
 
 Id (unsigned int id)
 
 Id (const std::string &path, const std::string &separator="/")
 
 Id (const ObjId &oi)
 
bool operator!= (const Id &other) const
 
bool operator< (const Id &other) const
 
bool operator== (const Id &other) const
 
std::string path (const std::string &separator="/") const
 
unsigned int value () const
 
void zeroOut () const
 
 ~Id ()
 

Static Public Member Functions

static void clearAllElements ()
 
static std::string id2str (Id id)
 
static bool isValid (Id id)
 
static bool isValid (unsigned int id)
 
static Id nextId ()
 
static unsigned int numIds ()
 
static Id str2Id (const std::string &s)
 

Static Private Member Functions

static vector< Element * > & elements ()
 

Private Attributes

unsigned int id_
 

Friends

ostream & operator<< (ostream &s, const Id &i)
 
istream & operator>> (istream &s, Id &i)
 

Detailed Description

This class manages id lookups for elements. Ids provide a uniform handle for every object, independent of which node they are located on.

Definition at line 17 of file Id.h.

Constructor & Destructor Documentation

Id::Id ( )

Returns the root Id

Definition at line 18 of file Id.cpp.

Referenced by Id(), and str2Id().

20  : id_( 0 )
21 {
22  ;
23 }
unsigned int id_
Definition: Id.h:172

+ Here is the caller graph for this function:

Id::Id ( unsigned int  id)

Creates an id with the specified Element number

Definition at line 25 of file Id.cpp.

26  : id_( id )
27 {
28  ;
29 }
unsigned int id_
Definition: Id.h:172
Id::Id ( const std::string &  path,
const std::string &  separator = "/" 
)

Returns an id found by traversing the specified path

Definition at line 31 of file Id.cpp.

References Shell::doFind(), Id(), ObjId::id, and id_.

32 {
33  Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
34  assert( shell );
35  id_ = shell->doFind( path ).id.id_;
36 }
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
Id id
Definition: ObjId.h:98
ObjId doFind(const string &path) const
Definition: Shell.cpp:549
Id()
Definition: Id.cpp:18
unsigned int id_
Definition: Id.h:172
Definition: Shell.h:43

+ Here is the call graph for this function:

Id::Id ( const ObjId oi)

Downconverts an OjbId to an Id

Definition at line 38 of file Id.cpp.

39  : id_( oi.id.id_ )
40 {
41  ;
42 }
Id id
Definition: ObjId.h:98
unsigned int id_
Definition: Id.h:172
Id::~Id ( )
inline

Destroys an Id. Doesn't do anything much.

Definition at line 46 of file Id.h.

46 {}

Member Function Documentation

void Id::bindIdToElement ( Element e)

The specified element is placed into current id.

Definition at line 148 of file Id.cpp.

References elements(), and id_.

149 {
150  if ( elements().size() <= id_ )
151  {
152  if ( elements().size() % 1000 == 0 )
153  {
154  elements().reserve( elements().size() + 1000 );
155  }
156  elements().resize( id_ + 1, 0 );
157  }
158  assert( elements()[ id_ ] == 0 );
159  /*
160  if ( elements()[ id_ ] != 0 )
161  cout << "Warning: assigning Element to existing id " << id_ << "\n";
162  */
163  elements()[ id_ ] = e;
164  // cout << "Id::bindIdToElement '" << e->getName() << "' = " << id_ << endl;
165 }
static vector< Element * > & elements()
Definition: Id.cpp:59
unsigned int id_
Definition: Id.h:172

+ Here is the call graph for this function:

void Id::clearAllElements ( )
static

Used to clean up all Elements when the simulation is terminated

Definition at line 202 of file Id.cpp.

References elements().

Referenced by finalize(), and main().

203 {
204  for ( vector< Element* >::iterator
205  i = elements().begin(); i != elements().end(); ++i )
206  {
207  if ( *i )
208  {
209  (*i)->clearAllMsgs();
210  delete *i;
211  }
212  }
213 }
static vector< Element * > & elements()
Definition: Id.cpp:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Id::destroy ( ) const

Cleanly deletes the associated Element, and zeroes out contents of elements vector at the location pointed to by this->id_.

Definition at line 176 of file Id.cpp.

References elements(), and id_.

Referenced by Element::destroyElementTree(), Cell::setupf(), testArith(), testFibonacci(), testLookupSetGet(), testMpiFibonacci(), testMsgSrcDestFields(), testSetGetExtField(), testSharedMsg(), and testShellParserStart().

177 {
178  if ( elements()[ id_ ] )
179  {
180  // cout << "Id::destroy '" << elements()[ id_ ]->getName() << "' = " << id_ << endl;
181  delete elements()[ id_ ];
182  elements()[ id_ ] = 0;
183  // Put id_ on 'available' list
184  }
185  else
186  {
187  cout << "Warning: Id::destroy: " << id_ << " already zeroed\n";
188  }
189 }
static vector< Element * > & elements()
Definition: Id.cpp:59
unsigned int id_
Definition: Id.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Element * Id::element ( ) const

Synonym for Id::operator()()

Returns the Element pointed to by the id If it is off-node, returns an allocated wrapper element with postmaster and id information. Calling func has to free it. This wrapper element may also point to UNKNOWN NODE, in which case the master node IdManager has to figure out where it belongs. Returns 0 on failure. Deprecated. Element* operator()() const; Returns the Element pointed to by the Id. Perhaps cleaner to use than operator()() as it is an explicit function.

Here we work with a single big array of all ids. Off-node elements are represented by their postmasters. When we hit a postmaster we put the id into a special field on it. Note that this is horrendously thread-unsafe.

Definition at line 113 of file Id.cpp.

Referenced by ReadCell::addCaConc(), ReadCell::addCanonicalChannel(), ReadCell::addChannel(), addClockMsg(), ReadCell::addSpikeGen(), Streamer::addTable(), Shell::adopt(), assignParam(), ReadCell::buildChannels(), ReadCell::buildCompartment(), buildFromProto(), Dsolve::buildMeshJunctions(), Dsolve::buildNeuroMeshJunctions(), ReadKkit::buildSumTotal(), Dsolve::calcJunction(), checkChildren(), checkForSpine(), SetGet::checkSet(), OneToAllMsg::copy(), OneToOneDataIndexMsg::copy(), OneToOneMsg::copy(), SingleMsg::copy(), DiagonalMsg::copy(), SparseMsg::copy(), FieldElement::data(), HSolve::deepSearchForCompartment(), HSolve::deleteIncomingMessages(), Shell::doAddMsg(), doClassSpecificMessaging(), Shell::doLoadModel(), Shell::doMove(), Element::dropAllMsgsFromSrc(), fillSegIndex(), fillSegments(), VoxelPoolsBase::filterCrossRateTerms(), NeuroNode::filterSpines(), NeuroMesh::filterSpines(), findAllConnectedCompartments(), findFuncMsgSrc(), findMeshOfEnz(), findModelParent(), DiagonalMsg::findOtherEnd(), findParentComptOfReac(), FieldElement::getNode(), FieldElement::getNumOnNode(), Stoich::getProxyPools(), LookupField< L, A >::getVec(), Shell::innerAddMsg(), innerCopyElements(), Shell::innerMove(), Stoich::installAndUnschedFunc(), Stoich::installAndUnschedFuncRate(), Stoich::installAndUnschedFuncReac(), isDoingReinit(), FieldElement::isGlobal(), isOffSolverReac(), Shell::isRunning(), ReadKkit::loadTab(), FieldElement::localDataStart(), main(), Dsolve::mapXfersBetweenDsolves(), FieldElement::numData(), FieldElement::numField(), FieldElement::numLocalData(), FieldElementFinfoBase::postCreationFunc(), FieldElement::rawIndex(), ReadCell::read(), Streamer::reinit(), FieldElement::resizeField(), SrcFinfo1< T >::sendTo(), SrcFinfo2< T1, T2 >::sendTo(), Gsolve::setCompartment(), ZombiePoolInterface::setCompartment(), Stoich::setCompartment(), Ksolve::setDsolve(), Gsolve::setDsolve(), Stoich::setDsolve(), Stoich::setKsolve(), HSolve::setSeed(), ZombieFunction::setSolver(), ZombieReac::setSolver(), ZombieMMenz::setSolver(), ZombieEnz::setSolver(), Neuron::setSpineAndPsdMesh(), Gsolve::setStoich(), SteadyState::setStoich(), Ksolve::setStoich(), Dsolve::setStoich(), ReadKkit::setupSlaveMsg(), showFields(), FieldElement::startDataIndex(), test2ArgSetVec(), testAssortedMsg(), testCellDiffn(), testCopy(), testCopyFieldElement(), testCreateMsg(), testCylDiffnWithStoich(), testFilterOffNodeTargets(), testGet(), testMsgField(), testMsgSrcDestFields(), testSendMsg(), testSendSpike(), testSetGet(), testSetGetDouble(), testSetGetVec(), testSharedMsg(), testSmallCellDiffn(), testStrGet(), testStrSet(), testTaperingCylDiffn(), testTreeTraversal(), testTwoReacGetNeighbors(), ZombiePool::vSetSolver(), ZombieCaConc::vSetSolver(), ZombieHHChannel::vSetSolver(), ZombieCompartment::vSetSolver(), Stoich::zombifyModel(), and Stoich::zombifyPoolFuncWithScaling().

114 {
115  return elements()[ id_ ];
116 }
static vector< Element * > & elements()
Definition: Id.cpp:59
unsigned int id_
Definition: Id.h:172
vector< Element * > & Id::elements ( )
staticprivate

Definition at line 59 of file Id.cpp.

Referenced by bindIdToElement(), clearAllElements(), destroy(), eref(), isValid(), nextId(), numIds(), and zeroOut().

60 {
61  static vector< Element* > e;
62  return e;
63 }

+ Here is the caller graph for this function:

Eref Id::eref ( ) const

Returns the Eref to the element plus index

Definition at line 125 of file Id.cpp.

References elements(), and id_.

Referenced by ReadCell::addChannelMessage(), addClockMsg(), addSpine(), Streamer::addTable(), ReadKkit::assignPoolCompartments(), benchmarkMsg(), ReadSwc::build(), Dsolve::build(), Neuron::buildElist(), ReadKkit::buildEnz(), buildFromProto(), Dsolve::calcJunction(), checkChildren(), Cell::children(), HSolve::children(), SteadyState::classifyState(), Shell::cleanSimulation(), OneToOneDataIndexMsg::copy(), OneToOneMsg::copy(), doClassSpecificMessaging(), ReadCspace::expandEnzyme(), ReadCspace::expandReaction(), Neuron::getExprElist(), Neuron::getExprVal(), getShell(), handle_keyboard_interrupts(), init(), MarkovSolverBase::init(), innerCopyElements(), Neutral::isDescendant(), isDoingReinit(), Shell::isRunning(), Shell::launchParser(), makeCompt(), ReadCspace::makeMolecule(), ReadCspace::makePlots(), makeReacTest(), makeStandardElements(), Dsolve::mapChansBetweenDsolves(), Dsolve::mapDiffPoolsBetweenDsolves(), mapVoxelsBetweenMeshes(), Dsolve::mapXfersBetweenDsolves(), path(), FieldElementFinfoBase::postCreationFunc(), HSolveUtils::rates(), Table::reinit(), Streamer::reinit(), Clock::reportClock(), Ksolve::setDsolve(), Gsolve::setDsolve(), Stoich::setDsolve(), Stoich::setElist(), MarkovRateTable::setInt2dChildTable(), Stoich::setKsolve(), ZombieReac::setSolver(), ZombieMMenz::setSolver(), ZombieEnz::setSolver(), Neuron::setSpineAndPsdMesh(), Gsolve::setStoich(), SteadyState::setStoich(), Ksolve::setStoich(), Dsolve::setStoich(), Cell::setupSolver(), MarkovRateTable::setVtChildTable(), Element::showFields(), storeFunctionMsgs(), testAssortedMsg(), testBuildStoich(), testCalcJunction(), testCellDiffn(), testChildren(), testClock(), testClockMessaging(), testCopy(), testCopyFieldElement(), testCopyMsgOps(), testCreateMsg(), testCylDiffn(), testCylDiffnWithStoich(), testDescendant(), testFibonacci(), testFilterOffNodeTargets(), testFindModelParent(), testGetMsg(), testGetMsgs(), testInterNodeOps(), testMMenz(), testMMenzProcess(), testMove(), testMpiFibonacci(), testMsgElementListing(), testMsgField(), testMsgSrcDestFields(), testObjIdToAndFromPath(), testPoolVolumeScaling(), testReacVolumeScaling(), testReadKkit(), ReadCspace::testReadModel(), testReMesh(), testRunGsolve(), testRunKsolve(), testSendMsg(), testSendSpike(), testSetupReac(), testSharedMsg(), testShellAddMsg(), testShellParserCreateDelete(), testShellParserQuit(), testShellParserStart(), testShellSetGet(), testSmallCellDiffn(), testStats(), testSyncSynapseSize(), testTable(), testTaperingCylDiffn(), testTreeTraversal(), testTwoReacGetNeighbors(), testVolScaling(), testWildcard(), verifyKids(), ZombieCaConc::vSetSolver(), ZombieHHChannel::vSetSolver(), and ZombieCompartment::vSetSolver().

126 {
127  return Eref( elements()[ id_ ], 0 );
128  // return Eref( elements()[ id_ ], index_ );
129 }
static vector< Element * > & elements()
Definition: Id.cpp:59
Definition: Eref.h:26
unsigned int id_
Definition: Id.h:172

+ Here is the call graph for this function:

string Id::id2str ( Id  id)
static

Returns a string holding the ascii value of the id_ .

Definition at line 70 of file Id.cpp.

71 {
72  return id.path();
73 }
static bool Id::isValid ( Id  id)
inlinestatic

Definition at line 145 of file Id.h.

References elements(), and id_.

Referenced by moose_connect(), moose_copy(), moose_ElementField_getPath(), moose_ElementField_setattro(), moose_Field_hash(), moose_Field_init(), moose_Field_repr(), moose_getField(), moose_Id_delete(), moose_Id_getattro(), moose_Id_getItem(), moose_Id_getLength(), moose_Id_getPath(), moose_Id_getShape(), moose_Id_getSlice(), moose_Id_repr(), moose_Id_setattro(), moose_Id_setField(), moose_Id_str(), moose_move(), moose_ObjId_connect(), moose_ObjId_get_destField_attr(), moose_ObjId_get_elementField_attr(), moose_ObjId_get_lookupField_attr(), moose_ObjId_getDataIndex(), moose_ObjId_getField(), moose_ObjId_getFieldIndex(), moose_ObjId_getFieldNames(), moose_ObjId_getFieldType(), moose_ObjId_getId(), moose_ObjId_getLookupField(), moose_ObjId_getNeighbors(), moose_ObjId_hash(), moose_ObjId_init_from_id(), moose_ObjId_repr(), moose_ObjId_richcompare(), moose_ObjId_setattro(), moose_ObjId_setDestField(), moose_ObjId_setLookupField(), and moose_ObjId_str().

146  {
147  return (id.id_ < elements().size()) && (elements()[id.id_] != 0);
148  }
static vector< Element * > & elements()
Definition: Id.cpp:59
unsigned int id_
Definition: Id.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool Id::isValid ( unsigned int  id)
inlinestatic

Definition at line 150 of file Id.h.

References elements(), and id.

151  {
152  return (id < elements().size()) && (elements()[id] != 0);
153  }
static vector< Element * > & elements()
Definition: Id.cpp:59
static char id[]
Definition: mfield.cpp:404

+ Here is the call graph for this function:

Id Id::nextId ( )
static

Reserves an id for assigning to an Element. Each time it is called a new id is reserved, even if previous ones have not been used yet.

Definition at line 132 of file Id.cpp.

References elements().

Referenced by buildFinfoElement(), Shell::doCopy(), Shell::doCreate(), init(), Msg::initMsgManagers(), innerCopyElements(), Cinfo::makeCinfoElements(), FieldElementFinfoBase::postCreationFunc(), Cell::setupSolver(), showFields(), test2ArgSetVec(), testArith(), testClock(), testCreateMsg(), testFibonacci(), testGet(), testLookupSetGet(), testMsgField(), testMsgSrcDestFields(), testSendMsg(), testSendSpike(), testSetGet(), testSetGetDouble(), testSetGetExtField(), testSetGetSynapse(), testSetGetVec(), testSetRepeat(), testSharedMsg(), testSparseMsg(), testStrGet(), and testStrSet().

133 {
134  // Should really look up 'available' list.
135  // Should really put the returned value onto the 'reserved' list
136  // so they don't go dangling.
137  Id ret( elements().size() );
138  elements().push_back( 0 );
139  return ret;
140 }
static vector< Element * > & elements()
Definition: Id.cpp:59
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Id::numIds ( )
static

Returns the number of Ids in use.

Definition at line 143 of file Id.cpp.

References elements().

144 {
145  return elements().size();
146 }
static vector< Element * > & elements()
Definition: Id.cpp:59

+ Here is the call graph for this function:

bool Id::operator!= ( const Id other) const
inline

Definition at line 130 of file Id.h.

References id_.

131  {
132  // return id_ != other.id_ || index_ != other.index_;
133  return id_ != other.id_;
134  }
unsigned int id_
Definition: Id.h:172
bool Id::operator< ( const Id other) const
inline

Definition at line 136 of file Id.h.

References id_.

137  {
138  // return ( id_ < other.id_ ) ||
139  // ( id_ == other.id_ && index_ < other.index_ );
140  return ( id_ < other.id_ );
141  }
unsigned int id_
Definition: Id.h:172
bool Id::operator== ( const Id other) const
inline

Definition at line 124 of file Id.h.

References id_.

125  {
126  // return id_ == other.id_ && index_ == other.index_;
127  return id_ == other.id_;
128  }
unsigned int id_
Definition: Id.h:172
string Id::path ( const std::string &  separator = "/") const

Returns the full pathname of the object on the id.

Definition at line 76 of file Id.cpp.

References eref(), and Neutral::path().

Referenced by Streamer::addTable(), ReadCell::buildCompartment(), Dsolve::buildMeshJunctions(), Dsolve::buildNeuroMeshJunctions(), Neuron::buildSegmentTree(), SetGet::checkSet(), HHChannel2D::createGate(), HHChannel2D::destroyGate(), HHChannel::destroyGate(), diagnoseTree(), Shell::doCopy(), findModelParent(), HSolveUtils::gates(), Neutral::getMsgDestFunctions(), Neutral::getMsgDests(), Neutral::getNeighbors(), LookupField< L, A >::getVec(), HHChannel2D::innerCreateGate(), HHChannel::innerCreateGate(), HHChannel2D::innerDestroyGate(), HHChannel::innerDestroyGate(), installDummy(), isOffSolverReac(), ReadCspace::makePlots(), makeStandardElements(), Ksolve::print(), printJunction(), ReadKkit::read(), ReadCell::ReadCell(), ReadCspace::readModelString(), ReadCell::readScript(), Table::reinit(), Streamer::reinit(), Streamer::removeTable(), HHGate::setAlpha(), HHGate::setBeta(), Ksolve::setDsolve(), Gsolve::setDsolve(), Stoich::setFunctionExpr(), setMethod(), HHGate::setMinfinity(), Neutral::setName(), HSolve::setSeed(), ZombieFunction::setSolver(), ZombieEnz::setSolver(), Neuron::setSpineAndPsdMesh(), HHGate::setTableA(), HHGate::setTau(), Cell::setupf(), ReadCell::startGraftCell(), storePlotMsgs(), ReadCspace::testReadModel(), testTreeTraversal(), Conv< Id >::val2str(), HHChannel::vCreateGate(), ZombieCaConc::vSetSolver(), ZombieHHChannel::vSetSolver(), ZombieCompartment::vSetSolver(), writeGroup(), and writeKkit().

77 {
78  string ret = Neutral::path( eref() );
79  // Trim off trailing []
80  assert( ret.length() > 0 );
81  // the 'back' operation is not supported by pre 2011 compilers
82 
83  while ( ret[ ret.length() - 1 ] == ']' )
84  {
85  size_t pos = ret.find_last_of( '[' );
86  if ( pos != string::npos && pos > 0 )
87  {
88  ret = ret.substr( 0, pos );
89  }
90  }
91 
92  return ret;
93 }
Eref eref() const
Definition: Id.cpp:125
static string path(const Eref &e)
Definition: Neutral.cpp:725

+ Here is the call graph for this function:

Id Id::str2Id ( const std::string &  s)
static

Returns an id whose value is string-converted from the specified string.

Static func to extract an id from a string. We need to accept ids out of the existing range, but it would be nice to have a heuristic on how outrageous the incoming value is.

Definition at line 49 of file Id.cpp.

References Id().

50 {
51  // unsigned int val = atoi( s.c_str() );
52  return Id( s );
53 }
Id()
Definition: Id.cpp:18

+ Here is the call graph for this function:

void Id::zeroOut ( ) const

Used to clean out any specific Id.

Definition at line 191 of file Id.cpp.

References elements(), and id_.

Referenced by Element::~Element().

192 {
193  assert ( id_ < elements().size() );
194  elements()[ id_ ] = 0;
195 }
static vector< Element * > & elements()
Definition: Id.cpp:59
unsigned int id_
Definition: Id.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

ostream& operator<< ( ostream &  s,
const Id i 
)
friend
istream& operator>> ( istream &  s,
Id i 
)
friend

Member Data Documentation


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