本文整理汇总了C++中Eref类的典型用法代码示例。如果您正苦于以下问题:C++ Eref类的具体用法?C++ Eref怎么用?C++ Eref使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Eref类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: child
// static function
Id Neutral::child( const Eref& e, const string& name )
{
static const Finfo* pf = neutralCinfo->findFinfo( "parentMsg" );
static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf );
static const FuncId pafid = pf2->getFid();
static const Finfo* cf = neutralCinfo->findFinfo( "childOut" );
static const SrcFinfo* cf2 = dynamic_cast< const SrcFinfo* >( cf );
static const BindIndex bi = cf2->getBindIndex();
const vector< MsgFuncBinding >* bvec = e.element()->getMsgAndFunc( bi );
vector< Id > ret;
for ( vector< MsgFuncBinding >::const_iterator i = bvec->begin();
i != bvec->end(); ++i ) {
if ( i->fid == pafid ) {
const Msg* m = Msg::getMsg( i->mid );
assert( m );
Element* e2 = m->e2();
if ( e2->getName() == name ) {
if ( e.dataIndex() == ALLDATA ) {// Child of any index is OK
return e2->id();
} else {
ObjId parent = m->findOtherEnd( m->getE2() );
// If child is a fieldElement, then all parent indices
// are permitted. Otherwise insist parent dataIndex OK.
if ( e2->hasFields() || parent == e.objId() )
return e2->id();
}
}
}
}
return Id();
}
示例2: vRemesh
void Pool::vRemesh( const Eref& e, const Qinfo* q,
double oldvol,
unsigned int numTotalEntries, unsigned int startEntry,
const vector< unsigned int >& localIndices,
const vector< double >& vols )
{
if ( e.index().value() != 0 )
return;
/*
if ( q->addToStructuralQ() )
return;
*/
Neutral* n = reinterpret_cast< Neutral* >( e.data() );
assert( vols.size() > 0 );
double concInit = nInit_ / ( NA * oldvol );
if ( vols.size() != e.element()->dataHandler()->localEntries() )
n->setLastDimension( e, q, vols.size() );
// Note that at this point the Pool pointer may be invalid!
// But we need to update the concs anyway.
assert( e.element()->dataHandler()->localEntries() == vols.size() );
Pool* pooldata = reinterpret_cast< Pool* >( e.data() );
for ( unsigned int i = 0; i < vols.size(); ++i ) {
pooldata[i].nInit_ = pooldata[i].n_ = concInit * vols[i] * NA;
}
}
示例3:
OneToAllMsg::OneToAllMsg( MsgId mid, Eref e1, Element* e2 )
:
Msg( mid, e1.element(), e2, OneToAllMsg::managerId_ ),
i1_( e1.index() )
{
;
}
示例4: zombify
void HSolve::zombify( Eref hsolve ) const
{
vector< Id >::const_iterator i;
vector< ObjId > temp;
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
temp.push_back( ObjId( *i, 0 ) );
for ( i = compartmentId_.begin(); i != compartmentId_.end(); ++i )
CompartmentBase::zombify( i->eref().element(),
ZombieCompartment::initCinfo(), hsolve.id() );
temp.clear();
for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
temp.push_back( ObjId( *i, 0 ) );
// Shell::dropClockMsgs( temp, "process" );
for ( i = caConcId_.begin(); i != caConcId_.end(); ++i )
CaConcBase::zombify( i->eref().element(), ZombieCaConc::initCinfo(), hsolve.id() );
temp.clear();
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
temp.push_back( ObjId( *i, 0 ) );
for ( i = channelId_.begin(); i != channelId_.end(); ++i )
HHChannelBase::zombify( i->eref().element(),
ZombieHHChannel::initCinfo(), hsolve.id() );
}
示例5: getReactantVols
unsigned int getReactantVols( const Eref& reac, const SrcFinfo* pools,
vector< double >& vols )
{
static const unsigned int meshIndex = 0;
const vector< MsgFuncBinding >* mfb =
reac.element()->getMsgAndFunc( pools->getBindIndex() );
unsigned int smallIndex = 0;
vols.resize( 0 );
if ( mfb ) {
for ( unsigned int i = 0; i < mfb->size(); ++i ) {
double v = 1;
Element* pool = Msg::getMsg( (*mfb)[i].mid )->e2();
if ( pool == reac.element() )
pool = Msg::getMsg( (*mfb)[i].mid )->e1();
assert( pool != reac.element() );
Eref pooler( pool, meshIndex );
if ( pool->cinfo()->isA( "PoolBase" ) ) {
v = lookupVolumeFromMesh( pooler );
} else {
cout << "Error: getReactantVols: pool is of unknown type\n";
assert( 0 );
}
vols.push_back( v );
if ( v < vols[0] )
smallIndex = i;
}
}
return smallIndex;
}
示例6: initEnzymeCinfo
/* Enzymatic Reaction */
void SbmlReader::setupEnzymaticReaction( const EnzymeInfo & einfo,string name )
{
static const Cinfo* enzymeCinfo = initEnzymeCinfo();
static const Finfo* k1Finfo = enzymeCinfo->findFinfo( "k1" );
static const Finfo* k2Finfo = enzymeCinfo->findFinfo( "k2" );
static const Finfo* k3Finfo = enzymeCinfo->findFinfo( "k3" );
Eref E = ( einfo.enzyme )();
Element* enzyme_ = Neutral::create( "Enzyme",name,E.id(),Id::scratchId() );//create Enzyme
Eref complx = einfo.complex();
Eref(enzyme_).add( "enz",E,"reac",ConnTainer::Default );
Eref(enzyme_).add( "cplx",complx,"reac",ConnTainer::Default );
vector< Id >::const_iterator sub_itr;
for ( sub_itr = einfo.substrates.begin(); sub_itr != einfo.substrates.end(); sub_itr++ )
{ Eref S = (*sub_itr)();
Eref( enzyme_ ).add( "sub",S,"reac",ConnTainer::Default );
}
vector< Id >::const_iterator prd_itr;
for ( prd_itr = einfo.products.begin(); prd_itr != einfo.products.end(); prd_itr++ )
{ Eref P = (*prd_itr)();
Eref( enzyme_ ).add( "prd",P,"prd",ConnTainer::Default );
}
::set< double >( enzyme_, k1Finfo, einfo.k1 );
::set< double >( enzyme_, k2Finfo, einfo.k2 );
::set< double >( enzyme_, k3Finfo, einfo.k3 );
::set< bool >( enzyme_,"mode",0 );
::set( complx,"destroy" );
}
示例7: initKinComptCinfo
/* create COMPARTMENT */
map< string,Id > SbmlReader::createCompartment( Id location )
{
static const Cinfo* kincomptCinfo = initKinComptCinfo();
static const Finfo* sizeFinfo = kincomptCinfo->findFinfo( "size" );
static const Finfo* dimensionFinfo = kincomptCinfo->findFinfo( "numDimensions" );
map< string,Id > idMap;
//Id outcompt; //outside compartment
map< Id,string > outsideMap;
map< Id,string > ::iterator iter;
double msize = 0.0,size=0.0;
::Compartment* compt;
unsigned int num_compts = model_->getNumCompartments();
//cout << "num of compartments :" << num_compts <<endl;
for ( unsigned int i = 0; i < num_compts; i++ )
{
compt = model_->getCompartment(i);
std::string id = "";
if ( compt->isSetId() ){
id = compt->getId();
}
std::string name = "";
if ( compt->isSetName() ){
name = compt->getName();
}
std::string outside = "";
if ( compt->isSetOutside() ){
outside = compt->getOutside ();
}
if ( compt->isSetSize() ){
msize = compt->getSize();
}
UnitDefinition * ud = compt->getDerivedUnitDefinition();
size = transformUnits( msize,ud );
unsigned int dimension = compt->getSpatialDimensions();
comptEl_ = Neutral::create( "KinCompt",id, location, Id::scratchId() ); //create Compartment
idMap[id] = comptEl_->id();
if ( outside != "" )
outsideMap[comptEl_->id()] = outside ;
if ( size != 0.0 )
::set< double >( comptEl_, sizeFinfo, size );
if ( dimension != 0 )
::set< unsigned int >( comptEl_,dimensionFinfo,dimension );
}
for ( iter = outsideMap.begin(); iter != outsideMap.end(); iter++ )
{
Eref msid = iter->first();
string outside = iter->second;
Id outcompt = idMap.find( outside )->second;
static const Finfo* outsideFinfo = kincomptCinfo->findFinfo( "outside" );
static const Finfo* insideFinfo = kincomptCinfo->findFinfo( "inside" );
msid.dropAll("child"); //delete the connection with old parent ie, /kinetics
Eref(outcompt() ).add("childSrc",msid,"child",ConnTainer::Default); //create connection with new parent ie.outside compartment
Eref( msid ).add( outsideFinfo->msg(),outcompt(),insideFinfo->msg(),ConnTainer::Default );
}
return idMap;
}
示例8: getNinit
double GslStoich::getNinit( const Eref& e ) const
{
unsigned int i = e.index().value();
unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
assert( i < pools_.size() );
assert( j < pools_[i].size() );
return pools_[i].Sinit()[j];
}
示例9: Eref
Eref SingleMsg::firstTgt( const Eref& src ) const
{
if ( src.element() == e1_ )
return Eref( e2_, i2_, f2_ );
else if ( src.element() == e2_ )
return Eref( e1_, i1_ );
return Eref( 0, 0 );
}
示例10: setNinit
void GslStoich::setNinit( const Eref& e, double v )
{
unsigned int i = e.index().value();
unsigned int j = coreStoich()->convertIdToPoolIndex( e.id() );
assert( i < pools_.size() );
assert( j < pools_[i].size() );
pools_[i].varSinit()[j] = v;
}
示例11: lookupVolumeFromMesh
/// Utility function to find the size of a pool. We assume one-to-one
/// match between pool indices and mesh indices: that is what they are for.
double lookupVolumeFromMesh( const Eref& e )
{
ObjId compt = getCompt( e.id() );
if ( compt == ObjId() )
return 1.0;
return LookupField< unsigned int, double >::
get( compt, "oneVoxelVolume", e.dataIndex() );
}
示例12: Eref
Eref OneToAllMsg::firstTgt( const Eref& src ) const
{
if ( src.element() == e1_ )
return Eref( e2_, 0 );
else if ( src.element() == e2_ )
return Eref( e1_, i1_ );
return Eref( 0, 0 );
}
示例13: testParGet
/////////////////////////////////////////////////////////////////
// Now test 'get' across nodes.
// Normally the 'get' call is invoked by the parser, which expects a
// value to come back. Note that the return must be asynchronous:
// the parser cannot block since we need to execute MPI polling
// operations on either side.
/////////////////////////////////////////////////////////////////
void testParGet( Id tnId, vector< Id >& testIds )
{
unsigned int myNode = MuMPI::INTRA_COMM().Get_rank();
unsigned int numNodes = MuMPI::INTRA_COMM().Get_size();
Slot parGetSlot = initShellCinfo()->getSlot( "parallel.getSrc" );
char name[20];
string sname;
if ( myNode == 0 ) {
cout << "\ntesting parallel get" << flush;
} else {
sprintf( name, "foo%d", myNode * 2 );
sname = name;
set< string >( tnId.eref(), "name", sname );
}
MuMPI::INTRA_COMM().Barrier();
Eref e = Id::shellId().eref();
Shell* sh = static_cast< Shell* >( e.data() );
vector< unsigned int > rids( numNodes, 0 );
vector< string > ret( numNodes );
unsigned int origSize = sh->freeRidStack_.size();
ASSERT( origSize > 0 , "Stack initialized properly" );
if ( myNode == 0 ) {
for ( unsigned int i = 1; i < numNodes; i++ ) {
rids[i] =
openOffNodeValueRequest< string >( sh, &ret[i], 1 );
ASSERT( sh->freeRidStack_.size() == origSize - i, "stack in use" );
sendTo3< Id, string, unsigned int >(
Id::shellId().eref(), parGetSlot, i - 1,
testIds[i - 1], "name", rids[i]
);
}
}
// Here we explicitly do what the closeOffNodeValueRequest handles.
MuMPI::INTRA_COMM().Barrier();
// Cycle a few times to make sure all data gets back to node 0
for ( unsigned int i = 0; i < 5; i++ ) {
pollPostmaster();
MuMPI::INTRA_COMM().Barrier();
}
// Now go through to check all values have come back.
if ( myNode == 0 ) {
ASSERT( sh->freeRidStack_.size() == 1 + origSize - numNodes,
"Stack still waiting" );
for ( unsigned int i = 1; i < numNodes; i++ ) {
sprintf( name, "foo%d", i * 2 );
sname = name;
ASSERT( sh->offNodeData_[ rids[i] ].numPending == 0,
"Pending requests cleared" );
ASSERT( sh->offNodeData_[ rids[i] ].data ==
static_cast< void* >( &ret[i] ), "Pointing to strings" );
ASSERT( ret[ i ] == sname, "All values returned correctly" );
// Clean up the debris
sh->offNodeData_[ rids[i] ].data = 0;
sh->freeRidStack_.push_back( rids[i] );
}
}
}
示例14: Eref
/**
* This is a little tricky because we might be mapping between
* data entries and field entries here.
* May wish also to apply to exec operations.
* At this point, the effect of trying to go between regular
* data entries and field entries is undefined.
*/
Eref OneToOneDataIndexMsg::firstTgt( const Eref& src ) const
{
if ( src.element() == e1_ ) {
return Eref( e2_, src.dataIndex(), 0 );
} else if ( src.element() == e2_ ) {
return Eref( e1_, src.dataIndex() );
}
return Eref( 0, 0 );
}
示例15: addSpike
void Synapse::addSpike( const Eref& e, double time )
{
static bool report = false;
static unsigned int tgtDataIndex = 0;
// static unsigned int tgtFieldIndex = 0;
if ( report && e.dataIndex() == tgtDataIndex ) {
cout << " " << time << "," << e.fieldIndex();
}
handler_->addSpike( e.fieldIndex(), time + delay_, weight_ );
}