📄 command.cpp
字号:
//------------------------------------------------void CommandPrint (int on){ printOn = on; CommandGetPrint ();}//------------------------------------------------void CommandGetPrint (){ outstr << "Printing of results is " << (printOn ? "ON" : "OFF" ) << endl;}//------------------------------------------------void CommandProperties (bool opt){ if (!CheckForOpenTable()) return; obs.Properties(*outFile, opt);}//------------------------------------------------void CommandInfoNodes (){ if (!CheckForOpenTable()) return; obs.OutNodeInfo();}//------------------------------------------------void CommandInfoSet (RTinfoType type, int status){ switch(type) { case it_flows : obs.SetFlowInfo(status); break; case it_insert : obs.SetInsertInfo(status); break; case it_search : obs.SetSearchInfo(status); break; case it_split : obs.SetSplitInfo(status); break; default : assert(0); } CommandInfoGet(type);}//------------------------------------------------void CommandInfoOut (RTinfoType type){ switch(type) { case it_flows : obs.OutFlowInfo(); break; case it_search : case it_insert : case it_split : cout << "This info, if set on, is automatically written to output file." << endl; break; default : assert(0); }}//------------------------------------------------void CommandInfoGet (RTinfoType type){ bool on = true; switch(type) { case it_flows : on = obs.GetFlowInfo(); break; case it_insert : on = obs.GetInsertInfo(); break; case it_search : on = obs.GetSearchInfo(); break; case it_split : on = obs.GetSplitInfo(); break; default : assert(0); } cout << "Flow info is " << (on ? "ON" : "OFF") << endl;}//------------------------------------------------void CommandStatistics (int on){ statisticsOn = on; if (on) { stInserts = stInsertsOld = 0; stDeletes = stDeletesOld = 0; stDelFails = 0; stSelects = stSelectsOld = 0; stSelectsR = stSelectsROld = 0; stInsertIOs = stInsertIOsOld = 0; stDeleteIOs = stDeleteIOsOld = 0; stSelectIOs = stSelectIOsOld = 0; } outstr << "Accumulation of I/O statistics is " << (on ? "ON" : "OFF" ) << endl;}//------------------------------------------------void CommandGetStatistics (){ outstr << "Accumulation of I/O statistics is " << (statisticsOn ? "ON" : "OFF" ) << endl;}//------------------------------------------------void CommandOutStatistics (){ *outFile << "I/O statistics (# of operations, operation type, average # of I/Os):" << endl; if (stInserts + stDeletes) *outFile << (stInserts + stDeletes) << " (-" << stDelFails << ") Updates " << (double) (stInsertIOs + stDeleteIOs) / (stInserts + stDeletes) << endl; //if (stInserts) *outFile << stInserts << " Inserts " // << (double) stInsertIOs / stInserts << endl; // if (stDeletes) *outFile << stDeletes << " Deletes " // << (double) stDeleteIOs / stDeletes << endl; if (stSelects) *outFile << stSelects << " Selects " << (double) stSelectIOs / stSelects << ", found: " << stSelectsR << endl;}//------------------------------------------------void CommandOutRunningStats (){ int st_updates = stInserts - stInsertsOld + stDeletes - stDeletesOld; int st_updateIOs = stInsertIOs - stInsertIOsOld + stDeleteIOs - stDeleteIOsOld; int st_selects = stSelects - stSelectsOld; int st_selectIOs = stSelectIOs - stSelectIOsOld; *outFile << "CT = " << setprecision(3) << CT << ": "; if (st_updates) *outFile << st_updates << " Updates " << (double) st_updateIOs / st_updates << endl; if (st_selects) *outFile << st_selects << " Selects " << (double) st_selectIOs / st_selects << ", found: " << stSelectsR - stSelectsROld << endl; stInsertsOld = stInserts; stDeletesOld = stDeletes; stSelectsOld = stSelects; stSelectsROld = stSelectsR; stInsertIOsOld = stInsertIOs; stDeleteIOsOld = stDeleteIOs; stSelectIOsOld = stSelectIOs;}//------------------------------------------------void CommandSplitAlgorithm(RTsettings::SplitAlgorithm alg){ Settings.SetSplitAlg (alg); CommandGetAlgorithm ();}//------------------------------------------------void CommandChooseSubtreeAlgorithm(RTsettings::ChoosesubtreeAlgorithm alg){ Settings.SetChoosesubtreeAlg (alg); CommandGetAlgorithm ();}//------------------------------------------------void CommandAlgorithm(RTsettings::LoadAlgorithm alg){ Settings.SetLoadAlg (alg); CommandGetAlgorithm ();}//------------------------------------------------void CommandUnionMode(RTsettings::UnionMode alg){ Settings.SetUnionMode (alg); CommandGetAlgorithm ();}//------------------------------------------------void CommandGetAlgorithm(){ outstr << "Current Split Algorithm is: "; switch(Settings.GetSplitAlg()) { case RTsettings::saOld : outstr << "Old R*" << endl; break; case RTsettings::saNoOverlap : outstr << "Old R* without overlap" << endl; break; default : outstr << "Hm... you shouldn't get this" << endl; } outstr << "Current ChooseSubtree Algorithm is: "; switch(Settings.GetChoosesubtreeAlg()) { case RTsettings::cstArea : outstr << "Area enlargment" << endl; break; case RTsettings::cstOverlap : outstr << "Overlap enlargment in leaves" << endl; break; default : outstr << "Hm... you shouldn't get this" << endl; } outstr << "Current BR recomputing mode is: "; switch(Settings.GetUnionMode()) { case RTsettings::unInsCT : outstr << "At insertion or deletionm, minimum at the current time" << endl; break; case RTsettings::unInsRefT : outstr << "At insertion or deletionm, minimum at the reference time" << endl; break; default : outstr << "Hm... you shouldn't get this" << endl; } outstr << "Current Bulk Loading Algorithm is: "; switch(Settings.GetLoadAlg()) { case RTsettings::aRatio : outstr << "Ratio" << endl; break; case RTsettings::aNormal : outstr << "Normal (only current spatial coordinates)" << endl; break; case RTsettings::aDual : outstr << "Dual" << endl; break; case RTsettings::aDualSpeed : outstr << "Dual speed" << endl; break; case RTsettings::aVelocity : outstr << "Only velocity" << endl; break; case RTsettings::aCSD : outstr << "CSD" << endl; break; case RTsettings::aCDS : outstr << "CDS" << endl; break; case RTsettings::aDSC : outstr << "DSC" << endl; break; case RTsettings::aSDC : outstr << "SDC" << endl; break; case RTsettings::aNormalHilbert : outstr << "Normal Hilbert" << endl; break; case RTsettings::aDualHilbert : outstr << "Dual Hilbert" << endl; break; default : outstr << "Hm... you shouldn't get this" << endl; }}//------------------------------------------------void CommandHorizon(double U, double W){ if (U <= 0.0 || W < 0.0) { outstr << "Horizon should be greater than zero" << endl; return; } cmHorizon = U + W; cmW = W; cmAutoHorizon = false; switch (Settings.GetDims()) { case 1: cmAlpha = 2.0 / cmHorizon; break; case 2: cmAlpha = ::sqrt(3) / cmHorizon; // cmAlpha = sqrt(6.0 / (2*U*U + 3*U*W + 2*W*W)); // Correctly supports U, W break; default: // 3 cmAlpha = 1.568283739 / cmHorizon; } if (Settings.GetTreeType() != RTsettings::tOpttree && ot_name) { ((RT*) ot_gist)->SetAutoHorizon(false); ((RT*) ot_gist)->SetHorizon(cmHorizon, cmW); ((RT*) ot_gist)->SetAlpha(cmAlpha); }}//------------------------------------------------void CommandAutoHorizon(double Wfactor){ cmAutoHorizon = true; cmWFactor = Wfactor; if (Settings.GetTreeType() != RTsettings::tOpttree && ot_name) { ((RT*) ot_gist)->SetAutoHorizon(true); ((RT*) ot_gist)->SetWFactor(cmWFactor); } }//------------------------------------------------void CommandGetHorizon (){ if (cmAutoHorizon) outstr << "Horizon is auto-adaptive (W factor = " << cmWFactor << ")" << endl; else outstr << "Horizon is: " << cmHorizon << endl;}//------------------------------------------------void CommandAlpha(double alpha){ if (alpha <= 0.0) outstr << "Alpha ratio should be grater than zero" << endl; else { cmAlpha = alpha; if (Settings.GetTreeType() != RTsettings::tOpttree && ot_name) ((RT*) ot_gist)->SetAlpha(cmAlpha); }}//------------------------------------------------void CommandGetAlpha (){ outstr << "Alpha ratio is: " << cmAlpha << endl;}//------------------------------------------------void CommandVisualize (RTvisobject what, int level, RTperiod interval){ if (!CheckForOpenTable()) return; obs.Visualize (what, level, interval);}//------------------------------------------------void CommandImport(const char *fname){ FILE *fl = fopen (fname, "rt"); if (!fl) { outstr << "Unable to open the import file \"" << fname << "\". Skipping it" << endl; return; } imports[numImports++] = fl;}//------------------------------------------------void CommandOutFile(const char *fname){ if (outFile != &cout) delete outFile; outFile = new ofstream(fname); if (outFile->bad()) { cout << "Unable to open the output file \"" << fname << '\"' << endl; outFile = &cout; return; } }//------------------------------------------------void CommandOutput(const char *str){ *outFile << str << endl;}//------------------------------------------------void CommandQuit(){ if (ot_name) CommandClose (); if (outFile != &cout) delete outFile; outstr << "Goodbye." << endl; PROFILE_ACTION_END(profile_total); PROFILE_OUTPUT; Quit();}//------------------------------------------------void CommandPrompt(){ if (!printOn) return; if (!ot_name) outstr << "Tree> "; else outstr << "TPRTree> "; outstr.flush();}//------------------------------------------------void CommandDebug(int on){ debug = on;// outstr << "Debugging: ";// outstr << (debug ? "ON\n" : "OFF\n");}//------------------------------------------------void CommandGetDebug(){ outstr << "Debugging: "; outstr << (debug ? "ON\n" : "OFF\n");}//------------------------------------------------void CommandHelp(){ FILE* f; char c; if ((f = fopen("command.help", "rt")) != NULL) { while ((c = fgetc(f)) != EOF) outstr << c; fclose (f); } else outstr << "The testbed should be run from the same directory where comman.help is located!" << endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -