本文整理汇总了C++中Shell类的典型用法代码示例。如果您正苦于以下问题:C++ Shell类的具体用法?C++ Shell怎么用?C++ Shell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char** argv )
{
bool doUnitTests = 0;
bool doRegressionTests = 0;
unsigned int benchmark = 0;
// This reorders the OpFunc to Fid mapping to ensure it is node and
// compiler independent.
Id shellId = init( argc, argv, doUnitTests, doRegressionTests, benchmark );
// Note that the main loop remains the parser loop, though it may
// spawn a lot of other stuff.
Element* shelle = shellId.element();
Shell* s = reinterpret_cast< Shell* >( shelle->data( 0 ) );
if ( doUnitTests )
nonMpiTests( s ); // These tests do not need the process loop.
if ( Shell::myNode() == 0 ) {
if ( Shell::numNodes() > 1 ) {
// Use the last clock for the postmaster, so that it is called
// after everything else has been processed and all messages
// are ready to send out.
s->doUseClock( "/postmaster", "process", 9 );
s->doSetClock( 9, 1.0 ); // Use a sensible default.
}
#ifdef DO_UNIT_TESTS
if ( doUnitTests ) {
mpiTests();
processTests( s );
}
// if ( doRegressionTests ) regressionTests();
#endif
// These are outside unit tests because they happen in optimized
// mode, using a command-line argument. As soon as they are done
// the system quits, in order to estimate timing.
if ( benchmark != 0 ) {
mooseBenchmarks( benchmark );
s->doQuit();
} else {
// Here we set off a little event loop to poll user input.
// It deals with the doQuit call too.
if(! quitFlag)
Shell::launchParser();
}
} else {
PostMaster* p = reinterpret_cast< PostMaster* >( ObjId( 3 ).data());
while ( Shell::keepLooping() ) {
p->clearPending();
}
}
Msg::clearAllMsgs();
Id::clearAllElements();
#ifdef USE_MPI
MPI_Finalize();
#endif
return 0;
}
示例2: Id
void SbmlReader::getRules() {
unsigned int nr = model_->getNumRules();
//if (nr > 0)
// cout << "\n ##### Need to populate funcpool and sumtotal which is pending due to equations \n";
Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
for ( unsigned int r = 0; r < nr; r++ ) {
Rule * rule = model_->getRule(r);
bool assignRule = rule->isAssignment();
if ( assignRule ) {
string rule_variable = rule->getVariable();
map< string,Id >::iterator v_iter;
map< string,Id >::iterator m_iter;
v_iter = molSidMIdMap_.find( rule_variable );
if (v_iter != molSidMIdMap_.end()) {
Id rVariable = molSidMIdMap_.find(rule_variable)->second;
string rstring =molSidMIdMap_.find(rule_variable)->first;
Id sumId = shell->doCreate( "SumFunc", rVariable, "func", 1 );
rVariable.element()->zombieSwap( FuncPool::initCinfo() );
ObjId ret = shell->doAddMsg( "single",
ObjId( sumId, 0 ), "output",
ObjId( rVariable, 0 ), "input" );
assert( ret != ObjId() );
const ASTNode * ast = rule->getMath();
vector< string > ruleMembers;
ruleMembers.clear();
printMembers( ast,ruleMembers );
for ( unsigned int rm = 0; rm < ruleMembers.size(); rm++ ) {
m_iter = molSidMIdMap_.find( ruleMembers[rm] );
if ( m_iter != molSidMIdMap_.end() ) {
Id rMember = molSidMIdMap_.find(ruleMembers[rm])->second;
ObjId ret = shell->doAddMsg( "single",
ObjId( rMember, 0 ), "nOut",
ObjId( sumId, 0 ), "input" );
string test = molSidMIdMap_.find(ruleMembers[rm])->first;
} else {
cerr << "SbmlReader::getRules: Assignment rule member is not a species" << endl;
// In assignment rule there are constants instead of molecule which is yet to deal in moose.
errorFlag_ = true;
}
}
}
}
bool rateRule = rule->isRate();
if ( rateRule ) {
cout << "warning : for now Rate Rule is not handled " << endl;
errorFlag_ = true;
}
bool algebRule = rule->isAlgebraic();
if ( algebRule ) {
cout << "warning: for now Algebraic Rule is not handled" << endl;
errorFlag_ = true;
}
}
}
示例3: setup
void setup(){
Serial.begin(9600);
shell.setPrompt("$\n");
shell.begin(Serial);
pinMode(3, OUTPUT);
digitalWrite(3, LOW);
ShellCommand(line, "draw a line", cmd_line);
ShellCommand(origin, "move pen to origin", cmd_origin);
}
示例4: main
int main()
{
TEvent init;
init.what = evCommand;
init.message.command = cmAbout; // make a cmAbout command event
Shell shell;
shell.putEvent(init); // put it in the queue to pop up
shell.run(); // About box when program starts
return 0;
}
示例5: main
int
main(int argc, char* argv[])
{
char *input;
char *str;
char *tokv[5];
int tokc;
char *expansion;
int result;
printf("Press Ctrl-D or enter \"exit\" to end session.\n"
"Enter \"help\" to display a command list.\n");
using_history();
try
{
Shell shell;
while (!shell.exitFlag())
{
input = readline("bossa> ");
if (!input)
{
printf("\n");
break;
}
for (str = input; *str && isspace(*str); str++);
if (*str)
{
result = history_expand(input, &expansion);
if (result >= 0 && result != 2)
{
add_history(expansion);
tokc = split(expansion, tokv, ARRAY_SIZE(tokv));
shell.invoke(tokv, tokc);
}
free(expansion);
}
free(input);
}
}
catch(...)
{
printf("\nUnhandled exception\n");
return 1;
}
return 0;
}
示例6: testRunKsolve
void testRunKsolve()
{
double simDt = 0.1;
// double plotDt = 0.1;
Shell* s = reinterpret_cast< Shell* >( Id().eref().data() );
Id kin = makeReacTest();
Id ksolve = s->doCreate( "Ksolve", kin, "ksolve", 1 );
Id stoich = s->doCreate( "Stoich", ksolve, "stoich", 1 );
Field< Id >::set( stoich, "compartment", kin );
Field< Id >::set( stoich, "ksolve", ksolve );
Field< string >::set( stoich, "path", "/kinetics/##" );
s->doUseClock( "/kinetics/ksolve", "process", 4 );
s->doSetClock( 4, simDt );
s->doReinit();
s->doStart( 20.0 );
Id plots( "/kinetics/plots" );
for ( unsigned int i = 0; i < 7; ++i ) {
stringstream ss;
ss << "plot." << i;
SetGet2< string, string >::set( ObjId( plots, i ), "xplot",
"tsr2.plot", ss.str() );
}
s->doDelete( kin );
cout << "." << flush;
}
示例7: Id
// Static func
void Shell::cleanSimulation()
{
Eref sheller = Id().eref();
Shell* s = reinterpret_cast< Shell* >( sheller.data() );
vector< Id > kids;
Neutral::children( sheller, kids );
for ( vector< Id >::iterator i = kids.begin(); i != kids.end(); ++i )
{
if ( i->value() > 4 ) {
cout << "Shell::cleanSimulation: deleted cruft at " <<
i->value() << ": " << i->path() << endl;
s->doDelete( *i );
}
}
}
示例8: testReadKkit
void testReadKkit()
{
ReadKkit rk;
// rk.read( "test.g", "dend", 0 );
Id base = rk.read( "foo.g", "dend", Id() );
assert( base != Id() );
// Id kinetics = s->doFind( "/kinetics" );
Shell* s = reinterpret_cast< Shell* >( Id().eref().data() );
rk.run();
rk.dumpPlots( "dend.plot" );
s->doDelete( base );
cout << "." << flush;
}
示例9: testTaperingCylDiffn
void testTaperingCylDiffn()
{
Shell* s = reinterpret_cast< Shell* >( Id().eref().data() );
double len = 25e-6;
double r0 = 2e-6;
double r1 = 1e-6;
double diffLength = 1e-6; // 1e-6 is the highest dx for which error is OK
double runtime = 10.0;
double dt = 0.1; // 0.2 is the highest dt for which the error is in bounds
double diffConst = 1.0e-12;
// Should set explicitly, currently during creation of DiffPoolVec
//double diffConst = 1.0e-12;
Id model = s->doCreate( "Neutral", Id(), "model", 1 );
Id cyl = s->doCreate( "CylMesh", model, "cyl", 1 );
Field< double >::set( cyl, "r0", r0 );
Field< double >::set( cyl, "r1", r1 );
Field< double >::set( cyl, "x0", 0 );
Field< double >::set( cyl, "x1", len );
Field< double >::set( cyl, "diffLength", diffLength );
unsigned int ndc = Field< unsigned int >::get( cyl, "numMesh" );
assert( ndc == static_cast< unsigned int >( round( len / diffLength )));
Id pool = s->doCreate( "Pool", cyl, "pool", 1 );
Field< double >::set( pool, "diffConst", diffConst );
Id dsolve = s->doCreate( "Dsolve", model, "dsolve", 1 );
Field< Id >::set( dsolve, "compartment", cyl );
s->doUseClock( "/model/dsolve", "process", 1 );
s->doSetClock( 1, dt );
// Next: build by setting the path of the dsolve.
Field< string >::set( dsolve, "path", "/model/cyl/pool" );
// Then find a way to test it.
assert( pool.element()->numData() == ndc );
Field< double >::set( ObjId( pool, 0 ), "nInit", 1.0 );
s->doReinit();
s->doStart( runtime );
double myTot = 0.0;
vector< double > poolVec;
Field< double >::getVec( pool, "n", poolVec );
for ( unsigned int i = 0; i < poolVec.size(); ++i ) {
myTot += poolVec[i];
}
assert( doubleEq( myTot, 1.0 ) );
s->doDelete( model );
cout << "." << flush;
}
示例10: testPoolVolumeScaling
void testPoolVolumeScaling()
{
Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
Id comptId = shell->doCreate( "CylMesh", Id(), "cyl", 1 );
Id meshId( comptId.value() + 1 );
Id poolId = shell->doCreate( "Pool", comptId, "pool", 1 );
ObjId mid = shell->doAddMsg( "OneToOne",
ObjId( poolId, 0 ), "requestVolume",
ObjId( meshId, 0 ), "get_volume" );
assert( mid != ObjId() );
vector< double > coords( 9, 0.0 );
double x1 = 100e-6;
double r0 = 10e-6;
double r1 = 5e-6;
double lambda = x1;
coords[3] = x1;
coords[6] = r0;
coords[7] = r1;
coords[8] = lambda;
Field< vector< double > >::set( comptId, "coords", coords );
double volume = Field< double >::get( poolId, "volume" );
assert( doubleEq( volume, PI * x1 * (r0+r1) * (r0+r1) / 4.0 ) );
Field< double >::set( poolId, "n", 400 );
double volscale = 1 / ( NA * volume );
double conc = Field< double >::get( poolId, "conc" );
assert( doubleEq( conc, 400 * volscale ) );
Field< double >::set( poolId, "conc", 500 * volscale );
double n = Field< double >::get( poolId, "n" );
assert( doubleEq( n, 500 ) );
Field< double >::set( poolId, "nInit", 650 );
double concInit = Field< double >::get( poolId, "concInit" );
assert( doubleEq( concInit, 650 * volscale ) );
Field< double >::set( poolId, "concInit", 10 * volscale );
n = Field< double >::get( poolId, "nInit" );
assert( doubleEq( n, 10 ) );
shell->doDelete( comptId );
cout << "." << flush;
}
示例11: launchParser
/**
* Launches Parser. Blocking when the parser blocks.
*/
void Shell::launchParser()
{
Id shellId;
Shell* s = reinterpret_cast< Shell* >( shellId.eref().data() );
bool quit = 0;
cout << "moose : " << flush;
while ( !quit ) {
string temp;
cin >> temp;
if ( temp == "quit" || temp == "q" ) {
s->doQuit();
quit = 1;
}
}
cout << "\nQuitting Moose\n" << flush;
}
示例12: testSpikeGen
void testSpikeGen()
{
Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
Id sid = shell->doCreate( "SpikeGen", Id(), "spike", 1, MooseGlobal );
SpikeGen& sg = *( reinterpret_cast< SpikeGen* >( sid.eref().data() ) );
Eref er( sid.eref() );
ProcInfo p;
p.dt = 0.001;
p.currTime = 0.0;
sg.setThreshold( 1.0 );
sg.setRefractT( 0.005 );
sg.reinit( er, &p );
sg.handleVm( 0.5 );
sg.process( er, &p );
assert( !sg.getFired() );
p.currTime += p.dt;
sg.handleVm( 0.999 );
sg.process( er, &p );
assert( !sg.getFired() );
p.currTime += p.dt;
sg.handleVm( 1.001 );
sg.process( er, &p );
assert( sg.getFired() );
p.currTime += p.dt;
sg.handleVm( 0.999 );
sg.process( er, &p );
assert( !sg.getFired() );
p.currTime += p.dt;
sg.handleVm( 2.0 ); // Too soon, refractory
sg.process( er, &p );
assert( !sg.getFired() );
p.currTime += 0.005; // Now post-refractory
sg.handleVm( 2.0 ); // Now not refractory
sg.process( er, &p );
assert( sg.getFired() );
sid.destroy();
cout << "." << flush;
}
示例13: makeStandardElements
//////////////////////////////////////////////////////////////////
// The read functions.
//////////////////////////////////////////////////////////////////
Id makeStandardElements( Id pa, const string& modelname )
{
Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() );
//cout << " kkit read " << pa << " " << modelname << " "<< MooseGlobal;
string modelPath = pa.path() + "/" + modelname;
if ( pa == Id() )
modelPath = "/" + modelname;
Id mgr( modelPath );
if ( mgr == Id() )
mgr = shell->doCreate( "Neutral", pa, modelname, 1, MooseGlobal );
Id kinetics( modelPath + "/kinetics" );
if ( kinetics == Id() ) {
kinetics =
shell->doCreate( "CubeMesh", mgr, "kinetics", 1, MooseGlobal );
SetGet2< double, unsigned int >::set( kinetics, "buildDefaultMesh", 1e-15, 1 );
}
assert( kinetics != Id() );
Id graphs = shell->doCreate( "Neutral", mgr, "graphs", 1, MooseGlobal);
assert( graphs != Id() );
Id moregraphs = shell->doCreate( "Neutral", mgr, "moregraphs", 1, MooseGlobal );
Id geometry = shell->doCreate( "Neutral", mgr, "geometry", 1, MooseGlobal );
assert( geometry != Id() );
Id groups =
shell->doCreate( "Neutral", mgr, "groups", 1, MooseGlobal );
assert( groups != Id() );
return mgr;
}
示例14: fin
/**
* The readcell function implements the old GENESIS cellreader
* functionality. Although it is really a parser operation, I
* put it here in Kinetics because the cell format is independent
* of parser and is likely to remain a legacy for a while.
*/
Id ReadKkit::read(
const string& filename,
const string& modelname,
Id pa, const string& methodArg )
{
string method = methodArg;
ifstream fin( filename.c_str() );
if (!fin){
cerr << "ReadKkit::read: could not open file " << filename << endl;
return Id();
}
if ( method.substr(0, 4) == "old_" ) {
moveOntoCompartment_ = false;
method = method.substr( 4 );
}
Shell* s = reinterpret_cast< Shell* >( ObjId().data() );
Id mgr = makeStandardElements( pa, modelname );
assert( mgr != Id() );
baseId_ = mgr;
basePath_ = mgr.path();
enzCplxMols_.resize( 0 );
innerRead( fin );
assignPoolCompartments();
assignReacCompartments();
assignEnzCompartments();
assignMMenzCompartments();
convertParametersToConcUnits();
s->doSetClock( 8, plotdt_ );
string plotpath = basePath_ + "/graphs/##[TYPE=Table]," +
basePath_ + "/moregraphs/##[TYPE=Table]";
s->doUseClock( plotpath, "process", 8 );
setMethod( s, mgr, simdt_, plotdt_, method );
s->doReinit();
return mgr;
}
示例15: sizeof
void Smoke::attach_shell(Shell &sh)
{
Game::attach_shell(sh);
const Shell::Context &ctx = sh.context();
physical_dev_ = ctx.physical_dev;
dev_ = ctx.dev;
queue_ = ctx.game_queue;
queue_family_ = ctx.game_queue_family;
format_ = ctx.format.format;
vk::GetPhysicalDeviceProperties(physical_dev_, &physical_dev_props_);
if (use_push_constants_ &&
sizeof(ShaderParamBlock) > physical_dev_props_.limits.maxPushConstantsSize) {
shell_->log(Shell::LOG_WARN, "cannot enable push constants");
use_push_constants_ = false;
}
VkPhysicalDeviceMemoryProperties mem_props;
vk::GetPhysicalDeviceMemoryProperties(physical_dev_, &mem_props);
mem_flags_.reserve(mem_props.memoryTypeCount);
for (uint32_t i = 0; i < mem_props.memoryTypeCount; i++)
mem_flags_.push_back(mem_props.memoryTypes[i].propertyFlags);
meshes_ = new Meshes(dev_, mem_flags_);
create_render_pass();
create_shader_modules();
create_descriptor_set_layout();
create_pipeline_layout();
create_pipeline();
create_frame_data(2);
render_pass_begin_info_.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_begin_info_.renderPass = render_pass_;
render_pass_begin_info_.clearValueCount = 1;
render_pass_begin_info_.pClearValues = &render_pass_clear_value_;
primary_cmd_begin_info_.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
primary_cmd_begin_info_.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
// we will render to the swapchain images
primary_cmd_submit_wait_stages_ = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
primary_cmd_submit_info_.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
primary_cmd_submit_info_.waitSemaphoreCount = 1;
primary_cmd_submit_info_.pWaitDstStageMask = &primary_cmd_submit_wait_stages_;
primary_cmd_submit_info_.commandBufferCount = 1;
primary_cmd_submit_info_.signalSemaphoreCount = 1;
if (multithread_) {
for (auto &worker : workers_)
worker->start();
}
}