本文整理汇总了C++中Program::add_operation方法的典型用法代码示例。如果您正苦于以下问题:C++ Program::add_operation方法的具体用法?C++ Program::add_operation怎么用?C++ Program::add_operation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program::add_operation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseMetaData
bool Simulator::parseMetaData()
{
string lineBuffer;
string filePath = configurationData.filePath;
int hardwareCycleTime;
bool doneParsing = false;
Program program;
const string BEGIN_SIMULATOR_STRING = "S(start)0";
const string END_SIMULATOR_STRING = "S(end)0.";
const string BEGIN_PROGRAM_STRING = "A(start)0";
const string END_PROGRAM_STRING = "A(end)0";
// Open the file for reading
ifstream inFile( filePath.c_str() );
if( inFile.fail() )
{
cerr << "Error! Failed to open Meta-Data file." << endl;
return false;
}
// Check first line
getline( inFile, lineBuffer );
if( lineBuffer != "Start Program Meta-Data Code:" )
{
cerr << "Error! Invalid Meta-Data file." << endl;
if( inFile.is_open() )
{
inFile.close();
}
return false;
}
// Get each token delimited by semicolons
while( !doneParsing )
{
// Ignore whitespace
inFile >> std::ws;
// Get the next operation
getline( inFile, lineBuffer, ';' );
// Check if at the end
doneParsing = lineBuffer.find( END_SIMULATOR_STRING ) != string::npos;
if( lineBuffer == BEGIN_PROGRAM_STRING )
{
program.clear_operations();
hardwareCycleTime = 0;
program.add_operation( lineBuffer, 0 );
}
else if( lineBuffer == END_PROGRAM_STRING )
{
program.add_operation( lineBuffer, 0 );
programs_.push_back( program );
programs_.back().prepare();
}
else if( ( lineBuffer != BEGIN_SIMULATOR_STRING ) && !doneParsing )
{
if( lineBuffer.find( "printer" ) != string::npos )
{
hardwareCycleTime = configurationData.printerCycleTime;
}
else if( lineBuffer.find( "monitor" ) != string::npos )
{
hardwareCycleTime = configurationData.monitorDisplayTime;
}
else if( lineBuffer.find( "keyboard" ) != string::npos )
{
hardwareCycleTime = configurationData.keyboardCycleTime;
}
else if( lineBuffer.find( "run" ) != string::npos )
{
hardwareCycleTime = configurationData.processorCycleTime;
}
else if( lineBuffer.find( "hard drive" ) != string::npos )
{
hardwareCycleTime = configurationData.hardDriveCycleTime;
}
else
{
cerr << "Error! Invalid Meta-Data file. "
<< "Could not set operation hardware cycle!" << endl;
if(inFile.is_open())
{
inFile.close();
}
return false;
}
program.add_operation( lineBuffer, hardwareCycleTime );
}
}
// Close the file
if(inFile.is_open())
{
inFile.close();
//.........这里部分代码省略.........