- Added the GET and SET commands to TextSimulation

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@752 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-07-11 15:46:46 +00:00
parent 8ffd81b823
commit d4beb67d0e
1 changed files with 69 additions and 5 deletions

View File

@ -286,7 +286,6 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
} }
void void
TextSimulation::on_help(const Tokens& arguments) TextSimulation::on_help(const Tokens& arguments)
{ {
@ -331,9 +330,11 @@ TextSimulation::on_help(const Tokens& arguments)
p_stdout(_("\n-- Do you really want me to explain what HELP means? --" p_stdout(_("\n-- Do you really want me to explain what HELP means? --"
"\n ************** YOU ARE JOKING ME !!! ************\n\n")); "\n ************** YOU ARE JOKING ME !!! ************\n\n"));
else if(command == "GET") else if(command == "GET")
p_stderr(_("\nFIXME: Not implemented")); p_stdout(_("\n -- GET COMMAND --\nSyntax: GET <attr_name>\n where <attr_name>"
"may be simulation_tick"));
else if(command == "SET") else if(command == "SET")
p_stderr(_("\nFIXME: Not implemented")); p_stdout(_("\n -- SET COMMAND --\nSyntax: SET <attr_name> [=] <value>\n"
"where <attr_name> may be simulation_tick"));
else if(command == "SHOW") else if(command == "SHOW")
p_stderr(_("\nFIXME: Not implemented")); p_stderr(_("\nFIXME: Not implemented"));
else if(command == "ADD") else if(command == "ADD")
@ -360,13 +361,76 @@ TextSimulation::on_quit(const Tokens& arguments)
void void
TextSimulation::on_get(const Tokens& arguments) TextSimulation::on_get(const Tokens& arguments)
{ {
p_stderr(_("\nFIXME: Not implemented\n")); //make a local copy which we'll probably modify
Tokens args = arguments;
ustring attr;
if(args.size() == 0)
{
p_stderr("\nERROR: you must provide an argument\n");
return;
}
else
{
attr = args[0].uppercase();
args.erase(args.begin());
}
arguments_ignored(args);
if(attr == "SIMULATION_TICK")
{
ostringstream oss;
oss << "\nsimulation_tick = " << get_timer() << "ms" << endl;
p_stdout(oss.str());
}
else
p_stderr("\nERROR: invalid attribute. Accepted are: simulation_tick\n");
} }
void void
TextSimulation::on_set(const Tokens& arguments) TextSimulation::on_set(const Tokens& arguments)
{ {
p_stderr(_("\nFIXME: Not implemented\n")); //make a local copy which we'll probably modify
Tokens args = arguments;
ustring attr;
ustring value;
if(args.size() < 2)
{
p_stderr("\nERROR: you must provide an attribute name and a value\n");
return;
}
else
{
attr = args[0].uppercase();
args.erase(args.begin());
if(args[0] == "=")
args.erase(args.begin());
value = args[0].uppercase();
args.erase(args.begin());
}
arguments_ignored(args);
if(attr == "SIMULATION_TICK")
{
try
{
set_timer(string_to<int>(value));
}
catch(domain_error e)
{
p_stderr("\nERROR: you must provide a valid integer value\n");
}
}
else
p_stderr("\nERROR: invalid attribute. Accepted are: simulation_tick\n");
} }
void void