- Give code a round of indentation. Thank astyle, not me.
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@837 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
aaf8e068d3
commit
d3c7b46853
|
@ -31,7 +31,7 @@ PythonCPUPolicyManager* _policy_manager = NULL;
|
|||
void
|
||||
sgpem__Plugin__on_init()
|
||||
{
|
||||
if(_policy_manager == NULL)
|
||||
if (_policy_manager == NULL)
|
||||
_policy_manager = new sgpem::PythonCPUPolicyManager();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
|
|||
PyObject* pUserCPUPolicyModule = PyImport_Import(pLoadmeStr);
|
||||
Py_DECREF(pLoadmeStr);
|
||||
|
||||
if(pUserCPUPolicyModule == NULL)
|
||||
if (pUserCPUPolicyModule == NULL)
|
||||
throw MalformedPolicyException(get_exception_information().c_str());
|
||||
|
||||
// Dictionary with defined ``symbols'' for .pyc file
|
||||
|
@ -69,7 +69,7 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
|
|||
|
||||
Py_DECREF(pScriptAdapterModule);
|
||||
|
||||
if(_adapter == NULL)
|
||||
if (_adapter == NULL)
|
||||
throw MalformedPolicyException(get_exception_information().c_str());
|
||||
|
||||
// And now, who's your daddy, huh?
|
||||
|
@ -78,12 +78,12 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
|
|||
|
||||
PythonCPUPolicy::~PythonCPUPolicy()
|
||||
{
|
||||
if(_adapter) Py_DECREF(_adapter);
|
||||
if (_adapter) Py_DECREF(_adapter);
|
||||
|
||||
// We keep this alive until dtor time, because
|
||||
// the user may have defined some static global-space
|
||||
// variables and they make use of them.
|
||||
if(_upolicy_dict) Py_DECREF(_upolicy_dict);
|
||||
if (_upolicy_dict) Py_DECREF(_upolicy_dict);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -122,7 +122,7 @@ PythonCPUPolicy::sort_queue() const throw(UserInterruptException)
|
|||
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL);
|
||||
|
||||
// Do minimal debugging
|
||||
if(!retval) PyErr_Print();
|
||||
if (!retval) PyErr_Print();
|
||||
else Py_DECREF(retval);
|
||||
|
||||
wait_unlock();
|
||||
|
@ -165,7 +165,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException)
|
|||
PyObject* retval = PyObject_CallMethod(_adapter, "async_get_time_slice", NULL);
|
||||
|
||||
// Do minimal debugging
|
||||
if(!retval) PyErr_Print();
|
||||
if (!retval) PyErr_Print();
|
||||
else Py_DECREF(retval);
|
||||
|
||||
wait_unlock();
|
||||
|
@ -199,7 +199,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException)
|
|||
still_locked = PyObject_IsTrue(retval);
|
||||
Py_DECREF(retval);
|
||||
|
||||
if(i++ > 12) /* waits for WAIT_FOR * 12 microseconds == 3 secs */
|
||||
if (i++ > 12) /* waits for WAIT_FOR * 12 microseconds == 3 secs */
|
||||
{
|
||||
PyThreadState_Clear(_save);
|
||||
// As the API documentation says, the caller of PyEval_RestoreThread
|
||||
|
@ -212,7 +212,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException)
|
|||
"taking too long to terminate."));
|
||||
}
|
||||
}
|
||||
while(still_locked);
|
||||
while (still_locked);
|
||||
|
||||
// What we should really do here:
|
||||
/* do {
|
||||
|
@ -234,7 +234,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException)
|
|||
string
|
||||
PythonCPUPolicy::get_exception_information()
|
||||
{
|
||||
if(PyErr_Occurred() == NULL)
|
||||
if (PyErr_Occurred() == NULL)
|
||||
return _("no error");
|
||||
|
||||
PyObject* pType = NULL;
|
||||
|
@ -245,7 +245,7 @@ PythonCPUPolicy::get_exception_information()
|
|||
|
||||
string msg;
|
||||
|
||||
if(pValue != NULL)
|
||||
if (pValue != NULL)
|
||||
{
|
||||
PyObject* pValueStr = PyObject_Str(pValue);
|
||||
|
||||
|
@ -256,9 +256,9 @@ PythonCPUPolicy::get_exception_information()
|
|||
else
|
||||
msg = string(_("no available information for this error"));
|
||||
|
||||
if(pType != NULL) Py_DECREF(pType);
|
||||
if(pValue != NULL) Py_DECREF(pValue);
|
||||
if(pTraceback != NULL) Py_DECREF(pTraceback);
|
||||
if (pType != NULL) Py_DECREF(pType);
|
||||
if (pValue != NULL) Py_DECREF(pValue);
|
||||
if (pTraceback != NULL) Py_DECREF(pTraceback);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ PythonCPUPolicyManager::~PythonCPUPolicyManager()
|
|||
void
|
||||
PythonCPUPolicyManager::init()
|
||||
{
|
||||
if(_initialized)
|
||||
if (_initialized)
|
||||
// No-op
|
||||
return;
|
||||
|
||||
|
@ -114,19 +114,19 @@ PythonCPUPolicyManager::collect_policies()
|
|||
GlobalPreferences::dir_iterator dir_it = prefs.policies_dir_begin();
|
||||
GlobalPreferences::dir_iterator dir_end = prefs.policies_dir_end();
|
||||
|
||||
for(; dir_it != dir_end; ++dir_it)
|
||||
for (; dir_it != dir_end; ++dir_it)
|
||||
{
|
||||
Glib::Dir dir(dir_it->c_str());
|
||||
|
||||
cout << "Opening directory " << *dir_it << " looking for python policies..." << endl;
|
||||
|
||||
for(Glib::DirIterator file_it = dir.begin(); file_it != dir.end(); ++file_it)
|
||||
for (Glib::DirIterator file_it = dir.begin(); file_it != dir.end(); ++file_it)
|
||||
{
|
||||
cout << "\tChecking if " << *file_it << " is a valid Python script... ";
|
||||
|
||||
Glib::PatternSpec dot_py("*.py");
|
||||
|
||||
if(dot_py.match(*file_it))
|
||||
if (dot_py.match(*file_it))
|
||||
{
|
||||
cout << "yes" << endl;
|
||||
|
||||
|
@ -139,7 +139,7 @@ PythonCPUPolicyManager::collect_policies()
|
|||
|
||||
_policies.push_back(pypolicy);
|
||||
}
|
||||
catch(MalformedPolicyException e)
|
||||
catch (MalformedPolicyException e)
|
||||
{
|
||||
std::cerr << "POLICY LOAD ERROR: " << e.what() << endl;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ static CPUPolicy*
|
|||
find_pol_by_name(const vector<CPUPolicy*>& pols, const Glib::ustring& name)
|
||||
{
|
||||
vector<CPUPolicy*>::const_iterator it = pols.begin();
|
||||
for( ; it != pols.end(); it++)
|
||||
if((*it)->get_name() == name)
|
||||
for ( ; it != pols.end(); it++)
|
||||
if ((*it)->get_name() == name)
|
||||
return *it;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ main(int argc, char** argv)
|
|||
{
|
||||
int successes = 0;
|
||||
|
||||
if(argc != 2)
|
||||
if (argc != 2)
|
||||
{
|
||||
std::cout << "[EE] Usage:\n\t" << argv[0] <<
|
||||
" path/to/uninstalled/test/policies" << std::endl;
|
||||
|
@ -81,7 +81,7 @@ main(int argc, char** argv)
|
|||
// Print out avail policies
|
||||
cout << "These are the policies I found:" << endl;
|
||||
vector<CPUPolicy*>::const_iterator it = policies.begin();
|
||||
for(; it != policies.end(); it++)
|
||||
for (; it != policies.end(); it++)
|
||||
cout << "\t * " << (*it)->get_name() << endl;
|
||||
|
||||
try
|
||||
|
@ -94,7 +94,7 @@ main(int argc, char** argv)
|
|||
pgk.activate_policy(&his, pol);
|
||||
pol->configure();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
cout << "configure: Caught UserInterruptException" << endl;
|
||||
successes++;
|
||||
|
@ -108,7 +108,7 @@ main(int argc, char** argv)
|
|||
pgk.activate_policy(&his, pol);
|
||||
pol->is_pre_emptive();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
cout << "is_preemptive: Caught UserInterruptException" << endl;
|
||||
successes++;
|
||||
|
@ -122,7 +122,7 @@ main(int argc, char** argv)
|
|||
pgk.activate_policy(&his, pol);
|
||||
pol->get_time_slice();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
cout << "get_time_slice: Caught UserInterruptException" << endl;
|
||||
successes++;
|
||||
|
@ -137,7 +137,7 @@ main(int argc, char** argv)
|
|||
pgk.activate_policy(&his, pol);
|
||||
pol->sort_queue();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
cout << "sort_queue: Caught UserInterruptException" << endl;
|
||||
successes++;
|
||||
|
|
|
@ -30,7 +30,7 @@ sgpem::XMLSerializer* _serializer = NULL;
|
|||
void
|
||||
sgpem__Plugin__on_init()
|
||||
{
|
||||
if(_serializer == NULL)
|
||||
if (_serializer == NULL)
|
||||
_serializer = new sgpem::XMLSerializer();
|
||||
}
|
||||
|
||||
|
|
|
@ -96,32 +96,32 @@ main(int argc, char** argv)
|
|||
os2 << ends; // null terminated string
|
||||
cout << "dump hist(t2) in print format into os2" << endl;
|
||||
|
||||
cout << "Comparing dump of hist(t1) and hist(t2): " << (os1.str()==os2.str()?"equals":"not equals") << endl;
|
||||
cout << "Comparing dump of hist(t1) and hist(t2): " << (os1.str() == os2.str() ? "equals" : "not equals") << endl;
|
||||
|
||||
ConcreteHistory hist2;
|
||||
xmlser.restore_snapshot(outfile, hist2);
|
||||
cout << "create ConcreteHistory hist" << endl;
|
||||
cout << "read XML data from file " << outfile << " and put into hist2(t3)"<< endl;
|
||||
cout << "read XML data from file " << outfile << " and put into hist2(t3)" << endl;
|
||||
|
||||
dumpEnvironment(hist2.get_last_environment(), os3);
|
||||
os3 << ends; // null terminated string
|
||||
cout << "dump hist2(t3) in print format into os3" << endl;
|
||||
|
||||
cout << "Comparing dump of hist(t1) and hist2(t3): " << (os1.str()==os3.str()?"equals":"not equals") << endl;
|
||||
cout << "Comparing dump of hist(t1) and hist2(t3): " << (os1.str() == os3.str() ? "equals" : "not equals") << endl;
|
||||
|
||||
xmlser.restore_snapshot(outfile, hist);
|
||||
cout << "read XML data from file " << outfile << " and put into hist(t4)"<< endl;
|
||||
cout << "read XML data from file " << outfile << " and put into hist(t4)" << endl;
|
||||
|
||||
dumpEnvironment(hist.get_last_environment(), os4);
|
||||
os4 << ends; // null terminated string
|
||||
cout << "dump hist(t3) in print format into os4" << endl;
|
||||
|
||||
cout << "Comparing dump of hist(t1) and hist(t4): " << (os1.str()==os4.str()?"equals":"not equals") << endl;
|
||||
cout << "Comparing dump of hist(t1) and hist(t4): " << (os1.str() == os4.str() ? "equals" : "not equals") << endl;
|
||||
|
||||
int ret = 1;
|
||||
if(os1.str()!=os2.str()
|
||||
&& os1.str()==os3.str()
|
||||
&& os1.str()==os4.str())
|
||||
if (os1.str() != os2.str()
|
||||
&& os1.str() == os3.str()
|
||||
&& os1.str() == os4.str())
|
||||
{
|
||||
cout << "test successful" << endl;
|
||||
ret = 0;
|
||||
|
@ -201,13 +201,13 @@ void addSomethingHistory(History &hist)
|
|||
// print entire environment into the passed ostream
|
||||
void dumpEnvironment(const Environment& env, ostream &os)
|
||||
{
|
||||
os << "dump environment start " <<endl;
|
||||
os << "dump environment start " << endl;
|
||||
|
||||
const Environment::Resources& rvect = env.get_resources();
|
||||
typedef Environment::Resources::const_iterator res_iterator;
|
||||
|
||||
res_iterator riter = rvect.begin();
|
||||
while(riter!=rvect.end())
|
||||
while (riter != rvect.end())
|
||||
{
|
||||
Resource* r = (*riter).second;
|
||||
os << " resource name: " << r->get_name()
|
||||
|
@ -221,7 +221,7 @@ void dumpEnvironment(const Environment& env, ostream &os)
|
|||
|
||||
proc_iterator iter = pvect.begin();
|
||||
proc_iterator end = pvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
Process* p = (*iter);
|
||||
os << " process name: " << p->get_name()
|
||||
|
@ -234,7 +234,7 @@ void dumpEnvironment(const Environment& env, ostream &os)
|
|||
const Threads& tvect = p->get_threads();
|
||||
thr_iterator iter1 = tvect.begin();
|
||||
thr_iterator end1 = tvect.end();
|
||||
while(iter1!=end1)
|
||||
while (iter1 != end1)
|
||||
{
|
||||
|
||||
Thread* t = (*iter1);
|
||||
|
@ -247,7 +247,7 @@ void dumpEnvironment(const Environment& env, ostream &os)
|
|||
const Requests& rvect = t->get_requests();
|
||||
req_iterator iter2 = rvect.begin();
|
||||
req_iterator end2 = rvect.end();
|
||||
while(iter2!=end2)
|
||||
while (iter2 != end2)
|
||||
{
|
||||
|
||||
Request* r = (*iter2);
|
||||
|
@ -258,14 +258,15 @@ void dumpEnvironment(const Environment& env, ostream &os)
|
|||
const SubRequests& srvect = r->get_subrequests();
|
||||
subreq_iterator iter3 = srvect.begin();
|
||||
subreq_iterator end3 = srvect.end();
|
||||
while(iter3!=end3)
|
||||
while (iter3 != end3)
|
||||
{
|
||||
|
||||
SubRequest* sr = (*iter3);
|
||||
os << " sub request: " /* << " resource_key: " << sr->get_resource_key() */;
|
||||
|
||||
Environment::Resources::const_iterator pos = env.get_resources().find(sr->get_resource_key());
|
||||
if (pos != env.get_resources().end()) {
|
||||
if (pos != env.get_resources().end())
|
||||
{
|
||||
os << " name: " << pos->second->get_name();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,12 +31,10 @@
|
|||
using namespace sgpem;
|
||||
|
||||
XMLSerializer::~XMLSerializer()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
XMLSerializer::XMLSerializer()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
@ -48,10 +46,11 @@ void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History&
|
|||
|
||||
xmlDocPtr doc;
|
||||
doc = xmlNewDoc((const xmlChar *)"1.0");
|
||||
if(doc!=NULL){
|
||||
if (doc != NULL)
|
||||
{
|
||||
fill_doc(doc, hist);
|
||||
int nwritten = xmlSaveFormatFile (filename.c_str(), doc, 1);
|
||||
if(nwritten<0)
|
||||
if (nwritten < 0)
|
||||
{
|
||||
throw SerializerError("Error writing xml doc to output stream.");
|
||||
}
|
||||
|
@ -80,7 +79,8 @@ void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& his
|
|||
* build an XML tree from a the file;
|
||||
*/
|
||||
doc = xmlParseFile(filename.c_str());
|
||||
if (doc == NULL) {
|
||||
if (doc == NULL)
|
||||
{
|
||||
xmlCleanupParser();
|
||||
throw SerializerError("Parsing Error: doc is invalid.");
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& his
|
|||
/*
|
||||
* the library has been compiled without some of the old interfaces
|
||||
*/
|
||||
#error Compilation of LIBXML with SAX1 support must be enabled
|
||||
#error Compilation of LIBXML with SAX1 support must be enabled
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ void XMLSerializer::clear_history(History& hist)
|
|||
typedef std::vector<Process*>::const_iterator proc_iterator;
|
||||
|
||||
proc_iterator iter = pvect.begin();
|
||||
while(iter!=pvect.end())
|
||||
while (iter != pvect.end())
|
||||
{
|
||||
hist.remove(*(*iter));
|
||||
iter = pvect.begin();
|
||||
|
@ -214,7 +214,7 @@ void XMLSerializer::clear_history(History& hist)
|
|||
typedef Environment::Resources::const_iterator res_iterator;
|
||||
|
||||
res_iterator riter = rvect.begin();
|
||||
while(riter!=rvect.end())
|
||||
while (riter != rvect.end())
|
||||
{
|
||||
hist.remove((*riter).first);
|
||||
riter = rvect.begin();
|
||||
|
@ -229,7 +229,8 @@ void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(Se
|
|||
*/
|
||||
xmlNodePtr root;
|
||||
root = xmlDocGetRootElement(doc);
|
||||
if (root == NULL) {
|
||||
if (root == NULL)
|
||||
{
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
throw SerializerError("Reading Error: xml doc is empty.");
|
||||
|
@ -237,14 +238,14 @@ void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(Se
|
|||
|
||||
xmlNodePtr cur;
|
||||
cur = root->children;
|
||||
while(cur!=NULL)
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring name((const char *)cur->name);
|
||||
if(name=="resources")
|
||||
if (name == "resources")
|
||||
{
|
||||
read_resources(cur, fact);
|
||||
}
|
||||
if(name=="schedulables")
|
||||
if (name == "schedulables")
|
||||
{
|
||||
read_schedulables(cur, fact);
|
||||
}
|
||||
|
@ -254,15 +255,17 @@ void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(Se
|
|||
|
||||
XMLSerializerFactory::Parameters* read_properties(xmlAttrPtr prop)
|
||||
{
|
||||
if(prop==NULL)
|
||||
if (prop == NULL)
|
||||
return NULL;
|
||||
|
||||
XMLSerializerFactory::Parameters* par=new XMLSerializerFactory::Parameters();
|
||||
while (prop != NULL) {
|
||||
if(prop->children && xmlNodeIsText(prop->children)){
|
||||
XMLSerializerFactory::Parameters* par = new XMLSerializerFactory::Parameters();
|
||||
while (prop != NULL)
|
||||
{
|
||||
if (prop->children && xmlNodeIsText(prop->children))
|
||||
{
|
||||
xmlChar *key = xmlNodeGetContent (prop->children);
|
||||
// xmlChar *key = xmlNodeListGetString(doc, prop->children, 1);
|
||||
if(key!=NULL)
|
||||
if (key != NULL)
|
||||
{
|
||||
std::pair<Glib::ustring, Glib::ustring> key_value(Glib::ustring((const char *)prop->name), Glib::ustring((const char *)key));
|
||||
par->insert(key_value);
|
||||
|
@ -278,14 +281,14 @@ void XMLSerializer::read_resources(xmlNodePtr resources_node, XMLSerializerFacto
|
|||
{
|
||||
xmlNodePtr cur;
|
||||
cur = resources_node->children;
|
||||
while(cur!=NULL)
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="resource")
|
||||
if (node_name == "resource")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Resource"), *par);
|
||||
}
|
||||
|
@ -297,19 +300,19 @@ void XMLSerializer::read_resources(xmlNodePtr resources_node, XMLSerializerFacto
|
|||
}
|
||||
void XMLSerializer::read_schedulables(xmlNodePtr schedulables_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(schedulables_node==NULL)
|
||||
if (schedulables_node == NULL)
|
||||
return;
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = schedulables_node->children;
|
||||
while(cur!=NULL)
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="process")
|
||||
if (node_name == "process")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Process"), *par);
|
||||
}
|
||||
|
@ -323,19 +326,19 @@ void XMLSerializer::read_schedulables(xmlNodePtr schedulables_node, XMLSerialize
|
|||
|
||||
void XMLSerializer::read_threads(xmlNodePtr threads_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(threads_node==NULL)
|
||||
if (threads_node == NULL)
|
||||
return;
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = threads_node->children;
|
||||
while(cur!=NULL)
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="thread")
|
||||
if (node_name == "thread")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Thread"), *par);
|
||||
}
|
||||
|
@ -349,21 +352,21 @@ void XMLSerializer::read_threads(xmlNodePtr threads_node, XMLSerializerFactory&
|
|||
|
||||
void XMLSerializer::read_requests(xmlNodePtr requests_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(requests_node==NULL)
|
||||
if (requests_node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = requests_node->children;
|
||||
while(cur!=NULL)
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="request")
|
||||
if (node_name == "request")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Request"), *par);
|
||||
}
|
||||
|
@ -377,21 +380,21 @@ void XMLSerializer::read_requests(xmlNodePtr requests_node, XMLSerializerFactory
|
|||
|
||||
void XMLSerializer::read_subrequests(xmlNodePtr subrequest_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(subrequest_node==NULL)
|
||||
if (subrequest_node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = subrequest_node;
|
||||
while(cur!=NULL)
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="subrequest")
|
||||
if (node_name == "subrequest")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("SubRequest"), *par);
|
||||
}
|
||||
|
|
|
@ -36,12 +36,10 @@ using namespace std;
|
|||
|
||||
XMLSerializerFactory::XMLSerializerFactory(History& hist)
|
||||
: _hist(&hist)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
XMLSerializerFactory::~XMLSerializerFactory()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
History* XMLSerializerFactory::get_history()
|
||||
{
|
||||
|
@ -51,23 +49,23 @@ History* XMLSerializerFactory::get_history()
|
|||
void
|
||||
XMLSerializerFactory::factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializerError)
|
||||
{
|
||||
if(class_name == "Resource")
|
||||
if (class_name == "Resource")
|
||||
{
|
||||
create_resource(parameters);
|
||||
}
|
||||
else if(class_name == "Process")
|
||||
else if (class_name == "Process")
|
||||
{
|
||||
create_process(parameters);
|
||||
}
|
||||
else if(class_name == "Thread")
|
||||
else if (class_name == "Thread")
|
||||
{
|
||||
create_thread(parameters);
|
||||
}
|
||||
else if(class_name == "Request")
|
||||
else if (class_name == "Request")
|
||||
{
|
||||
create_request(parameters);
|
||||
}
|
||||
else if(class_name == "SubRequest")
|
||||
else if (class_name == "SubRequest")
|
||||
{
|
||||
create_subrequest(parameters);
|
||||
}
|
||||
|
@ -85,23 +83,25 @@ XMLSerializerFactory::create_resource(Parameters& parameters)
|
|||
|
||||
Glib::ustring name;
|
||||
Glib::ustring key("0");
|
||||
int arrival_time=0;
|
||||
int how_many=1;
|
||||
bool preemptable=false;
|
||||
int arrival_time = 0;
|
||||
int how_many = 1;
|
||||
bool preemptable = false;
|
||||
int old_key;
|
||||
Parameters::iterator pos;
|
||||
|
||||
// read "name" property
|
||||
pos = parameters.find(Glib::ustring("name"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
name = pos->second;
|
||||
}
|
||||
|
||||
// read "key" property
|
||||
pos = parameters.find(Glib::ustring("id"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
Glib::ustring id = key = pos->second;
|
||||
if(id.length()>6 && id.substr(0,6)==Glib::ustring("reskey"))
|
||||
if (id.length() > 6 && id.substr(0, 6) == Glib::ustring("reskey"))
|
||||
{
|
||||
key = id.substr(6);
|
||||
string_to_int(key, old_key);
|
||||
|
@ -110,19 +110,22 @@ XMLSerializerFactory::create_resource(Parameters& parameters)
|
|||
|
||||
// read "preemptable" property
|
||||
pos = parameters.find(Glib::ustring("preemptable"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
preemptable = (pos->second == "true");
|
||||
}
|
||||
|
||||
// read "arrival-time" property
|
||||
pos = parameters.find(Glib::ustring("arrival-time"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
}
|
||||
|
||||
// read "how-many" property
|
||||
pos = parameters.find(Glib::ustring("how-many"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, how_many);
|
||||
}
|
||||
|
||||
|
@ -142,25 +145,28 @@ XMLSerializerFactory::create_process(Parameters& parameters)
|
|||
{
|
||||
|
||||
Glib::ustring name;
|
||||
int arrival_time=0;
|
||||
int priority=1;
|
||||
int arrival_time = 0;
|
||||
int priority = 1;
|
||||
Parameters::iterator pos;
|
||||
|
||||
// read "name" property
|
||||
pos = parameters.find(Glib::ustring("name"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
name = pos->second;
|
||||
}
|
||||
|
||||
// read "arrival-time" property
|
||||
pos = parameters.find(Glib::ustring("arrival-time"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
}
|
||||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("priority"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, priority);
|
||||
}
|
||||
|
||||
|
@ -178,32 +184,36 @@ XMLSerializerFactory::create_thread(Parameters& parameters)
|
|||
{
|
||||
|
||||
Glib::ustring name;
|
||||
int arrival_time=0;
|
||||
int lasts_for=0;
|
||||
int priority=1;
|
||||
int arrival_time = 0;
|
||||
int lasts_for = 0;
|
||||
int priority = 1;
|
||||
Parameters::iterator pos;
|
||||
|
||||
// read "name" property
|
||||
pos = parameters.find(Glib::ustring("name"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
name = pos->second;
|
||||
}
|
||||
|
||||
// read "arrival-time" property
|
||||
pos = parameters.find(Glib::ustring("arrival-delta"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
}
|
||||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("priority"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, priority);
|
||||
}
|
||||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("lasts-for"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, lasts_for);
|
||||
}
|
||||
|
||||
|
@ -218,12 +228,13 @@ XMLSerializerFactory::create_request(Parameters& parameters)
|
|||
// if(_hist!=NULL)
|
||||
{
|
||||
|
||||
int arrival_time=0;
|
||||
int arrival_time = 0;
|
||||
Parameters::iterator pos;
|
||||
|
||||
// read "arrival-time" property
|
||||
pos = parameters.find(Glib::ustring("arrival-time"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, arrival_time);
|
||||
}
|
||||
|
||||
|
@ -238,8 +249,8 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
|
|||
// if(_hist!=NULL)
|
||||
{
|
||||
|
||||
int old_key=0;
|
||||
int lasts_for=0;
|
||||
int old_key = 0;
|
||||
int lasts_for = 0;
|
||||
//int places=1;
|
||||
Parameters::iterator pos;
|
||||
resource_key_t new_key = 0;
|
||||
|
@ -247,12 +258,14 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
|
|||
|
||||
// read "arrival-time" property
|
||||
pos = parameters.find(Glib::ustring("resource"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, old_key);
|
||||
|
||||
TempMap::iterator temp_pos;
|
||||
temp_pos = _temp_map.find((resource_key_t)old_key);
|
||||
if (temp_pos != _temp_map.end()) {
|
||||
if (temp_pos != _temp_map.end())
|
||||
{
|
||||
//take key of resource in _hist
|
||||
new_key = temp_pos->second;
|
||||
}
|
||||
|
@ -266,7 +279,8 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
|
|||
|
||||
// read "priority" property
|
||||
pos = parameters.find(Glib::ustring("lasts-for"));
|
||||
if (pos != parameters.end()) {
|
||||
if (pos != parameters.end())
|
||||
{
|
||||
string_to_int(pos->second, lasts_for);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,10 @@ using namespace sgpem;
|
|||
|
||||
XMLVisitor::XMLVisitor(xmlNodePtr current)
|
||||
: _current(current)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
XMLVisitor::~XMLVisitor()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void XMLVisitor::from_resource(const Resource& obj) throw(SerializerError)
|
||||
{
|
||||
|
@ -100,7 +98,7 @@ void XMLVisitor::from_resource(const Resource& obj, const Glib::ustring& key) th
|
|||
|
||||
void XMLVisitor::from_history(xmlNodePtr parent, const History& hist) throw(SerializerError)
|
||||
{
|
||||
if(parent!=NULL)
|
||||
if (parent != NULL)
|
||||
{
|
||||
from_environment(parent, hist.get_last_environment());
|
||||
}
|
||||
|
@ -113,7 +111,7 @@ void XMLVisitor::from_history(xmlNodePtr parent, const History& hist) throw(Seri
|
|||
|
||||
void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) throw(SerializerError)
|
||||
{
|
||||
if(parent==NULL)
|
||||
if (parent == NULL)
|
||||
{
|
||||
throw SerializerError(_("Error trying to add data to empty XML node."));
|
||||
}
|
||||
|
@ -127,7 +125,7 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
|
|||
|
||||
res_iterator iter = rvect.begin();
|
||||
res_iterator end = rvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
//XMLVisitor xvisit(resources_node);
|
||||
Glib::ustring key;
|
||||
|
@ -147,7 +145,7 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
|
|||
|
||||
proc_iterator iter = pvect.begin();
|
||||
proc_iterator end = pvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
// XMLVisitor xvisit(schedulables_node);
|
||||
// xvisit.from_process(*(*iter));
|
||||
|
@ -160,7 +158,7 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
|
|||
|
||||
void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key) throw(SerializerError)
|
||||
{
|
||||
if(parent!=NULL)
|
||||
if (parent != NULL)
|
||||
{
|
||||
Glib::ustring id = "reskey" + key;
|
||||
Glib::ustring strPreemptible("false"); // fixed??
|
||||
|
@ -184,7 +182,7 @@ void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Gli
|
|||
|
||||
void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(SerializerError)
|
||||
{
|
||||
if(parent!=NULL)
|
||||
if (parent != NULL)
|
||||
{
|
||||
Glib::ustring strPriority;
|
||||
Glib::ustring strArrivalTime;
|
||||
|
@ -205,7 +203,7 @@ void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(Seria
|
|||
const Threads& tvect = ((Process&)obj).get_threads();
|
||||
thr_iterator iter = tvect.begin();
|
||||
thr_iterator end = tvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
const Thread* t = *iter;
|
||||
|
||||
|
@ -222,7 +220,7 @@ void XMLVisitor::from_process(xmlNodePtr parent, const Process& obj) throw(Seria
|
|||
|
||||
void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(SerializerError)
|
||||
{
|
||||
if(parent!=NULL)
|
||||
if (parent != NULL)
|
||||
{
|
||||
|
||||
Glib::ustring strPriority;
|
||||
|
@ -246,7 +244,7 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
|
|||
const Requests& rvect = ((Thread&)obj).get_requests();
|
||||
req_iterator iter = rvect.begin();
|
||||
req_iterator end = rvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
const Request* r = *iter;
|
||||
|
||||
|
@ -263,7 +261,7 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
|
|||
|
||||
void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(SerializerError)
|
||||
{
|
||||
if(parent!=NULL)
|
||||
if (parent != NULL)
|
||||
{
|
||||
|
||||
Glib::ustring strArrivalTime;
|
||||
|
@ -280,7 +278,7 @@ void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(Seria
|
|||
const SubRequests& srvect = ((Request&)obj).get_subrequests();
|
||||
subreq_iterator iter = srvect.begin();
|
||||
subreq_iterator end = srvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
const SubRequest* sr = *iter;
|
||||
from_subrequest(request_node, *(*iter));
|
||||
|
@ -296,7 +294,7 @@ void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(Seria
|
|||
|
||||
void XMLVisitor::from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw(SerializerError)
|
||||
{
|
||||
if(parent!=NULL)
|
||||
if (parent != NULL)
|
||||
{
|
||||
|
||||
Glib::ustring strResource;
|
||||
|
|
|
@ -50,7 +50,7 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
|||
|
||||
// Update resource pointers in a way you won't like :-)
|
||||
{
|
||||
for(Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
|
||||
for (Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
|
||||
it->second = new DynamicResource(dynamic_cast<const DynamicResource&>(*it->second));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
|||
{
|
||||
const Processes& ce_proc = ce._processes;
|
||||
insert_iterator<Processes> dest(_processes, _processes.begin());
|
||||
for(Processes::const_iterator orig = ce_proc.begin(); orig != ce_proc.end(); orig++)
|
||||
for (Processes::const_iterator orig = ce_proc.begin(); orig != ce_proc.end(); orig++)
|
||||
*dest++ = new DynamicProcess(dynamic_cast<const DynamicProcess&>(**orig));
|
||||
}
|
||||
|
||||
|
@ -81,27 +81,27 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
|||
|
||||
typedef SubRequestQueue::iterator it5_t;
|
||||
|
||||
for(it1_t it1 = _processes.begin(); it1 != _processes.end(); it1++)
|
||||
for (it1_t it1 = _processes.begin(); it1 != _processes.end(); it1++)
|
||||
{
|
||||
const v2_t& threads = (*it1)->get_threads();
|
||||
for(it2_t it2 = threads.begin(); it2 != threads.end(); it2++)
|
||||
for (it2_t it2 = threads.begin(); it2 != threads.end(); it2++)
|
||||
{
|
||||
const v3_t& reqs = (*it2)->get_requests();
|
||||
for(it3_t it3 = reqs.begin(); it3 != reqs.end(); it3++)
|
||||
for (it3_t it3 = reqs.begin(); it3 != reqs.end(); it3++)
|
||||
{
|
||||
// an optimization here: there is no reason in iterating through
|
||||
// future or exausted requests. (Do you know why?)
|
||||
const v4_t& subr = (*it3)->get_subrequests();
|
||||
for(it4_t it4 = subr.begin(); it4 != subr.end(); it4++)
|
||||
for (it4_t it4 = subr.begin(); it4 != subr.end(); it4++)
|
||||
{
|
||||
SubRequest::state curr_state = (*it4)->get_state();
|
||||
if(curr_state != Request::state_future && curr_state != Request::state_exhausted)
|
||||
if (curr_state != Request::state_future && curr_state != Request::state_exhausted)
|
||||
{
|
||||
// the subrequest is the following queue:
|
||||
SubRequestQueue & queue = get_request_queue((*it4)->get_resource_key());
|
||||
// we must replace the old pointer:
|
||||
bool found = false;
|
||||
for(it5_t it5 = queue.begin(); !found && it5 != queue.end(); it5++)
|
||||
for (it5_t it5 = queue.begin(); !found && it5 != queue.end(); it5++)
|
||||
{
|
||||
DynamicSubRequest& _old = dynamic_cast<DynamicSubRequest&>(**it5);
|
||||
DynamicSubRequest& _new = dynamic_cast<DynamicSubRequest&>(**it4);
|
||||
|
@ -201,7 +201,7 @@ ConcreteEnvironment::~ConcreteEnvironment()
|
|||
memory::deletor<Process>());
|
||||
|
||||
// We do the same with Resources.
|
||||
for(Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
|
||||
for (Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
|
||||
delete it->second;
|
||||
|
||||
// After this, the destructor of _sched_queue is invoked (only invalid pointers)
|
||||
|
|
|
@ -187,7 +187,8 @@ namespace sgpem
|
|||
|
||||
SubRequestQueues _sreq_queues;
|
||||
|
||||
}; //~ class ConcreteEnvironment
|
||||
}
|
||||
; //~ class ConcreteEnvironment
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ template<typename T>
|
|||
static bool deep_remove(std::vector<T*>& v, const T& obj)
|
||||
{
|
||||
typedef typename std::vector<T*> Vector;
|
||||
for(typename Vector::iterator it = v.begin(); it != v.end(); it++)
|
||||
if(**it == obj)
|
||||
for (typename Vector::iterator it = v.begin(); it != v.end(); it++)
|
||||
if (**it == obj)
|
||||
{
|
||||
delete *it;
|
||||
v.erase(it);
|
||||
|
@ -70,8 +70,8 @@ template<typename T>
|
|||
static T* deep_find(const std::vector<T*>& v, const T& obj)
|
||||
{
|
||||
typedef typename std::vector<T*> Vector;
|
||||
for(typename Vector::const_iterator it = v.begin(); it != v.end(); it++)
|
||||
if(**it == obj)
|
||||
for (typename Vector::const_iterator it = v.begin(); it != v.end(); it++)
|
||||
if (**it == obj)
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ ConcreteHistory::ConcreteHistory(const ConcreteHistory& h) :
|
|||
History(h)
|
||||
{
|
||||
typedef Snapshots::const_iterator SnapIt;
|
||||
for(SnapIt it = h._snapshots.begin(); it != h._snapshots.end(); ++it)
|
||||
for (SnapIt it = h._snapshots.begin(); it != h._snapshots.end(); ++it)
|
||||
_snapshots.push_back(new ConcreteEnvironment(*(*it)));
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ ConcreteHistory::get_last_environment() const
|
|||
|
||||
const ConcreteEnvironment&
|
||||
ConcreteHistory::get_environment_at(position index) const
|
||||
throw(std::out_of_range)
|
||||
throw(std::out_of_range)
|
||||
{
|
||||
return *_snapshots.at(index);
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ ConcreteHistory::remove(resource_key_t resource_key)
|
|||
ConcreteEnvironment& initial = *_snapshots.front();
|
||||
ConcreteEnvironment::Resources& resources = initial.get_resources();
|
||||
ConcreteEnvironment::Resources::iterator found = resources.find(resource_key);
|
||||
if(found == resources.end())
|
||||
if (found == resources.end())
|
||||
return;
|
||||
|
||||
reset(false);
|
||||
|
@ -168,18 +168,18 @@ ConcreteHistory::remove(resource_key_t resource_key)
|
|||
// all hail the cyclomatic complexity!
|
||||
ConcreteEnvironment::Processes& processes = initial.get_processes();
|
||||
typedef ConcreteEnvironment::Processes::iterator ProcIt;
|
||||
for(ProcIt it1 = processes.begin(); it1 != processes.end(); it1++)
|
||||
for (ProcIt it1 = processes.begin(); it1 != processes.end(); it1++)
|
||||
{
|
||||
Threads& threads = dynamic_cast<DynamicProcess&>(**it1).get_dynamic_threads();
|
||||
for(Threads::iterator it2 = threads.begin(); it2 != threads.end(); it2++)
|
||||
for (Threads::iterator it2 = threads.begin(); it2 != threads.end(); it2++)
|
||||
{
|
||||
Requests& reqs = (*it2)->get_dynamic_requests();
|
||||
for(Requests::iterator it3 = reqs.begin(); it3 != reqs.end(); it3++)
|
||||
for (Requests::iterator it3 = reqs.begin(); it3 != reqs.end(); it3++)
|
||||
{
|
||||
SubRequests& subr = (*it3)->get_dynamic_subrequests();
|
||||
SubRequests::iterator it4 = subr.begin();
|
||||
while(it4 != subr.end())
|
||||
if((*it4)->get_resource_key() == resource_key)
|
||||
while (it4 != subr.end())
|
||||
if ((*it4)->get_resource_key() == resource_key)
|
||||
{
|
||||
delete *it4;
|
||||
it4 = subr.erase(it4);
|
||||
|
@ -204,7 +204,7 @@ ConcreteHistory::remove(Process& process)
|
|||
ConcreteEnvironment& initial = *_snapshots.front();
|
||||
ConcreteEnvironment::Processes& processes = initial.get_processes();
|
||||
bool found = deep_remove<Process>(processes, process);
|
||||
if(found)
|
||||
if (found)
|
||||
reset(true);
|
||||
}
|
||||
|
||||
|
@ -220,13 +220,13 @@ ConcreteHistory::remove(Thread& thread)
|
|||
|
||||
Process* found = deep_find<Process>(processes, dyn_thr.get_process());
|
||||
|
||||
if(found == NULL)
|
||||
if (found == NULL)
|
||||
return; // not found, just return.
|
||||
|
||||
DynamicProcess& dynamic_found = dynamic_cast<DynamicProcess&>(*found);
|
||||
bool removed = deep_remove<DynamicThread>(dynamic_found.get_dynamic_threads(), dyn_thr);
|
||||
|
||||
if(removed)
|
||||
if (removed)
|
||||
reset(true);
|
||||
}
|
||||
|
||||
|
@ -244,15 +244,15 @@ ConcreteHistory::remove(Request& request)
|
|||
|
||||
Process* proc_ref = deep_find<Process>(processes, dyn_proc);
|
||||
DynamicProcess* dyn_proc_ref = dynamic_cast<DynamicProcess*>(proc_ref);
|
||||
if(dyn_proc_ref == NULL)
|
||||
if (dyn_proc_ref == NULL)
|
||||
return; // not found, just return.
|
||||
DynamicThread* thr_ref = deep_find<DynamicThread>(dyn_proc_ref->get_dynamic_threads(), dyn_thr);
|
||||
if(thr_ref == NULL)
|
||||
if (thr_ref == NULL)
|
||||
return; // not found, just return.
|
||||
|
||||
bool removed = deep_remove<DynamicRequest>(thr_ref->get_dynamic_requests(), dyn_req);
|
||||
|
||||
if(removed)
|
||||
if (removed)
|
||||
reset(true);
|
||||
}
|
||||
|
||||
|
@ -274,18 +274,18 @@ ConcreteHistory::remove(SubRequest& subrequest)
|
|||
|
||||
Process* proc_ref = deep_find<Process>(processes, dyn_proc);
|
||||
DynamicProcess* dyn_proc_ref = dynamic_cast<DynamicProcess*>(proc_ref);
|
||||
if(dyn_proc_ref == NULL)
|
||||
if (dyn_proc_ref == NULL)
|
||||
return; // not found, just return.
|
||||
DynamicThread* thr_ref = deep_find<DynamicThread>(dyn_proc_ref->get_dynamic_threads(), dyn_thr);
|
||||
if(thr_ref == NULL)
|
||||
if (thr_ref == NULL)
|
||||
return; // not found, just return.
|
||||
DynamicRequest* req_ref = deep_find<DynamicRequest>(thr_ref->get_dynamic_requests(), dyn_req);
|
||||
if(req_ref == NULL)
|
||||
if (req_ref == NULL)
|
||||
return; // not found, just return.
|
||||
|
||||
bool removed = deep_remove<DynamicSubRequest>(req_ref->get_dynamic_subrequests(), dyn_sub);
|
||||
|
||||
if(removed)
|
||||
if (removed)
|
||||
reset(true);
|
||||
}
|
||||
|
||||
|
@ -309,15 +309,15 @@ ConcreteHistory::add_resource(const Glib::ustring& name,
|
|||
|
||||
// alakazam! Black magic at work... get a unique index for this resource
|
||||
resource_key_t index = 0;
|
||||
while(resources.find(index) != resources.end())
|
||||
while (resources.find(index) != resources.end())
|
||||
index++;
|
||||
|
||||
// Found a hole in the map, fill it like little Hans,
|
||||
// its finger and the spilling dam.
|
||||
Resources::iterator temp = resources.insert(pair<resource_key_t,Resource*>(index, resource)).first;
|
||||
Resources::iterator temp = resources.insert(pair<resource_key_t, Resource*>(index, resource)).first;
|
||||
// The same for request queues.
|
||||
SubRequestQueue emptysrq;
|
||||
_snapshots.front()->get_subrequest_queues().insert(pair<resource_key_t,SubRequestQueue>(index, emptysrq));
|
||||
_snapshots.front()->get_subrequest_queues().insert(pair<resource_key_t, SubRequestQueue>(index, emptysrq));
|
||||
|
||||
|
||||
notify_change();
|
||||
|
@ -412,7 +412,7 @@ ConcreteHistory::reset(bool notify)
|
|||
for_each(it, _snapshots.end(), deletor<ConcreteEnvironment>());
|
||||
_snapshots.resize(1); // Truncate to keep only our "model"
|
||||
|
||||
if(notify)
|
||||
if (notify)
|
||||
notify_change();
|
||||
}
|
||||
|
||||
|
@ -420,6 +420,6 @@ void
|
|||
ConcreteHistory::notify_change()
|
||||
{
|
||||
History::RegisteredObservers::iterator it;
|
||||
for(it =_observers.begin(); it != _observers.end(); it++)
|
||||
for (it = _observers.begin(); it != _observers.end(); it++)
|
||||
(*it)->update(*this);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ namespace sgpem
|
|||
// Disable assignment, implement it only if needed
|
||||
ConcreteHistory& operator=(const ConcreteHistory& op2);
|
||||
|
||||
}; //~ class ConcreteHistory
|
||||
}
|
||||
; //~ class ConcreteHistory
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ ConcreteSimulation::stop()
|
|||
void
|
||||
ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException)
|
||||
{
|
||||
switch(_state)
|
||||
switch (_state)
|
||||
{
|
||||
case state_running:
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException)
|
|||
|
||||
_state = state_running;
|
||||
|
||||
if(get_policy() == NULL)
|
||||
if (get_policy() == NULL)
|
||||
{
|
||||
stop();
|
||||
throw NullPolicyException("no policy selected");
|
||||
|
@ -103,12 +103,12 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException)
|
|||
{
|
||||
//step forward
|
||||
bool yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
|
||||
if(!yet_to_finish) stop();
|
||||
if (!yet_to_finish) stop();
|
||||
|
||||
//sleep
|
||||
Glib::usleep(_timer_interval*1000);
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
stop();
|
||||
throw;
|
||||
|
@ -118,7 +118,7 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException)
|
|||
if (_state == state_stopped || _state == state_paused)
|
||||
return;
|
||||
}
|
||||
while(true);
|
||||
while (true);
|
||||
}
|
||||
|
||||
//******* STEP by STEP
|
||||
|
@ -129,12 +129,12 @@ ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException)
|
|||
assert(get_policy() != NULL);
|
||||
//step forward
|
||||
bool yet_to_finish = Scheduler::get_instance().step_forward(_history, *get_policy());
|
||||
if(yet_to_finish)
|
||||
if (yet_to_finish)
|
||||
pause();
|
||||
else
|
||||
stop();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
stop();
|
||||
throw;
|
||||
|
@ -159,7 +159,7 @@ ConcreteSimulation::set_policy(CPUPolicy* p)
|
|||
{
|
||||
_policy = p;
|
||||
|
||||
if(p != NULL)
|
||||
if (p != NULL)
|
||||
CPUPoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ CPUPoliciesGatekeeper::register_manager(CPUPolicyManager* manager)
|
|||
|
||||
ManagerIterator end = _registered.end();
|
||||
|
||||
if(find(_registered.begin(), end, manager) == end)
|
||||
if (find(_registered.begin(), end, manager) == end)
|
||||
_registered.push_back(manager);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ CPUPoliciesGatekeeper::unregister_manager(CPUPolicyManager* manager)
|
|||
ManagerIterator end = _registered.end();
|
||||
ManagerIterator pos = find(_registered.begin(), end, manager);
|
||||
|
||||
if(pos != end)
|
||||
if (pos != end)
|
||||
{
|
||||
deactivate_policies(*pos);
|
||||
_registered.erase(pos);
|
||||
|
@ -81,7 +81,7 @@ CPUPoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
|||
|
||||
ActiveIterator policy = _active_policies.find(history);
|
||||
|
||||
if(policy == _active_policies.end())
|
||||
if (policy == _active_policies.end())
|
||||
throw runtime_error("No active policy associated with this "
|
||||
"history is available.");
|
||||
|
||||
|
@ -96,10 +96,10 @@ CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy)
|
|||
ActiveIterator end = _active_policies.end();
|
||||
ActiveIterator pos = _active_policies.find(history);
|
||||
|
||||
if(pos != end && pos->second != policy)
|
||||
if (pos != end && pos->second != policy)
|
||||
_active_policies[history]->deactivate();
|
||||
|
||||
if(pos == end || pos->second != policy)
|
||||
if (pos == end || pos->second != policy)
|
||||
{
|
||||
_active_policies[history] = policy;
|
||||
_active_policies[history]->activate();
|
||||
|
@ -119,15 +119,15 @@ CPUPoliciesGatekeeper::deactivate_policies(CPUPolicyManager* manager)
|
|||
CPUPolicyIterator avail_it = avail_policies.begin();
|
||||
CPUPolicyIterator avail_end = avail_policies.end();
|
||||
|
||||
for(; avail_it != avail_end; ++avail_it)
|
||||
for (; avail_it != avail_end; ++avail_it)
|
||||
{
|
||||
// TODO isn't there a way to write more compact code by using
|
||||
// library utilities?
|
||||
ActiveIterator act_it = _active_policies.begin();
|
||||
|
||||
while(act_it != _active_policies.end())
|
||||
while (act_it != _active_policies.end())
|
||||
{
|
||||
if(act_it->second == *avail_it)
|
||||
if (act_it->second == *avail_it)
|
||||
{
|
||||
ActiveIterator removable = act_it++;
|
||||
removable->second->deactivate();
|
||||
|
|
|
@ -38,7 +38,7 @@ CPUPolicyManager::~CPUPolicyManager()
|
|||
{
|
||||
// This check is necessary:
|
||||
//FIXME remove this when get_registered_manager is dropped
|
||||
if(_registered == this) _registered = NULL;
|
||||
if (_registered == this) _registered = NULL;
|
||||
|
||||
CPUPoliciesGatekeeper::get_instance().unregister_manager(this);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
|
|||
|
||||
const vector<DynamicThread*>& other_threads = other._dynamic_threads;
|
||||
|
||||
for(ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
|
||||
for (ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
|
||||
new DynamicThread(*(*it), this);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ DynamicProcess::get_state() const
|
|||
unsigned int closest = 0;
|
||||
|
||||
vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
for(; it != _dynamic_threads.end(); it++)
|
||||
for (; it != _dynamic_threads.end(); it++)
|
||||
{
|
||||
if ((**it).get_state() == state_running) running++;
|
||||
if ((**it).get_state() == state_ready) ready++;
|
||||
|
@ -225,7 +225,7 @@ unsigned int
|
|||
DynamicProcess::get_elapsed_time() const
|
||||
{
|
||||
unsigned int result = 0;
|
||||
for(std::vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
for (std::vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
it != _dynamic_threads.end(); it++)
|
||||
{
|
||||
result += (*it)->get_elapsed_time();
|
||||
|
@ -237,11 +237,11 @@ int
|
|||
DynamicProcess::get_last_acquisition() const
|
||||
{
|
||||
int result = -1;
|
||||
for(std::vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
for (std::vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
it != _dynamic_threads.end(); it++)
|
||||
{
|
||||
int acq = (*it)->get_last_acquisition();
|
||||
if(result < acq)
|
||||
if (result < acq)
|
||||
result = acq;
|
||||
}
|
||||
return result;
|
||||
|
@ -251,11 +251,11 @@ int
|
|||
DynamicProcess::get_last_release() const
|
||||
{
|
||||
int result = -1;
|
||||
for(std::vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
for (std::vector<DynamicThread*>::const_iterator it = _dynamic_threads.begin();
|
||||
it != _dynamic_threads.end(); it++)
|
||||
{
|
||||
int acq = (*it)->get_last_release();
|
||||
if(result < acq)
|
||||
if (result < acq)
|
||||
result = acq;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -58,7 +58,7 @@ DynamicRequest::DynamicRequest(const DynamicRequest& other, DynamicThread* owner
|
|||
// Not sure of this, but the constructor of DynamicSubRequest should take care
|
||||
// of adding itself to the vector of sub requests. This is only my opinion,
|
||||
// but I think this is a complicated way of doing things...
|
||||
for(SubReqVec::const_iterator it = other_subs.begin(); it != other_subs.end(); ++it)
|
||||
for (SubReqVec::const_iterator it = other_subs.begin(); it != other_subs.end(); ++it)
|
||||
new DynamicSubRequest(*(*it), this);
|
||||
|
||||
// Leave this line: it helps us with a compiler warning if
|
||||
|
@ -122,11 +122,11 @@ DynamicRequest::get_state() const
|
|||
#endif // ~NDEBUG
|
||||
|
||||
const SubReqs& sreqs = _dynamic_subrequests;
|
||||
for(SubReqs::const_iterator it = sreqs.begin(); it != sreqs.end(); it++)
|
||||
for (SubReqs::const_iterator it = sreqs.begin(); it != sreqs.end(); it++)
|
||||
{
|
||||
SubRequest& cur = **it;
|
||||
|
||||
switch(cur.get_state())
|
||||
switch (cur.get_state())
|
||||
{
|
||||
case state_allocated:
|
||||
return state_allocated;
|
||||
|
@ -139,7 +139,7 @@ DynamicRequest::get_state() const
|
|||
// have the same state since state_allocable,
|
||||
// state_terminated and state_future are mutually
|
||||
// exclusive
|
||||
if(at_least_once)
|
||||
if (at_least_once)
|
||||
assert(result == cur.get_state());
|
||||
at_least_once = true;
|
||||
#endif //~ NDEBUG
|
||||
|
|
|
@ -37,8 +37,8 @@ DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
|
|||
{
|
||||
assert(core != NULL);
|
||||
assert(owner != NULL);
|
||||
// Leave this line: it helps us with a compiler warning if
|
||||
// the get_dynamic* method signature changes:
|
||||
// Leave this line: it helps us with a compiler warning if
|
||||
// the get_dynamic* method signature changes:
|
||||
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
|
||||
siblings.push_back(this);
|
||||
}
|
||||
|
@ -51,15 +51,14 @@ DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other,
|
|||
{
|
||||
assert(owner != NULL);
|
||||
|
||||
// Leave this line: it helps us with a compiler warning if
|
||||
// the get_dynamic* method signature changes:
|
||||
// Leave this line: it helps us with a compiler warning if
|
||||
// the get_dynamic* method signature changes:
|
||||
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
|
||||
siblings.push_back(this);
|
||||
}
|
||||
|
||||
DynamicSubRequest::~DynamicSubRequest()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
bool
|
||||
|
@ -131,7 +130,7 @@ DynamicSubRequest::decrease_remaining_time()
|
|||
{
|
||||
assert(_state == Request::state_allocated);
|
||||
unsigned int temp = get_remaining_time();
|
||||
if(temp > 0)
|
||||
if (temp > 0)
|
||||
_ran_for++;
|
||||
|
||||
return temp;
|
||||
|
|
|
@ -59,7 +59,7 @@ DynamicThread::DynamicThread(const DynamicThread &other, DynamicProcess* parent)
|
|||
|
||||
const vector<DynamicRequest*>& other_req = other._dynamic_requests;
|
||||
|
||||
for(ReqIt it = other_req.begin(); it != other_req.end(); ++it)
|
||||
for (ReqIt it = other_req.begin(); it != other_req.end(); ++it)
|
||||
new DynamicRequest(*(*it), this);
|
||||
|
||||
// Leave this line: it helps us with a compiler warning if
|
||||
|
@ -140,7 +140,7 @@ DynamicThread::decrease_remaining_time()
|
|||
{
|
||||
// strict check for us to better debug scheduler
|
||||
assert(_ran_for < get_total_cpu_time());
|
||||
if(_ran_for < get_total_cpu_time())
|
||||
if (_ran_for < get_total_cpu_time())
|
||||
_ran_for++;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,8 @@ GlobalPreferences::key_file_read(KeyFile& kf)
|
|||
{
|
||||
int new_speed;
|
||||
const Glib::ustring* val = kf.search_value(Glib::ustring("speed"));
|
||||
if(val){
|
||||
if (val)
|
||||
{
|
||||
string_to_int(*val, new_speed);
|
||||
set_speed(new_speed);
|
||||
}
|
||||
|
@ -165,18 +166,18 @@ GlobalPreferences::key_file_read(KeyFile& kf)
|
|||
// read modules directories
|
||||
{
|
||||
const Glib::ustring* val = kf.search_value(Glib::ustring("modules-dir-number"));
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
std::istringstream istr(val->c_str());
|
||||
int n;
|
||||
istr >> n;
|
||||
for(int i=1; i<=n; i++)
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "modules-dir-" << i;
|
||||
Glib::ustring key(ostr.str());
|
||||
val = kf.search_value(key);
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
// add_modules_dir(*val);
|
||||
_mod_dirs.push_back(*val);
|
||||
|
@ -188,18 +189,18 @@ GlobalPreferences::key_file_read(KeyFile& kf)
|
|||
// read policies directories
|
||||
{
|
||||
const Glib::ustring* val = kf.search_value(Glib::ustring("policies-dir-number"));
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
std::istringstream istr(val->c_str());
|
||||
int n;
|
||||
istr >> n;
|
||||
for(int i=1; i<=n; i++)
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "policies-dir-" << i;
|
||||
Glib::ustring key(ostr.str());
|
||||
val = kf.search_value(key);
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
// add_policies_dir(*val);
|
||||
_pol_dirs.push_back(*val);
|
||||
|
@ -227,10 +228,11 @@ GlobalPreferences::key_file_write(KeyFile& kf)
|
|||
/*
|
||||
GlobalPreferences::dir_iterator iter=_globalPreferences.modules_dir_begin();
|
||||
*/
|
||||
dir_iterator iter=_mod_dirs.begin();
|
||||
dir_iterator end=_mod_dirs.end();
|
||||
int n=0;
|
||||
while(iter!=end){
|
||||
dir_iterator iter = _mod_dirs.begin();
|
||||
dir_iterator end = _mod_dirs.end();
|
||||
int n = 0;
|
||||
while (iter != end)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
n++;
|
||||
ostr << "modules-dir-" << n; // << std::ends;
|
||||
|
@ -246,13 +248,14 @@ GlobalPreferences::key_file_write(KeyFile& kf)
|
|||
}
|
||||
// add policies directories
|
||||
{
|
||||
/*
|
||||
/*
|
||||
GlobalPreferences::dir_iterator iter=_globalPreferences.policies_dir_begin();
|
||||
*/
|
||||
dir_iterator iter=_pol_dirs.begin();
|
||||
dir_iterator end=_pol_dirs.end();
|
||||
int n=0;
|
||||
while(iter!=end){
|
||||
dir_iterator iter = _pol_dirs.begin();
|
||||
dir_iterator end = _pol_dirs.end();
|
||||
int n = 0;
|
||||
while (iter != end)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
n++;
|
||||
ostr << "policies-dir-" << n; // << std::ends;
|
||||
|
|
|
@ -41,18 +41,18 @@ namespace sgpem
|
|||
// read modules directories
|
||||
{
|
||||
const Glib::ustring* val = search_value(Glib::ustring("modules-dir-number"));
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
std::istringstream istr(val->c_str());
|
||||
int n;
|
||||
istr >> n;
|
||||
for(int i=1; i<=n; i++)
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "modules-dir-" << i << std::ends;
|
||||
Glib::ustring key(ostr.str());
|
||||
val = search_value(key);
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
_globalPreferences.add_modules_dir(*val);
|
||||
}
|
||||
|
@ -63,18 +63,18 @@ namespace sgpem
|
|||
// read policies directories
|
||||
{
|
||||
const Glib::ustring* val = search_value(Glib::ustring("policies-dir-number"));
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
std::istringstream istr(val->c_str());
|
||||
int n;
|
||||
istr >> n;
|
||||
for(int i=1; i<=n; i++)
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "policies-dir-" << i << std::ends;
|
||||
Glib::ustring key(ostr.str());
|
||||
val = search_value(key);
|
||||
if(val)
|
||||
if (val)
|
||||
{
|
||||
_globalPreferences.add_policies_dir(*val);
|
||||
}
|
||||
|
@ -88,9 +88,10 @@ namespace sgpem
|
|||
{
|
||||
// add modules directories
|
||||
{
|
||||
GlobalPreferences::dir_iterator iter=_globalPreferences.modules_dir_begin();
|
||||
int n=0;
|
||||
while(iter!=_globalPreferences.modules_dir_end()){
|
||||
GlobalPreferences::dir_iterator iter = _globalPreferences.modules_dir_begin();
|
||||
int n = 0;
|
||||
while (iter != _globalPreferences.modules_dir_end())
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
n++;
|
||||
ostr << "modules-dir-" << n << std::ends;
|
||||
|
@ -106,9 +107,10 @@ namespace sgpem
|
|||
}
|
||||
// add policies directories
|
||||
{
|
||||
GlobalPreferences::dir_iterator iter=_globalPreferences.policies_dir_begin();
|
||||
int n=0;
|
||||
while(iter!=_globalPreferences.policies_dir_end()){
|
||||
GlobalPreferences::dir_iterator iter = _globalPreferences.policies_dir_begin();
|
||||
int n = 0;
|
||||
while (iter != _globalPreferences.policies_dir_end())
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
n++;
|
||||
ostr << "policies-dir-" << n << std::ends;
|
||||
|
|
|
@ -31,13 +31,11 @@ using namespace std;
|
|||
|
||||
History::History()
|
||||
: _notify(true)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
History::~History()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
|
@ -59,9 +57,9 @@ History::detach(const HistoryObserver& observer)
|
|||
void
|
||||
History::notify_change()
|
||||
{
|
||||
if(!_notify) return;
|
||||
if (!_notify) return;
|
||||
|
||||
for(RegisteredObservers::iterator it =_observers.begin();
|
||||
for (RegisteredObservers::iterator it = _observers.begin();
|
||||
it != _observers.end(); it++)
|
||||
(*it)->update(*this);
|
||||
}
|
||||
|
@ -74,7 +72,7 @@ History::set_notify_enabled(bool enabled)
|
|||
_notify = enabled;
|
||||
|
||||
// Force notify if we re-enable it
|
||||
if(old_value == false && _notify == true)
|
||||
if (old_value == false && _notify == true)
|
||||
notify_change();
|
||||
|
||||
return old_value;
|
||||
|
|
|
@ -123,7 +123,8 @@ namespace sgpem
|
|||
private:
|
||||
bool _notify;
|
||||
|
||||
}; //~ class History
|
||||
}
|
||||
; //~ class History
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ namespace sgpem
|
|||
virtual void update(const History& changed_history) = 0;
|
||||
virtual ~HistoryObserver();
|
||||
|
||||
}; // class HistoryObserver
|
||||
}
|
||||
; // class HistoryObserver
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
|
|
|
@ -37,26 +37,26 @@ HoltGraph::update(const History& changed_history)
|
|||
_active_threads.clear();
|
||||
_active_requests.clear();
|
||||
|
||||
for(unsigned int pi = 0; pi < processes.size(); ++pi)
|
||||
for (unsigned int pi = 0; pi < processes.size(); ++pi)
|
||||
{
|
||||
vector<Thread*> threads = processes[pi]->get_threads();
|
||||
|
||||
for(unsigned int ti = 0; ti < threads.size(); ++ti)
|
||||
for (unsigned int ti = 0; ti < threads.size(); ++ti)
|
||||
{
|
||||
vector<Request*> requests = threads[ti]->get_requests();
|
||||
|
||||
for(unsigned int ri = 0; ri < requests.size(); ++ri)
|
||||
for (unsigned int ri = 0; ri < requests.size(); ++ri)
|
||||
{
|
||||
Request& r = *requests[ri];
|
||||
|
||||
if(r.get_state() == Request::state_allocated)
|
||||
if (r.get_state() == Request::state_allocated)
|
||||
{
|
||||
_active_requests.push_back(&r);
|
||||
_active_threads.insert(&r.get_thread());
|
||||
|
||||
vector<SubRequest*> subrequests = r.get_subrequests();
|
||||
|
||||
for(unsigned int sri = 0; sri < subrequests.size(); ++sri)
|
||||
for (unsigned int sri = 0; sri < subrequests.size(); ++sri)
|
||||
{
|
||||
Environment::resource_key_t key = subrequests[sri]->get_resource_key();
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ namespace sgpem
|
|||
std::set<const Resource*> _resources;
|
||||
std::set<const Thread*> _active_threads;
|
||||
Requests _active_requests;
|
||||
}; // class HistoryObserver
|
||||
}
|
||||
; // class HistoryObserver
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
|
|
|
@ -26,5 +26,4 @@ using namespace sgpem;
|
|||
|
||||
InvalidPluginException::InvalidPluginException(const std::string& what) :
|
||||
std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
|
|
@ -31,7 +31,8 @@ namespace sgpem
|
|||
{
|
||||
public:
|
||||
InvalidPluginException(const std::string& what);
|
||||
}; //~ class InvalidPluginException
|
||||
}
|
||||
; //~ class InvalidPluginException
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace sgpem
|
|||
{
|
||||
const Glib::ustring* ret = 0;
|
||||
elements_iterator cur = _elements.find(key);
|
||||
if(cur != elements_end())
|
||||
if (cur != elements_end())
|
||||
{
|
||||
ret = &((*cur).second);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace sgpem
|
|||
KeyFile::file_read(const Glib::ustring& filename)
|
||||
{
|
||||
std::ifstream ifs(filename.c_str());
|
||||
if(ifs)
|
||||
if (ifs)
|
||||
{
|
||||
file_read(ifs);
|
||||
} // end - if(ifs)
|
||||
|
@ -81,23 +81,23 @@ namespace sgpem
|
|||
void
|
||||
KeyFile::file_read(std::istream& is)
|
||||
{
|
||||
if(is)
|
||||
if (is)
|
||||
{
|
||||
_elements.clear(); // erase all elements
|
||||
char buff[KEY_FILE_BUF_LEN]; //
|
||||
while(is)
|
||||
while (is)
|
||||
{
|
||||
is.getline(buff, (KEY_FILE_BUF_LEN), '\n');
|
||||
// if not a comment line...
|
||||
|
||||
if(*buff!='\0' && *buff!='#')
|
||||
if (*buff != '\0' && *buff != '#')
|
||||
{
|
||||
char* pos = strchr(buff, '=');
|
||||
if(pos!=0)
|
||||
if (pos != 0)
|
||||
{
|
||||
*pos = '\0';
|
||||
const Glib::ustring key(buff);
|
||||
const Glib::ustring value(pos+1);
|
||||
const Glib::ustring value(pos + 1);
|
||||
insert_key_value(key, value);
|
||||
}
|
||||
} // end - if not a comment line...
|
||||
|
@ -110,7 +110,7 @@ namespace sgpem
|
|||
KeyFile::file_write(const Glib::ustring& filename)
|
||||
{
|
||||
std::ofstream ofs(filename.c_str());
|
||||
if(ofs)
|
||||
if (ofs)
|
||||
{
|
||||
file_write(ofs);
|
||||
} // end - if(ofs)
|
||||
|
@ -119,10 +119,11 @@ namespace sgpem
|
|||
void
|
||||
KeyFile::file_write(std::ostream& os)
|
||||
{
|
||||
if(os)
|
||||
if (os)
|
||||
{
|
||||
elements_iterator iter;
|
||||
for(iter = elements_begin(); iter != elements_end(); iter++){
|
||||
for (iter = elements_begin(); iter != elements_end(); iter++)
|
||||
{
|
||||
os << (*iter).first << "=" << (*iter).second << std::endl;
|
||||
}
|
||||
} // end - if(ofs)
|
||||
|
|
|
@ -35,11 +35,11 @@ Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) :
|
|||
get_author_ptr(NULL),
|
||||
get_version_ptr(NULL)
|
||||
{
|
||||
if(!*this) throw InvalidPluginException(Module::get_last_error());
|
||||
if (!*this) throw InvalidPluginException(Module::get_last_error());
|
||||
|
||||
// Type-safeness here is an optional, as always. :-)
|
||||
std::string prefix = "sgpem__Plugin__";
|
||||
if(!(get_symbol(prefix + "on_init", (void*&) on_init_ptr) &&
|
||||
if (!(get_symbol(prefix + "on_init", (void*&) on_init_ptr) &&
|
||||
get_symbol(prefix + "on_exit", (void*&) on_exit_ptr) &&
|
||||
get_symbol(prefix + "describe", (void*&) describe_ptr) &&
|
||||
get_symbol(prefix + "get_name", (void*&) get_name_ptr) &&
|
||||
|
@ -52,10 +52,10 @@ Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) :
|
|||
void
|
||||
Module::set_enabled(bool enabled)
|
||||
{
|
||||
if(_enabled == enabled)
|
||||
if (_enabled == enabled)
|
||||
return;
|
||||
|
||||
if(enabled)
|
||||
if (enabled)
|
||||
on_init_ptr();
|
||||
else
|
||||
on_exit_ptr();
|
||||
|
|
|
@ -64,7 +64,8 @@ namespace sgpem
|
|||
f_ustring get_author_ptr;
|
||||
f_float get_version_ptr;
|
||||
|
||||
}; //~ class Module
|
||||
}
|
||||
; //~ class Module
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -59,14 +59,14 @@ PluginManager::rescan_dirs()
|
|||
|
||||
Glib::PatternSpec shared_obj(Glib::ustring("*.") + G_MODULE_SUFFIX);
|
||||
|
||||
while(it != prefs.modules_dir_end())
|
||||
while (it != prefs.modules_dir_end())
|
||||
{
|
||||
Glib::Dir dir(*it);
|
||||
|
||||
for(Glib::DirIterator dir_it = dir.begin(); dir_it != dir.end(); ++dir_it)
|
||||
for (Glib::DirIterator dir_it = dir.begin(); dir_it != dir.end(); ++dir_it)
|
||||
{
|
||||
// only attempt to load .so files
|
||||
if(shared_obj.match(*dir_it))
|
||||
if (shared_obj.match(*dir_it))
|
||||
{
|
||||
std::string module_path = Module::build_path(*it, *dir_it);
|
||||
|
||||
|
@ -78,7 +78,7 @@ PluginManager::rescan_dirs()
|
|||
_modules.push_back(module);
|
||||
std::cerr << "\tSuccess" << std::endl;
|
||||
}
|
||||
catch(InvalidPluginException e)
|
||||
catch (InvalidPluginException e)
|
||||
{
|
||||
std::cerr << "\tFailed, invalid plugin: " << e.what() << std::endl;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ namespace sgpem
|
|||
|
||||
std::vector<Module*> _modules;
|
||||
|
||||
}; //~ class PluginManager
|
||||
}
|
||||
; //~ class PluginManager
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ using sgpem::ReadyQueue;
|
|||
|
||||
void
|
||||
ReadyQueue::swap(position a, position b)
|
||||
throw (std::out_of_range)
|
||||
throw (std::out_of_range)
|
||||
{
|
||||
if(a == b) return;
|
||||
if (a == b) return;
|
||||
|
||||
// Usage of "at()" isn't casual:
|
||||
// at() checks indexes, "[]" doesn't.
|
||||
|
@ -51,7 +51,7 @@ ReadyQueue::size() const
|
|||
|
||||
sgpem::Thread&
|
||||
ReadyQueue::get_item_at(position index)
|
||||
throw (std::out_of_range)
|
||||
throw (std::out_of_range)
|
||||
{
|
||||
// Checks index access
|
||||
return *_scheds.at(index);
|
||||
|
@ -59,7 +59,7 @@ ReadyQueue::get_item_at(position index)
|
|||
|
||||
const sgpem::Thread&
|
||||
ReadyQueue::get_item_at(position index) const
|
||||
throw (std::out_of_range)
|
||||
throw (std::out_of_range)
|
||||
{
|
||||
// Checks index access
|
||||
return *_scheds.at(index);
|
||||
|
|
|
@ -55,7 +55,7 @@ ResourcePoliciesGatekeeper::register_manager(ResourcePolicyManager* manager)
|
|||
|
||||
ManagerIterator end = _registered.end();
|
||||
|
||||
if(find(_registered.begin(), end, manager) == end)
|
||||
if (find(_registered.begin(), end, manager) == end)
|
||||
_registered.push_back(manager);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ ResourcePoliciesGatekeeper::unregister_manager(ResourcePolicyManager* manager)
|
|||
ManagerIterator end = _registered.end();
|
||||
ManagerIterator pos = find(_registered.begin(), end, manager);
|
||||
|
||||
if(pos != end)
|
||||
if (pos != end)
|
||||
{
|
||||
deactivate_policies(**pos);
|
||||
_registered.erase(pos);
|
||||
|
@ -81,7 +81,7 @@ ResourcePoliciesGatekeeper::get_current_policy(History* history) throw(runtime_e
|
|||
|
||||
PolicyIterator policy = _active_policies.find(history);
|
||||
|
||||
if(policy == _active_policies.end())
|
||||
if (policy == _active_policies.end())
|
||||
throw runtime_error("No active policy associated with this "
|
||||
"history is available.");
|
||||
|
||||
|
@ -97,8 +97,7 @@ ResourcePoliciesGatekeeper::activate_policy(History *history, ResourcePolicy* po
|
|||
}
|
||||
|
||||
ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
ResourcePoliciesGatekeeper::deactivate_policies(const ResourcePolicyManager& manager)
|
||||
|
@ -107,17 +106,18 @@ ResourcePoliciesGatekeeper::deactivate_policies(const ResourcePolicyManager& man
|
|||
|
||||
const vector<ResourcePolicy*>& policies = manager.get_avail_policies();
|
||||
|
||||
for(AvailableIt avail_it = policies.begin(); avail_it != policies.end(); ++avail_it)
|
||||
for (AvailableIt avail_it = policies.begin(); avail_it != policies.end(); ++avail_it)
|
||||
{
|
||||
// TODO isn't there a way to write more compact code by using
|
||||
// library utilities?
|
||||
for(PolicyIterator it = _active_policies.begin(); it != _active_policies.end();)
|
||||
for (PolicyIterator it = _active_policies.begin(); it != _active_policies.end();)
|
||||
{
|
||||
// FIXME Is this necessary? It just came across my mind the idea that
|
||||
// incrementing an invalid iterator might be unsafe...
|
||||
PolicyIterator next = it; ++next;
|
||||
PolicyIterator next = it;
|
||||
++next;
|
||||
|
||||
if(it->second == *avail_it)
|
||||
if (it->second == *avail_it)
|
||||
_active_policies.erase(it);
|
||||
|
||||
it = next;
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef std::vector<DynamicThread*> Threads;
|
|||
|
||||
class Extender
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
enum walk_purpose
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ class Extender
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
|
||||
// the following methods are never used in step forward (by now)
|
||||
|
||||
|
@ -390,9 +390,9 @@ class Extender
|
|||
}
|
||||
}
|
||||
|
||||
// /// If the thread is runnable, we may need to refill its quantum.
|
||||
// if (t.state == "RUNNING" && t.remaining_quantum == 0)
|
||||
// t.remaining_quantum = quantum_size;
|
||||
// /// If the thread is runnable, we may need to refill its quantum.
|
||||
// if (t.state == "RUNNING" && t.remaining_quantum == 0)
|
||||
// t.remaining_quantum = quantum_size;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -400,12 +400,12 @@ class Extender
|
|||
}
|
||||
front = old_front;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// private class members
|
||||
private:
|
||||
private:
|
||||
|
||||
auto_ptr<ConcreteEnvironment> & env;
|
||||
int walk;
|
||||
|
@ -440,7 +440,7 @@ collect_threads(const std::vector<Process*>& procs,
|
|||
typedef std::vector<DynamicThread*> Threads;
|
||||
|
||||
collected_threads.clear();
|
||||
for(Processes::const_iterator it1 = procs.begin(); it1 != procs.end(); it1++)
|
||||
for (Processes::const_iterator it1 = procs.begin(); it1 != procs.end(); it1++)
|
||||
{
|
||||
const Threads& ts = ((DynamicProcess&) **it1).get_dynamic_threads();
|
||||
collected_threads.insert(collected_threads.end(), ts.begin(), ts.end());
|
||||
|
@ -454,9 +454,9 @@ static void prepare_ready_queue(ConcreteEnvironment& snapshot,
|
|||
ReadyQueue& queue = snapshot.get_sorted_queue();
|
||||
assert(queue.size() == 0);
|
||||
|
||||
for(Threads::const_iterator it = all_threads.begin();
|
||||
for (Threads::const_iterator it = all_threads.begin();
|
||||
it != all_threads.end(); it++)
|
||||
if((*it)->get_state() == Schedulable::state_ready)
|
||||
if ((*it)->get_state() == Schedulable::state_ready)
|
||||
queue.append(**it);
|
||||
}
|
||||
|
||||
|
@ -468,8 +468,7 @@ static void prepare_ready_queue(ConcreteEnvironment& snapshot,
|
|||
//private constructor. The parameter is discarded
|
||||
Scheduler::Scheduler()
|
||||
: _ready_queue(NULL), _policy(NULL), _step_mutex()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
ReadyQueue*
|
||||
|
@ -504,7 +503,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
// store a readyqueue and policy pointer for the user-policy to retrieve, to when
|
||||
// the policy returns
|
||||
// TODO: restrict this area to maximise parallelism
|
||||
Glib::Mutex::Lock lock(_step_mutex);
|
||||
Glib::Mutex::Lock lock (_step_mutex);
|
||||
|
||||
// NOTE: Be sure to read the *ORIGINAL* documentation in the design document for this method!
|
||||
|
||||
|
@ -527,19 +526,19 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
|
||||
// designer + implementer (Matteo) comment follows:
|
||||
|
||||
for(Threads::iterator it = all_threads.begin(); it != all_threads.end(); it++)
|
||||
for (Threads::iterator it = all_threads.begin(); it != all_threads.end(); it++)
|
||||
{
|
||||
DynamicThread& current = **it;
|
||||
|
||||
// 1. mark future threads as ready, if appropriate
|
||||
if(current.get_state() == Schedulable::state_future)
|
||||
if (current.get_state() == Schedulable::state_future)
|
||||
{
|
||||
// if there is at least a future process, don't terminate the simulation
|
||||
Process& parent = current.get_process();
|
||||
if (parent.get_state() == Schedulable::state_future)
|
||||
simulation_ended = false;
|
||||
// start a thread only if its parent is arrived!
|
||||
if(parent.get_arrival_time() <= current_instant && parent.get_elapsed_time() == current.get_arrival_time())
|
||||
if (parent.get_arrival_time() <= current_instant && parent.get_elapsed_time() == current.get_arrival_time())
|
||||
{
|
||||
current.set_state(Schedulable::state_ready);
|
||||
// in this way we will never have threads ready having remaining time == 0
|
||||
|
@ -550,7 +549,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
|
||||
// Save the current running thread for future usage, if it hasn't ended
|
||||
// its allotted time
|
||||
if(current.get_state() == Schedulable::state_running)
|
||||
if (current.get_state() == Schedulable::state_running)
|
||||
{
|
||||
assert(running_thread == NULL); // ... and one to bind them all.
|
||||
running_thread = ¤t; // Even if we change its state to terminate
|
||||
|
@ -558,24 +557,24 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
// increasing the time elapsed of the running thread + process
|
||||
// should be done here as the first thing, instead than
|
||||
// directly after selecting them
|
||||
if(current.get_total_cpu_time() - current.get_elapsed_time() > 0)
|
||||
if (current.get_total_cpu_time() - current.get_elapsed_time() > 0)
|
||||
current.decrease_remaining_time();
|
||||
|
||||
// 2. mark threads that used all their allotted time as terminated
|
||||
if(current.get_total_cpu_time() - current.get_elapsed_time() == 0)
|
||||
if (current.get_total_cpu_time() - current.get_elapsed_time() == 0)
|
||||
current.set_state(Schedulable::state_terminated);
|
||||
}
|
||||
|
||||
// 3. check for simulation termination (we can directly use threads
|
||||
// for this check, since processes' state is based upon threads' one)
|
||||
if( /* we still think that */ simulation_ended &&
|
||||
if ( /* we still think that */ simulation_ended &&
|
||||
(current.get_state() & (Schedulable::state_blocked |
|
||||
Schedulable::state_terminated)) == 0)
|
||||
simulation_ended = false;
|
||||
}
|
||||
|
||||
// 4a. Look for exhausted requests for the running thread
|
||||
if(running_thread != NULL)
|
||||
if (running_thread != NULL)
|
||||
{
|
||||
bool running_terminated = running_thread->get_state() == Schedulable::state_terminated;
|
||||
Extender e(new_snapshot,
|
||||
|
@ -583,17 +582,17 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
running_thread->get_elapsed_time());
|
||||
|
||||
Requests& reqs = running_thread->get_dynamic_requests();
|
||||
for(Requests::iterator r_it = reqs.begin(); r_it != reqs.end(); r_it++)
|
||||
for (Requests::iterator r_it = reqs.begin(); r_it != reqs.end(); r_it++)
|
||||
e.extendRequest(**r_it);
|
||||
}
|
||||
|
||||
// Unblock blocked threads.. by discovering just-now-allocable requests
|
||||
for(Threads::iterator it = all_threads.begin(); it != all_threads.end(); it++)
|
||||
for (Threads::iterator it = all_threads.begin(); it != all_threads.end(); it++)
|
||||
{
|
||||
DynamicThread& current = **it;
|
||||
|
||||
// for each still blocked thread
|
||||
if(current.get_state() == Schedulable::state_blocked)
|
||||
if (current.get_state() == Schedulable::state_blocked)
|
||||
{
|
||||
// Since it was blocked then one and only one (why?) request is unallocable.
|
||||
// lets' find it and see if our information is outdated (i.e. now it is
|
||||
|
@ -602,7 +601,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
// for each request
|
||||
Requests& reqs = current.get_dynamic_requests();
|
||||
Extender e(new_snapshot, Extender::walk_to_advance, current.get_elapsed_time());
|
||||
for(Requests::iterator r_it = reqs.begin(); r_it != reqs.end() && !blocked; r_it++)
|
||||
for (Requests::iterator r_it = reqs.begin(); r_it != reqs.end() && !blocked; r_it++)
|
||||
{
|
||||
// update its state.
|
||||
e.extendRequest(**r_it);
|
||||
|
@ -620,7 +619,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
// ---------- FIXME ----------------
|
||||
// Check correctness: Now if the simulation ended we
|
||||
// append the newly created environment and return false
|
||||
if(simulation_ended) goto final_cleanup;
|
||||
if (simulation_ended) goto final_cleanup;
|
||||
|
||||
|
||||
bool preemptible_policy;
|
||||
|
@ -639,7 +638,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
// ?. See if old running_thread has to be put to ready state
|
||||
// This happens when the policy makes use of preemptability by
|
||||
// priority, or when a time slice ended
|
||||
if(running_thread != NULL && running_thread->get_state() == Schedulable::state_running &&
|
||||
if (running_thread != NULL && running_thread->get_state() == Schedulable::state_running &&
|
||||
(preemptible_policy ||
|
||||
time_slice == current_instant - running_thread->get_last_acquisition()) )
|
||||
{
|
||||
|
@ -671,7 +670,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
found = true;
|
||||
// the thread may block on raising a request
|
||||
Requests& reqs = running_thread->get_dynamic_requests();
|
||||
for(Requests::iterator r_it = reqs.begin(); r_it != reqs.end()
|
||||
for (Requests::iterator r_it = reqs.begin(); r_it != reqs.end()
|
||||
&& running_thread->get_state() != Schedulable::state_blocked; r_it++)
|
||||
{
|
||||
Extender e(new_snapshot, Extender::walk_to_allocate_cpu, running_thread->get_elapsed_time());
|
||||
|
@ -686,7 +685,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
|
||||
// if the old running thread may not directly continue, pick from the ready queue.
|
||||
//int debug = 1000;
|
||||
while(_ready_queue->size() != 0 && !found)//&& debug-- > 0);
|
||||
while (_ready_queue->size() != 0 && !found)//&& debug-- > 0);
|
||||
{
|
||||
// try with the first on the queue
|
||||
found = true;
|
||||
|
@ -694,7 +693,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
|
||||
|
||||
Requests& reqs = candidate.get_dynamic_requests();
|
||||
for(Requests::iterator r_it = reqs.begin(); r_it != reqs.end(); r_it++)
|
||||
for (Requests::iterator r_it = reqs.begin(); r_it != reqs.end(); r_it++)
|
||||
{
|
||||
Extender e(new_snapshot, Extender::walk_to_allocate_cpu, candidate.get_elapsed_time());
|
||||
e.extendRequest(**r_it);
|
||||
|
@ -726,7 +725,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
|
||||
|
||||
} // end of try
|
||||
catch(UserInterruptException& e)
|
||||
catch (UserInterruptException& e)
|
||||
{
|
||||
// Reset values that the policy doesn't need anymore
|
||||
_policy = NULL;
|
||||
|
@ -740,7 +739,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
throw;
|
||||
}
|
||||
|
||||
final_cleanup:
|
||||
final_cleanup:
|
||||
|
||||
// append the new snapshot...
|
||||
// ...and remember to release the auto_ptr!
|
||||
|
|
|
@ -26,5 +26,4 @@ using namespace sgpem;
|
|||
|
||||
SerializerError::SerializerError(const std::string& what) :
|
||||
std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
|
|
@ -31,7 +31,8 @@ namespace sgpem
|
|||
{
|
||||
public:
|
||||
SerializerError(const std::string& what);
|
||||
}; //~ class SerializerError
|
||||
}
|
||||
; //~ class SerializerError
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ SerializersGatekeeper::register_serializer(Serializer* serializer)
|
|||
|
||||
SerializerIterator end = _registered.end();
|
||||
|
||||
if(find(_registered.begin(), end, serializer) == end)
|
||||
if (find(_registered.begin(), end, serializer) == end)
|
||||
_registered.push_back(serializer);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ SerializersGatekeeper::unregister_serializer(Serializer* serializer)
|
|||
SerializerIterator end = _registered.end();
|
||||
SerializerIterator pos = find(_registered.begin(), end, serializer);
|
||||
|
||||
if(pos != end)
|
||||
if (pos != end)
|
||||
{
|
||||
_registered.erase(pos);
|
||||
}
|
||||
|
|
|
@ -30,8 +30,7 @@ template class SG_DLLEXPORT Singleton<ConcreteSimulation>;
|
|||
|
||||
|
||||
Simulation::~Simulation()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Simulation&
|
||||
Simulation::get_instance()
|
||||
|
|
|
@ -44,7 +44,7 @@ StaticProcess::get_total_cpu_time() const
|
|||
typedef std::vector<StaticThread*>::const_iterator ThreadIterator;
|
||||
|
||||
unsigned int result = 0;
|
||||
for(ThreadIterator it = _threads.begin(); it != _threads.end(); it++)
|
||||
for (ThreadIterator it = _threads.begin(); it != _threads.end(); it++)
|
||||
result += (*it)->get_total_cpu_time();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -30,24 +30,24 @@ namespace sgpem
|
|||
{
|
||||
|
||||
/* Force template instantiation to allow visibility outside this DSO */
|
||||
template SG_DLLEXPORT int string_to<int>(const Glib::ustring&);
|
||||
template SG_DLLEXPORT float string_to<float>(const Glib::ustring&);
|
||||
template SG_DLLEXPORT int string_to<int>(const Glib::ustring&);
|
||||
template SG_DLLEXPORT float string_to<float>(const Glib::ustring&);
|
||||
|
||||
// Specialized further down in this file:
|
||||
// template SG_DLLEXPORT bool string_to<bool>(const Glib::ustring&);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
\brief A function that converts a Unicode string to an integer value
|
||||
|
||||
The string can contain ONLY digits and the "minus" character.
|
||||
|
||||
\returns TRUE if the string is well formatted
|
||||
\returns FALSE otherwise
|
||||
*/
|
||||
bool
|
||||
string_to_int(const ustring& str, int& num)
|
||||
{
|
||||
*/
|
||||
bool
|
||||
string_to_int(const ustring& str, int& num)
|
||||
{
|
||||
static const ustring allvalid = "0123456789-";
|
||||
static const ustring digits = "0123456789";
|
||||
|
||||
|
@ -78,13 +78,13 @@ string_to_int(const ustring& str, int& num)
|
|||
if (start == 1)
|
||||
num *= -1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
string_to(const ustring& str) throw(domain_error)
|
||||
{
|
||||
if(tokenize(str).size() != 1)
|
||||
template <typename T>
|
||||
T
|
||||
string_to(const ustring& str) throw(domain_error)
|
||||
{
|
||||
if (tokenize(str).size() != 1)
|
||||
throw domain_error(_("too few or too many tokens"));
|
||||
|
||||
istringstream iss(str);
|
||||
|
@ -97,7 +97,7 @@ string_to(const ustring& str) throw(domain_error)
|
|||
{
|
||||
iss >> value;
|
||||
}
|
||||
catch(ios_base::failure e)
|
||||
catch (ios_base::failure e)
|
||||
{
|
||||
throw domain_error(e.what());
|
||||
}
|
||||
|
@ -106,17 +106,17 @@ string_to(const ustring& str) throw(domain_error)
|
|||
// how useless!!!
|
||||
iss.exceptions(ios_base::goodbit);
|
||||
|
||||
if(iss.peek() != istringstream::traits_type::eof())
|
||||
if (iss.peek() != istringstream::traits_type::eof())
|
||||
throw domain_error(_("incorrect number format"));
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
SG_DLLEXPORT bool
|
||||
string_to<bool>(const Glib::ustring& str) throw(domain_error)
|
||||
{
|
||||
if(tokenize(str).size() != 1)
|
||||
template <>
|
||||
SG_DLLEXPORT bool
|
||||
string_to<bool>(const Glib::ustring& str) throw(domain_error)
|
||||
{
|
||||
if (tokenize(str).size() != 1)
|
||||
throw domain_error(_("too few or too many tokens"));
|
||||
|
||||
istringstream iss(str);
|
||||
|
@ -129,7 +129,7 @@ string_to<bool>(const Glib::ustring& str) throw(domain_error)
|
|||
{
|
||||
iss >> boolalpha >> value;
|
||||
}
|
||||
catch(ios_base::failure e)
|
||||
catch (ios_base::failure e)
|
||||
{
|
||||
throw domain_error(e.what());
|
||||
}
|
||||
|
@ -138,18 +138,18 @@ string_to<bool>(const Glib::ustring& str) throw(domain_error)
|
|||
// how useless!!!
|
||||
iss.exceptions(ios_base::goodbit);
|
||||
|
||||
if(iss.peek() != istringstream::traits_type::eof())
|
||||
if (iss.peek() != istringstream::traits_type::eof())
|
||||
throw domain_error(_("incorrect boolean"));
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
\brief A function that converts an integer value to an Unicode string
|
||||
*/
|
||||
void
|
||||
int_to_string(const int& num, ustring& str)
|
||||
{
|
||||
void
|
||||
int_to_string(const int& num, ustring& str)
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
str = '0';
|
||||
|
@ -171,41 +171,41 @@ int_to_string(const int& num, ustring& str)
|
|||
}
|
||||
if (negative)
|
||||
str = '-' + str;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
float_to_string(const float& f, Glib::ustring& str)
|
||||
{
|
||||
void
|
||||
float_to_string(const float& f, Glib::ustring& str)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << f;
|
||||
char p[20];
|
||||
ss.getline(p, 20);
|
||||
str = p;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
string_to_float(const Glib::ustring& str, float& f)
|
||||
{
|
||||
void
|
||||
string_to_float(const Glib::ustring& str, float& f)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << str;
|
||||
ss >> f;
|
||||
}
|
||||
}
|
||||
|
||||
// helper function for tokenize()
|
||||
static void
|
||||
add_token(Tokens& tokens, const ustring& token)
|
||||
{
|
||||
if(token.size() > 0)
|
||||
static void
|
||||
add_token(Tokens& tokens, const ustring& token)
|
||||
{
|
||||
if (token.size() > 0)
|
||||
tokens.push_back(token);
|
||||
}
|
||||
}
|
||||
|
||||
Tokens
|
||||
tokenize(const ustring& str)
|
||||
{
|
||||
Tokens
|
||||
tokenize(const ustring& str)
|
||||
{
|
||||
istringstream iss(str);
|
||||
Tokens tokens;
|
||||
|
||||
while(iss)
|
||||
while (iss)
|
||||
{
|
||||
ustring token;
|
||||
iss >> token;
|
||||
|
@ -218,7 +218,7 @@ tokenize(const ustring& str)
|
|||
{
|
||||
index = token.find('=');
|
||||
|
||||
if(index != ustring::npos)
|
||||
if (index != ustring::npos)
|
||||
{
|
||||
add_token(tokens, token.substr(0, index));
|
||||
add_token(tokens, "=");
|
||||
|
@ -227,12 +227,12 @@ tokenize(const ustring& str)
|
|||
token = token.substr(index + 1, token.size());
|
||||
}
|
||||
}
|
||||
while(index != ustring::npos);
|
||||
while (index != ustring::npos);
|
||||
|
||||
add_token(tokens, token);
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ using namespace sgpem;
|
|||
|
||||
CairoElements::CairoElements(cairo_t* const ctx)
|
||||
: _ctx(ctx)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
|
@ -62,8 +61,8 @@ CairoElements::draw_3dsphere(const Point& center, float radius, const Color& cl)
|
|||
cairo_pattern_add_color_stop_rgba(grad, 1, r - .4, g - .4, b - .4, 1);
|
||||
cairo_pattern_add_color_stop_rgba(grad, 0, r, g, b, .7);
|
||||
cairo_set_source(cr, grad);
|
||||
cairo_translate(cr, x*.2, (y + radius*8/9) * 1/3);
|
||||
cairo_scale(cr, .8, 2./3);
|
||||
cairo_translate(cr, x*.2, (y + radius*8 / 9) * 1 / 3);
|
||||
cairo_scale(cr, .8, 2. / 3);
|
||||
cairo_arc(cr, x, y, radius, 0, 2*M_PI);
|
||||
cairo_fill(cr);
|
||||
cairo_pattern_destroy(grad);
|
||||
|
@ -75,8 +74,8 @@ CairoElements::draw_3dsphere(const Point& center, float radius, const Color& cl)
|
|||
cairo_pattern_add_color_stop_rgba(grad, 0, 1, 1, 1, .9);
|
||||
cairo_pattern_add_color_stop_rgba(grad, 1, 1, 1, 1, .2);
|
||||
cairo_set_source(cr, grad);
|
||||
cairo_translate(cr, x * .2, (y - radius*8/9) * 1/3);
|
||||
cairo_scale(cr, .8, 2./3);
|
||||
cairo_translate(cr, x * .2, (y - radius*8 / 9) * 1 / 3);
|
||||
cairo_scale(cr, .8, 2. / 3);
|
||||
cairo_arc(cr, x, y, radius, 0, 2*M_PI);
|
||||
cairo_fill(cr);
|
||||
cairo_pattern_destroy(grad);
|
||||
|
@ -113,14 +112,14 @@ CairoElements::draw_container(const Rectangle& area)
|
|||
cairo_move_to(cr, x0 + corner_radius, y0);
|
||||
|
||||
// NW -> NE
|
||||
cairo_line_to(cr, x0+w - corner_radius, y0);
|
||||
cairo_curve_to(cr, x0+w, y0, x0+w, y0, x0+w, y0 + corner_radius);
|
||||
cairo_line_to(cr, x0 + w - corner_radius, y0);
|
||||
cairo_curve_to(cr, x0 + w, y0, x0 + w, y0, x0 + w, y0 + corner_radius);
|
||||
// NE -> SE
|
||||
cairo_line_to(cr, x0+w, y0+h - corner_radius);
|
||||
cairo_curve_to(cr, x0+w, y0+h, x0+w, y0+h, x0+w - corner_radius, y0+h);
|
||||
cairo_line_to(cr, x0 + w, y0 + h - corner_radius);
|
||||
cairo_curve_to(cr, x0 + w, y0 + h, x0 + w, y0 + h, x0 + w - corner_radius, y0 + h);
|
||||
// SE -> SW
|
||||
cairo_line_to(cr, x0 + corner_radius, y0+h);
|
||||
cairo_curve_to(cr, x0, y0+h, x0, y0+h, x0, y0+h - corner_radius);
|
||||
cairo_line_to(cr, x0 + corner_radius, y0 + h);
|
||||
cairo_curve_to(cr, x0, y0 + h, x0, y0 + h, x0, y0 + h - corner_radius);
|
||||
// SW -> NW
|
||||
cairo_line_to(cr, x0, y0 + corner_radius);
|
||||
cairo_curve_to(cr, x0, y0, x0, y0, x0 + corner_radius, y0);
|
||||
|
@ -158,14 +157,14 @@ CairoElements::draw_expandable(const Rectangle& area, bool expanded)
|
|||
cairo_set_source_rgb(cr, 0, 0, 0);
|
||||
cairo_stroke(cr);
|
||||
|
||||
cairo_move_to(cr, x0 + w/10, y0 + h/2);
|
||||
cairo_line_to(cr, x0 + w*9/10, y0 + h/2);
|
||||
cairo_move_to(cr, x0 + w / 10, y0 + h / 2);
|
||||
cairo_line_to(cr, x0 + w*9 / 10, y0 + h / 2);
|
||||
cairo_stroke(cr);
|
||||
|
||||
if(!expanded)
|
||||
if (!expanded)
|
||||
{
|
||||
cairo_move_to(cr, x0 + w/2, y0 + h/10);
|
||||
cairo_line_to(cr, x0 + w/2, y0 + h*9/10);
|
||||
cairo_move_to(cr, x0 + w / 2, y0 + h / 10);
|
||||
cairo_line_to(cr, x0 + w / 2, y0 + h*9 / 10);
|
||||
cairo_stroke(cr);
|
||||
}
|
||||
|
||||
|
@ -175,12 +174,10 @@ CairoElements::draw_expandable(const Rectangle& area, bool expanded)
|
|||
|
||||
Rectangle draw_thread_status(const Point& top_left_crn,
|
||||
const Thread& thread_info)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
Rectangle draw_process_status(const Point& top_left_crn,
|
||||
const Process& process_info)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ CairoWidget::update(const History& history)
|
|||
{
|
||||
// get_window() returns a null pointer
|
||||
// if the widget has not been realized
|
||||
if(!is_realized())
|
||||
if (!is_realized())
|
||||
return; // Nowhere to draw to.
|
||||
|
||||
// Determine the final height before to start drawing
|
||||
|
@ -89,7 +89,7 @@ CairoWidget::update(const History& history)
|
|||
void
|
||||
CairoWidget::on_realize()
|
||||
{
|
||||
if(is_realized()) return;
|
||||
if (is_realized()) return;
|
||||
|
||||
Gtk::Widget::on_realize();
|
||||
ensure_style();
|
||||
|
@ -140,7 +140,7 @@ CairoWidget::on_size_allocate(const Gtk::Allocation& allocation)
|
|||
{
|
||||
set_allocation(allocation);
|
||||
|
||||
if(is_realized())
|
||||
if (is_realized())
|
||||
get_window()->move_resize(allocation.get_x(), allocation.get_y(),
|
||||
allocation.get_width(), allocation.get_height());
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ CairoWidget::on_size_allocate(const Gtk::Allocation& allocation)
|
|||
bool
|
||||
CairoWidget::on_expose_event(GdkEventExpose* event)
|
||||
{
|
||||
if(event == NULL || event->count > 0)
|
||||
if (event == NULL || event->count > 0)
|
||||
return false;
|
||||
|
||||
// calculated dinamically:
|
||||
|
@ -159,7 +159,7 @@ CairoWidget::on_expose_event(GdkEventExpose* event)
|
|||
// Clip to redraw only the smallest possible area
|
||||
// Use double buffering or we're CPU-dead
|
||||
// Copy from the buffer to the screen
|
||||
if(_buf)
|
||||
if (_buf)
|
||||
get_window()->draw_drawable(get_style()->get_black_gc(), _buf,
|
||||
event->area.x, event->area.y,
|
||||
event->area.x, event->area.y,
|
||||
|
|
|
@ -81,8 +81,7 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
|
|||
|
||||
|
||||
GuiBuilder::~GuiBuilder()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
Gtk::Window&
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
/** \brief This class initialize and starts the whole GUI
|
||||
|
||||
*/
|
||||
namespace sgpem {
|
||||
namespace sgpem
|
||||
{
|
||||
|
||||
class GuiBuilder
|
||||
{
|
||||
|
|
|
@ -102,11 +102,11 @@ parse_options(int argc, char** argv)
|
|||
|
||||
GlobalPreferences& prefs = GlobalPreferences::get_instance();
|
||||
|
||||
for(Glib::OptionGroup::vecustrings::const_iterator it = policies_dir_val.begin();
|
||||
for (Glib::OptionGroup::vecustrings::const_iterator it = policies_dir_val.begin();
|
||||
it != policies_dir_val.end(); ++it)
|
||||
prefs.add_policies_dir(*it);
|
||||
|
||||
for(Glib::OptionGroup::vecustrings::const_iterator it = modules_dir_val.begin();
|
||||
for (Glib::OptionGroup::vecustrings::const_iterator it = modules_dir_val.begin();
|
||||
it != modules_dir_val.end(); ++it)
|
||||
prefs.add_modules_dir(*it);
|
||||
|
||||
|
@ -115,16 +115,16 @@ parse_options(int argc, char** argv)
|
|||
// initialize plugins, too
|
||||
vector<Module*> modules = PluginManager::get_instance().get_module_list();
|
||||
|
||||
for(vector<Module*>::iterator it = modules.begin(); it != modules.end(); ++it)
|
||||
for (vector<Module*>::iterator it = modules.begin(); it != modules.end(); ++it)
|
||||
(*it)->set_enabled(true);
|
||||
|
||||
vector<CPUPolicyManager*> managers = CPUPoliciesGatekeeper::get_instance().get_registered();
|
||||
|
||||
for(vector<CPUPolicyManager*>::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
for (vector<CPUPolicyManager*>::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
(*it)->init();
|
||||
|
||||
|
||||
if(no_gui_enabled)
|
||||
if (no_gui_enabled)
|
||||
{
|
||||
// We don't return to main, instead we
|
||||
// initialize the command line version
|
||||
|
@ -133,7 +133,7 @@ parse_options(int argc, char** argv)
|
|||
std::string str;
|
||||
|
||||
std::cout << std::endl << "% ";
|
||||
while(getline(std::cin, str))
|
||||
while (getline(std::cin, str))
|
||||
{
|
||||
// Enter main loop
|
||||
TextSimulation::parse_command(sim, str);
|
||||
|
@ -143,14 +143,14 @@ parse_options(int argc, char** argv)
|
|||
else
|
||||
{
|
||||
GuiBuilder* gui = new GuiBuilder();
|
||||
if(fnames.begin() != fnames.end())
|
||||
if (fnames.begin() != fnames.end())
|
||||
gui->open_file(*fnames.begin());
|
||||
main_loop.run(gui->get_initial_window());
|
||||
delete gui;
|
||||
}
|
||||
|
||||
} // ~ try
|
||||
catch(Glib::OptionError e)
|
||||
catch (Glib::OptionError e)
|
||||
{
|
||||
std::cout << _("Bad invocation: ") << e.what() << std::endl;
|
||||
std::cout << _("Use the `-?' or `--help' option to see the help") << std::endl;
|
||||
|
|
|
@ -29,13 +29,11 @@ using namespace sgpem;
|
|||
|
||||
SchedulablesWidget::SchedulablesWidget()
|
||||
: Glib::ObjectBase("sgpem_SchedulablesWidget"), CairoWidget()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
SchedulablesWidget::~SchedulablesWidget()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
|
|
|
@ -34,8 +34,8 @@ template<typename Instantiated_class>
|
|||
Instantiated_class&
|
||||
sgpem::Singleton<Instantiated_class>::get_instance()
|
||||
{
|
||||
Glib::RecMutex::Lock lock(_mutex);
|
||||
if(_instance == NULL)
|
||||
Glib::RecMutex::Lock lock (_mutex);
|
||||
if (_instance == NULL)
|
||||
_instance = new Instantiated_class();
|
||||
return *_instance;
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ namespace memory
|
|||
template<typename T, bool isArray>
|
||||
smart_ptr<T, isArray>::~smart_ptr() throw()
|
||||
{
|
||||
if(--(_contents->rc) == 0)
|
||||
if (--(_contents->rc) == 0)
|
||||
{
|
||||
if(_contents->ptr != 0)
|
||||
if (_contents->ptr != 0)
|
||||
!isArray ? delete _contents->ptr : delete [] _contents->ptr;
|
||||
delete _contents;
|
||||
}
|
||||
|
@ -61,11 +61,11 @@ namespace memory
|
|||
smart_ptr<T, isArray>&
|
||||
smart_ptr<T, isArray>::operator=(const smart_ptr& sptr) throw()
|
||||
{
|
||||
if(this != &sptr && _contents != sptr._contents)
|
||||
if (this != &sptr && _contents != sptr._contents)
|
||||
{
|
||||
if(--(_contents->rc) == 0)
|
||||
if (--(_contents->rc) == 0)
|
||||
{
|
||||
if(_contents->ptr != 0)
|
||||
if (_contents->ptr != 0)
|
||||
!isArray ? delete _contents->ptr : delete [] _contents->ptr;
|
||||
delete _contents;
|
||||
}
|
||||
|
@ -165,11 +165,11 @@ namespace memory
|
|||
smart_ptr<T, isArray>::smart_ptr(const smart_ptr<U, isArray>& sptr)
|
||||
throw(std::bad_cast)
|
||||
{
|
||||
if(!sptr._contents->ptr || dynamic_cast<T*>(sptr._contents->ptr) == 0)
|
||||
if (!sptr._contents->ptr || dynamic_cast<T*>(sptr._contents->ptr) == 0)
|
||||
throw std::bad_cast();
|
||||
|
||||
// I know, I know... this is Evil(TM):
|
||||
_contents = reinterpret_cast<typename smart_ptr<T, isArray>::contents_type*>(sptr._contents);
|
||||
_contents = reinterpret_cast<typename smart_ptr<T, isArray>::contents_type* > (sptr._contents);
|
||||
(_contents->rc)++;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
using namespace sgpem;
|
||||
|
||||
|
||||
memory::smart_ptr<sgpem::DynamicSchedulable>
|
||||
History::get_scheduled_at(int time) const
|
||||
{
|
||||
memory::smart_ptr<sgpem::DynamicSchedulable>
|
||||
History::get_scheduled_at(int time) const
|
||||
{
|
||||
using namespace memory;
|
||||
smart_ptr<DynamicSchedulable> scheduled_at = smart_ptr<DynamicSchedulable>();
|
||||
if (0 <= time && time <= _total_time_elapsed)
|
||||
|
@ -45,18 +45,18 @@ using namespace sgpem;
|
|||
}
|
||||
}
|
||||
return scheduled_at;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
memory::smart_ptr<sgpem::ReadyQueue>
|
||||
History::get_simulation_status_at(int time) const
|
||||
{
|
||||
memory::smart_ptr<sgpem::ReadyQueue>
|
||||
History::get_simulation_status_at(int time) const
|
||||
{
|
||||
using namespace memory;
|
||||
smart_ptr<ReadyQueue> simulation_status_at = smart_ptr<ReadyQueue>();
|
||||
if (0 <= time && time <= _total_time_elapsed)
|
||||
{
|
||||
if (_slice == memory::smart_ptr<Slice>())
|
||||
std::cout<<"History::get_simulation_status_at.NULL.error";
|
||||
std::cout << "History::get_simulation_status_at.NULL.error";
|
||||
else
|
||||
simulation_status_at = memory::smart_ptr<ReadyQueue>
|
||||
(
|
||||
|
@ -67,47 +67,47 @@ using namespace sgpem;
|
|||
);
|
||||
}
|
||||
return simulation_status_at;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
History::get_current_time() const
|
||||
{
|
||||
int
|
||||
History::get_current_time() const
|
||||
{
|
||||
return _total_time_elapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
History::enqueue_slice(const sgpem::ReadyQueue& status)
|
||||
{
|
||||
void
|
||||
History::enqueue_slice(const sgpem::ReadyQueue& status)
|
||||
{
|
||||
_slice = memory::smart_ptr<Slice>(new Slice(_total_time_elapsed, 1, status));
|
||||
_total_time_elapsed++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
History::truncate_at(int instant)
|
||||
{
|
||||
void
|
||||
History::truncate_at(int instant)
|
||||
{
|
||||
//std::cout << "\nRecreating a Singleton History";
|
||||
_slice = memory::smart_ptr<Slice>();
|
||||
_total_time_elapsed = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
History&
|
||||
History::get_instance()
|
||||
{
|
||||
History&
|
||||
History::get_instance()
|
||||
{
|
||||
if (History::_instance == NULL)
|
||||
History::_instance = new History();
|
||||
return *History::_instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
History::History()
|
||||
{
|
||||
History::History()
|
||||
{
|
||||
_slice = memory::smart_ptr<Slice>();
|
||||
_total_time_elapsed = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
History * History::_instance = NULL;
|
||||
History * History::_instance = NULL;
|
||||
|
|
|
@ -33,19 +33,19 @@ PolicyManager::get_registered_manager()
|
|||
return *_registered;
|
||||
}
|
||||
|
||||
Policy&
|
||||
Policy&
|
||||
PolicyManager::get_policy()
|
||||
{
|
||||
return PRRPolicy::get_instance();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
PolicyManager::init()
|
||||
{}
|
||||
|
||||
PolicyManager::~PolicyManager()
|
||||
PolicyManager::~PolicyManager()
|
||||
{
|
||||
if(_registered == this) _registered = NULL;
|
||||
if (_registered == this) _registered = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ PRRPolicy::PRRPolicy(int quantum)
|
|||
Policy&
|
||||
PRRPolicy::get_instance()
|
||||
{
|
||||
if(_instance == NULL) _instance = new PRRPolicy(3); // quantum size
|
||||
if (_instance == NULL) _instance = new PRRPolicy(3); // quantum size
|
||||
return *_instance;
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ PRRPolicy::get_instance()
|
|||
PRRPolicy::~PRRPolicy()
|
||||
{}
|
||||
|
||||
void
|
||||
void
|
||||
PRRPolicy::configure()
|
||||
throw(UserInterruptException)
|
||||
throw(UserInterruptException)
|
||||
{}
|
||||
|
||||
void
|
||||
void
|
||||
PRRPolicy::sort_queue() const
|
||||
throw(UserInterruptException)
|
||||
throw(UserInterruptException)
|
||||
{
|
||||
ReadyQueue* local_sl = Scheduler::get_instance().get_ready_queue();
|
||||
for (uint useless = 0; useless < local_sl->size(); useless++)
|
||||
|
@ -64,54 +64,54 @@ PRRPolicy::sort_queue() const
|
|||
local_sl->swap(i, i + 1);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
PRRPolicy::activate()
|
||||
{}
|
||||
|
||||
void
|
||||
void
|
||||
PRRPolicy::deactivate()
|
||||
{}
|
||||
|
||||
int
|
||||
int
|
||||
PRRPolicy::get_id() const
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
sgpem::policy_sorts_type
|
||||
sgpem::policy_sorts_type
|
||||
PRRPolicy::wants() const
|
||||
throw(UserInterruptException)
|
||||
throw(UserInterruptException)
|
||||
{
|
||||
return policy_sorts_processes;
|
||||
}
|
||||
|
||||
Glib::ustring
|
||||
Glib::ustring
|
||||
PRRPolicy::get_name() const
|
||||
{
|
||||
return "42";
|
||||
}
|
||||
|
||||
Glib::ustring
|
||||
Glib::ustring
|
||||
PRRPolicy::get_description() const
|
||||
{
|
||||
return "42";
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
PRRPolicy::is_pre_emptive() const
|
||||
throw(UserInterruptException)
|
||||
throw(UserInterruptException)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
PRRPolicy::get_time_slice() const
|
||||
throw(UserInterruptException)
|
||||
throw(UserInterruptException)
|
||||
{
|
||||
return _quantum;
|
||||
}
|
||||
|
||||
PolicyParameters&
|
||||
PolicyParameters&
|
||||
PRRPolicy::get_parameters()
|
||||
{
|
||||
return _parameters;
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
// from here and further until the bottom, all to throw away I suppose
|
||||
|
||||
int
|
||||
main(int argc, char** argv) {
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
|
||||
using namespace sgpem;
|
||||
using Glib::ustring;
|
||||
|
@ -42,7 +43,7 @@ main(int argc, char** argv) {
|
|||
|
||||
GlobalPreferences& gp = GlobalPreferences::get_instance();
|
||||
|
||||
if(argc<2)
|
||||
if (argc < 2)
|
||||
{
|
||||
cout << "GlobalPreferences serialization test program" << endl;
|
||||
cout << "Syntax: test-global_preferences_serialization [mod1 mod2 ...][% pol1 pol2 ...]" << endl << endl;
|
||||
|
@ -51,14 +52,14 @@ main(int argc, char** argv) {
|
|||
<< ", read it and compare with saved one." << endl << endl;
|
||||
}
|
||||
|
||||
int i=1;
|
||||
while(i<argc && (*argv[i]!='%'))
|
||||
int i = 1;
|
||||
while (i < argc && (*argv[i] != '%'))
|
||||
{
|
||||
gp.add_modules_dir( Glib::ustring(argv[i]) );
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
while(i<argc)
|
||||
while (i < argc)
|
||||
{
|
||||
gp.add_policies_dir( Glib::ustring(argv[i]) );
|
||||
i++;
|
||||
|
@ -78,14 +79,14 @@ main(int argc, char** argv) {
|
|||
gp.write_configrc(os1);
|
||||
|
||||
|
||||
i=1;
|
||||
while(i<argc && (*argv[i]!='%'))
|
||||
i = 1;
|
||||
while (i < argc && (*argv[i] != '%'))
|
||||
{
|
||||
gp.add_modules_dir( Glib::ustring("bis-") + Glib::ustring(argv[i]) );
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
while(i<argc)
|
||||
while (i < argc)
|
||||
{
|
||||
gp.add_policies_dir( Glib::ustring("bis-") + Glib::ustring(argv[i]) );
|
||||
i++;
|
||||
|
@ -108,12 +109,12 @@ main(int argc, char** argv) {
|
|||
cout << "Preferences writed into os3 (t3)" << endl << endl;
|
||||
gp.write_configrc(os3);
|
||||
|
||||
cout << "Comparing dump of (t1) and (t2): " << (os1.str()==os2.str()?"equals":"not equals") << endl;
|
||||
cout << "Comparing dump of (t1) and (t3): " << (os1.str()==os3.str()?"equals":"not equals") << endl;
|
||||
cout << "Comparing dump of (t1) and (t2): " << (os1.str() == os2.str() ? "equals" : "not equals") << endl;
|
||||
cout << "Comparing dump of (t1) and (t3): " << (os1.str() == os3.str() ? "equals" : "not equals") << endl;
|
||||
|
||||
int ret = 1;
|
||||
if(os1.str()!=os2.str()
|
||||
&& os1.str()==os3.str())
|
||||
if (os1.str() != os2.str()
|
||||
&& os1.str() == os3.str())
|
||||
{
|
||||
cout << "test successful" << endl;
|
||||
ret = 0;
|
||||
|
|
|
@ -42,7 +42,7 @@ using Glib::ustring;
|
|||
// it is updated
|
||||
class DummyObserver : public HistoryObserver
|
||||
{
|
||||
public:
|
||||
public:
|
||||
DummyObserver() : _i(0) {}
|
||||
void update(const History& history)
|
||||
{
|
||||
|
@ -96,15 +96,15 @@ find_thread(ConcreteEnvironment& env, Thread& _thread)
|
|||
Environment::Processes& processes = env.get_processes();
|
||||
|
||||
// please forgive me, I'm sick of using iterators...
|
||||
for(unsigned int i = 0; i < processes.size(); ++i)
|
||||
for (unsigned int i = 0; i < processes.size(); ++i)
|
||||
{
|
||||
Process& p = *processes[i];
|
||||
vector<Thread*> threads = p.get_threads();
|
||||
|
||||
for(unsigned int j = 0; j < threads.size(); ++j)
|
||||
for (unsigned int j = 0; j < threads.size(); ++j)
|
||||
{
|
||||
DynamicThread& t = (DynamicThread&)*threads[j];
|
||||
if(t == thread)
|
||||
DynamicThread& t = (DynamicThread&) * threads[j];
|
||||
if (t == thread)
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
@ -119,15 +119,15 @@ find_thread(const ConcreteEnvironment& env, const Thread& _thread)
|
|||
const Environment::Processes& processes = env.get_processes();
|
||||
|
||||
// please forgive me, I'm sick of using iterators...
|
||||
for(unsigned int i = 0; i < processes.size(); ++i)
|
||||
for (unsigned int i = 0; i < processes.size(); ++i)
|
||||
{
|
||||
const Process& p = *processes[i];
|
||||
vector<const Thread*> threads = p.get_threads();
|
||||
|
||||
for(unsigned int j = 0; j < threads.size(); ++j)
|
||||
for (unsigned int j = 0; j < threads.size(); ++j)
|
||||
{
|
||||
const DynamicThread& t = (const DynamicThread&)*threads[j];
|
||||
if(t == thread)
|
||||
const DynamicThread& t = (const DynamicThread&) * threads[j];
|
||||
if (t == thread)
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Checking if it contains only one Environment... ";
|
||||
|
||||
if(h.get_size() == 1)
|
||||
if (h.get_size() == 1)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -161,7 +161,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Checking if the environment is empty... ";
|
||||
|
||||
if(environment.get_processes().size() == 0 &&
|
||||
if (environment.get_processes().size() == 0 &&
|
||||
environment.get_resources().size() == 0 &&
|
||||
environment.get_sorted_queue().size() == 0)
|
||||
test << "PASS";
|
||||
|
@ -340,7 +340,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Checking if history size is 6... ";
|
||||
|
||||
if(h.get_size() == 6)
|
||||
if (h.get_size() == 6)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -351,7 +351,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Checking if dynamic priority of thread at instant 1 and 5 is different... ";
|
||||
|
||||
if(t1.get_priority_push() != t5.get_priority_push())
|
||||
if (t1.get_priority_push() != t5.get_priority_push())
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -362,7 +362,7 @@ main(int argc, char** argv)
|
|||
test << "Checking if dynamic priority of thread at instant 4, is different ";
|
||||
test << "from that at instant 1 and 5, and equal to the one expected... ";
|
||||
|
||||
if(t4.get_priority_push() != t1.get_priority_push() &&
|
||||
if (t4.get_priority_push() != t1.get_priority_push() &&
|
||||
t4.get_priority_push() != t5.get_priority_push() &&
|
||||
t4.get_priority_push() == priorities[3])
|
||||
test << "PASS";
|
||||
|
@ -379,28 +379,28 @@ main(int argc, char** argv)
|
|||
|
||||
bool subreq_pass = true;
|
||||
|
||||
for(unsigned int i = 0; i < le_processes.size(); ++i)
|
||||
for (unsigned int i = 0; i < le_processes.size(); ++i)
|
||||
{
|
||||
vector<Thread*> threads = le_processes[i]->get_threads();
|
||||
|
||||
for(unsigned int j = 0; j < threads.size(); ++j)
|
||||
for (unsigned int j = 0; j < threads.size(); ++j)
|
||||
{
|
||||
vector<Request*> requests = threads[j]->get_requests();
|
||||
|
||||
for(unsigned int k = 0; k < requests.size(); ++k)
|
||||
for (unsigned int k = 0; k < requests.size(); ++k)
|
||||
{
|
||||
vector<SubRequest*> subrequests = requests[k]->get_subrequests();
|
||||
|
||||
for(unsigned int x = 0; x < subrequests.size(); ++x)
|
||||
for (unsigned int x = 0; x < subrequests.size(); ++x)
|
||||
{
|
||||
if(le_resources.find(subrequests[x]->get_resource_key()) == le_resources.end())
|
||||
if (le_resources.find(subrequests[x]->get_resource_key()) == le_resources.end())
|
||||
subreq_pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(subreq_pass)
|
||||
if (subreq_pass)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -413,7 +413,7 @@ main(int argc, char** argv)
|
|||
h.get_environment_at(6);
|
||||
test << "FAIL";
|
||||
}
|
||||
catch(out_of_range)
|
||||
catch (out_of_range)
|
||||
{
|
||||
test << "PASS";
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Checking if history has size 1 after adding a thread... ";
|
||||
|
||||
if(h.get_size() == 1)
|
||||
if (h.get_size() == 1)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -447,7 +447,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Checking if history has size 1 after removing a resource... ";
|
||||
|
||||
if(h.get_size() == 1)
|
||||
if (h.get_size() == 1)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -465,32 +465,32 @@ main(int argc, char** argv)
|
|||
bool final_bad_match = false;
|
||||
bool final_sreq2_match = false;
|
||||
|
||||
for(unsigned int i = 0; i < final_processes.size(); ++i)
|
||||
for (unsigned int i = 0; i < final_processes.size(); ++i)
|
||||
{
|
||||
DynamicProcess& p = (DynamicProcess&)*final_processes[i];
|
||||
DynamicProcess& p = (DynamicProcess&) * final_processes[i];
|
||||
|
||||
if(!final_p1_match && p == p1)
|
||||
if (!final_p1_match && p == p1)
|
||||
final_p1_match = true;
|
||||
else if(!final_p2_match && p == p2)
|
||||
else if (!final_p2_match && p == p2)
|
||||
final_p2_match = true;
|
||||
else
|
||||
final_bad_match = true;
|
||||
|
||||
vector<DynamicThread*>& threads = p.get_dynamic_threads();
|
||||
|
||||
for(unsigned int j = 0; j < threads.size(); ++j)
|
||||
for (unsigned int j = 0; j < threads.size(); ++j)
|
||||
{
|
||||
vector<DynamicRequest*> requests = threads[j]->get_dynamic_requests();
|
||||
|
||||
for(unsigned int k = 0; k < requests.size(); ++k)
|
||||
for (unsigned int k = 0; k < requests.size(); ++k)
|
||||
{
|
||||
vector<DynamicSubRequest*> subrequests = requests[k]->get_dynamic_subrequests();
|
||||
|
||||
for(unsigned int x = 0; x < subrequests.size(); ++x)
|
||||
for (unsigned int x = 0; x < subrequests.size(); ++x)
|
||||
{
|
||||
// NOTE this will of course fail if the subrequests which should not be here
|
||||
// are still in the environment
|
||||
if(!final_sreq2_match && *subrequests[x] == sreq2)
|
||||
if (!final_sreq2_match && *subrequests[x] == sreq2)
|
||||
final_sreq2_match = true;
|
||||
else
|
||||
final_bad_match = true;
|
||||
|
@ -501,16 +501,16 @@ main(int argc, char** argv)
|
|||
|
||||
typedef Environment::Resources::const_iterator ResourceIt;
|
||||
|
||||
if(final_resources.size() == 1)
|
||||
if (final_resources.size() == 1)
|
||||
{
|
||||
DynamicResource& r = (DynamicResource&)*(final_resources.begin()->second);
|
||||
if(!(r == *res2.second))
|
||||
DynamicResource& r = (DynamicResource&) * (final_resources.begin()->second);
|
||||
if (!(r == *res2.second))
|
||||
final_bad_match = true;
|
||||
}
|
||||
else
|
||||
final_bad_match = true;
|
||||
|
||||
if(!final_bad_match && final_p1_match && final_p2_match && final_sreq2_match)
|
||||
if (!final_bad_match && final_p1_match && final_p2_match && final_sreq2_match)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
@ -528,7 +528,7 @@ main(int argc, char** argv)
|
|||
h.get_environment_at(-17);
|
||||
test << "FAIL";
|
||||
}
|
||||
catch(out_of_range)
|
||||
catch (out_of_range)
|
||||
{
|
||||
test << "PASS";
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ main(int argc, char** argv)
|
|||
|
||||
test << "Internal observer's counter should be 21... ";
|
||||
|
||||
if(observer._i == 21)
|
||||
if (observer._i == 21)
|
||||
test << "PASS";
|
||||
else
|
||||
test << "FAIL";
|
||||
|
|
|
@ -31,14 +31,15 @@
|
|||
// from here and further until the bottom, all to throw away I suppose
|
||||
|
||||
int
|
||||
main(int argc, char** argv) {
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
|
||||
using namespace sgpem;
|
||||
using Glib::ustring;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
if((argc<4) || (argc%2)!=0)
|
||||
if ((argc < 4) || (argc % 2) != 0)
|
||||
{
|
||||
cout << "KeyFile class test program" << endl;
|
||||
cout << "Syntax: test-key_file filename key1 value1 [key2 value2...]" << endl;
|
||||
|
@ -63,7 +64,7 @@ main(int argc, char** argv) {
|
|||
KeyFile kfile_bis;
|
||||
|
||||
// fill KeyFile object
|
||||
for(int index = 2; index<argc; index+=2)
|
||||
for (int index = 2; index < argc; index += 2)
|
||||
{
|
||||
kfile.insert_key_value(Glib::ustring(argv[index]), Glib::ustring(argv[index+1]));
|
||||
}
|
||||
|
@ -76,18 +77,18 @@ main(int argc, char** argv) {
|
|||
|
||||
// compare writed vs. readed data
|
||||
bool ok = true;
|
||||
for(int index = 2; ok && index<argc; index+=2)
|
||||
for (int index = 2; ok && index < argc; index += 2)
|
||||
{
|
||||
Glib::ustring val(argv[index+1]);
|
||||
const Glib::ustring* pt = kfile_bis.search_value(Glib::ustring(argv[index]));
|
||||
if(!pt || (*pt)!=val)
|
||||
if (!pt || (*pt) != val)
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
// output response...
|
||||
if(ok)
|
||||
if (ok)
|
||||
{
|
||||
cout << "Test successful" << endl;
|
||||
return 0;
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace sgpem
|
|||
History&
|
||||
TestHistory::get_instance()
|
||||
{
|
||||
if(!_instance)
|
||||
if (!_instance)
|
||||
_instance = new TestHistory();
|
||||
return *_instance;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace sgpem
|
|||
|
||||
static Policy& get_instance()
|
||||
{
|
||||
if(!_instance) _instance = new Policy(3); // quantum size
|
||||
if (!_instance) _instance = new Policy(3); // quantum size
|
||||
return *_instance;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ namespace sgpem
|
|||
|
||||
PolicyManager::~PolicyManager()
|
||||
{
|
||||
if(_registered == this) _registered = NULL;
|
||||
if (_registered == this) _registered = NULL;
|
||||
}
|
||||
|
||||
PolicyManager&
|
||||
|
@ -199,7 +199,7 @@ namespace sgpem
|
|||
History::get_instance()
|
||||
|
||||
{
|
||||
if(!_instance) _instance = new Policy(3); // quantum size
|
||||
if (!_instance) _instance = new Policy(3); // quantum size
|
||||
return *_instance;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,6 @@ namespace sgpem
|
|||
// this class should invoke the Scheduler Stepforward method.
|
||||
class StepForwardTester
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// from here and further until the bottom, all to throw away I suppose
|
||||
|
|
|
@ -77,8 +77,7 @@ namespace sgpem
|
|||
description(_description), low_bound(_low_bound),
|
||||
up_bound(_up_bound), required(_required), preset(_preset),
|
||||
value(_preset)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
CommandParameter<T>::CommandParameter(const PolicyParameters::Parameter<T>& pparam) :
|
||||
|
@ -86,24 +85,21 @@ namespace sgpem
|
|||
low_bound(pparam.get_lower_bound()),
|
||||
up_bound(pparam.get_upper_bound()), required(pparam.is_required()),
|
||||
preset(pparam.get_default()), value(pparam.get_value())
|
||||
{
|
||||
}
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
TextSimulation::TextSimulation() :
|
||||
_saved(true)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
TextSimulation::~TextSimulation()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
bool
|
||||
TextSimulation::check_arguments_num(const Tokens& arguments, unsigned int num)
|
||||
{
|
||||
if(arguments.size() < num)
|
||||
if (arguments.size() < num)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << _("ERROR: this command requires at least ") << num << _(" arguments\n");
|
||||
|
@ -111,7 +107,7 @@ TextSimulation::check_arguments_num(const Tokens& arguments, unsigned int num)
|
|||
|
||||
return false;
|
||||
}
|
||||
else if(arguments.size() > num)
|
||||
else if (arguments.size() > num)
|
||||
p_stderr(_("WARNING: some arguments will be ignored\n"));
|
||||
|
||||
return true;
|
||||
|
@ -120,12 +116,12 @@ TextSimulation::check_arguments_num(const Tokens& arguments, unsigned int num)
|
|||
bool
|
||||
TextSimulation::unsaved_ask_confirm() const
|
||||
{
|
||||
if(!_saved)
|
||||
if (!_saved)
|
||||
{
|
||||
p_stderr(_("WARNING: Simulation was not recently saved. "
|
||||
"If you continue some changes to the simulation might be lost.\n"));
|
||||
|
||||
for(bool bad_arg = true; bad_arg;)
|
||||
for (bool bad_arg = true; bad_arg;)
|
||||
{
|
||||
p_stdout(_("Continue? [y/n] "));
|
||||
|
||||
|
@ -133,11 +129,11 @@ TextSimulation::unsaved_ask_confirm() const
|
|||
|
||||
Tokens tokens = tokenize(buf);
|
||||
|
||||
if(tokens.size() == 1 && tokens[0].size() == 1)
|
||||
if (tokens.size() == 1 && tokens[0].size() == 1)
|
||||
{
|
||||
if(tokens[0].lowercase() == _("n"))
|
||||
if (tokens[0].lowercase() == _("n"))
|
||||
return false;
|
||||
else if(tokens[0].lowercase() == _("y"))
|
||||
else if (tokens[0].lowercase() == _("y"))
|
||||
bad_arg = false;
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +146,7 @@ template <typename Container>
|
|||
void
|
||||
TextSimulation::show(const Container& entities)
|
||||
{
|
||||
for(unsigned int i = 0; i < entities.size(); ++i)
|
||||
for (unsigned int i = 0; i < entities.size(); ++i)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << i + 1 << ". " << entities[i]->get_name() << endl;
|
||||
|
@ -163,9 +159,9 @@ namespace sgpem
|
|||
{
|
||||
template <>
|
||||
void
|
||||
TextSimulation::show<vector<Request*> >(const vector<Request*>& entities)
|
||||
TextSimulation::show<vector<Request*> > (const vector<Request*>& entities)
|
||||
{
|
||||
for(unsigned int i = 0; i < entities.size(); ++i)
|
||||
for (unsigned int i = 0; i < entities.size(); ++i)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << i + 1 << ". instant: " << entities[i]->get_instant() << endl;
|
||||
|
@ -175,9 +171,9 @@ namespace sgpem
|
|||
|
||||
template <>
|
||||
void
|
||||
TextSimulation::show<vector<SubRequest*> >(const vector<SubRequest*>& entities)
|
||||
TextSimulation::show<vector<SubRequest*> > (const vector<SubRequest*>& entities)
|
||||
{
|
||||
for(unsigned int i = 0; i < entities.size(); ++i)
|
||||
for (unsigned int i = 0; i < entities.size(); ++i)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
|
@ -188,11 +184,11 @@ namespace sgpem
|
|||
|
||||
template <>
|
||||
void
|
||||
TextSimulation::show<map<int, Resource*> >(const map<int, Resource*>& entities)
|
||||
TextSimulation::show<map<int, Resource*> > (const map<int, Resource*>& entities)
|
||||
{
|
||||
typedef map<int, Resource*>::const_iterator ResourceIt;
|
||||
|
||||
for(ResourceIt it = entities.begin(); it != entities.end(); ++it)
|
||||
for (ResourceIt it = entities.begin(); it != entities.end(); ++it)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
|
@ -202,7 +198,7 @@ namespace sgpem
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} //~ namespace sgpem
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
|
@ -216,7 +212,7 @@ TextSimulation::get_parameter(CommandParameter<T>& parameter)
|
|||
|
||||
ostringstream buf;
|
||||
|
||||
if(parameter.required)
|
||||
if (parameter.required)
|
||||
buf << "*";
|
||||
|
||||
buf << parameter.description << " (range: [" << parameter.low_bound << ", " <<
|
||||
|
@ -232,35 +228,35 @@ TextSimulation::get_parameter(CommandParameter<T>& parameter)
|
|||
// to find if it's only composed of white spaces...
|
||||
// Indedeed there's a pro: by using extensively tokenize() we are more sure
|
||||
// it's correct ;-)
|
||||
if(tokenize(input).size() > 0)
|
||||
if (tokenize(input).size() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
value = string_to<T>(input);
|
||||
|
||||
if(value > parameter.up_bound || value < parameter.low_bound)
|
||||
if (value > parameter.up_bound || value < parameter.low_bound)
|
||||
{
|
||||
p_stderr(_("ERROR: Provided value is out of range\n"));
|
||||
correct = false;
|
||||
}
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: Please provide a valid numeric value\n"));
|
||||
correct = false;
|
||||
}
|
||||
|
||||
if(correct)
|
||||
if (correct)
|
||||
parameter.value = value;
|
||||
}
|
||||
else if(parameter.required)
|
||||
else if (parameter.required)
|
||||
{
|
||||
p_stderr(_("ERROR: This is a mandatory attribute; you MUST provide a valid value!\n"));
|
||||
|
||||
correct = false;
|
||||
}
|
||||
}
|
||||
while(!correct);
|
||||
while (!correct);
|
||||
}
|
||||
|
||||
// Specializations need to go explicitly inside the namespace. why?
|
||||
|
@ -272,11 +268,11 @@ namespace sgpem
|
|||
{
|
||||
bool loop = true;
|
||||
|
||||
while(loop)
|
||||
while (loop)
|
||||
{
|
||||
ustring buf;
|
||||
|
||||
if(parameter.required)
|
||||
if (parameter.required)
|
||||
buf += "*";
|
||||
|
||||
p_stdout(buf + parameter.description +
|
||||
|
@ -290,7 +286,7 @@ namespace sgpem
|
|||
// it's correct ;-)
|
||||
Tokens tokens = tokenize(buf);
|
||||
|
||||
if(tokens.size() == 0 && parameter.required)
|
||||
if (tokens.size() == 0 && parameter.required)
|
||||
p_stderr(_("ERROR: This is a mandatory atribute; you MUST provide a valid value!\n"));
|
||||
else
|
||||
{
|
||||
|
@ -313,7 +309,7 @@ namespace sgpem
|
|||
|
||||
ostringstream buf;
|
||||
|
||||
if(parameter.required)
|
||||
if (parameter.required)
|
||||
buf << "*";
|
||||
|
||||
buf << parameter.description <<
|
||||
|
@ -329,25 +325,25 @@ namespace sgpem
|
|||
// it's correct ;-)
|
||||
Tokens tokens = tokenize(str);
|
||||
|
||||
if(tokens.size() != 0)
|
||||
if (tokens.size() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
parameter.value = string_to<bool>(str);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: Please provide a valid boolean value ('true' or 'false')\n"));
|
||||
correct = false;
|
||||
}
|
||||
}
|
||||
else if(parameter.required)
|
||||
else if (parameter.required)
|
||||
{
|
||||
p_stderr(_("ERROR: This is a mandatory atribute; you MUST provide a valid value!\n"));
|
||||
correct = false;
|
||||
}
|
||||
}
|
||||
while(!correct);
|
||||
while (!correct);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,13 +359,13 @@ TextSimulation::on_run(const Tokens& arguments)
|
|||
{
|
||||
Simulation::get_instance().run();
|
||||
}
|
||||
catch(UserInterruptException e)
|
||||
catch (UserInterruptException e)
|
||||
{
|
||||
p_stderr(_("ERROR: "));
|
||||
p_stderr(e.what());
|
||||
p_stderr(_("\nSimulation is now stopped\n"));
|
||||
}
|
||||
catch(NullPolicyException e)
|
||||
catch (NullPolicyException e)
|
||||
{
|
||||
p_stderr(_("ERROR: "));
|
||||
p_stderr(e.what());
|
||||
|
@ -402,7 +398,7 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
|||
|
||||
CPUPolicy* policy = Simulation::get_instance().get_policy();
|
||||
|
||||
if(policy == NULL)
|
||||
if (policy == NULL)
|
||||
{
|
||||
p_stderr(_("ERROR: No policy actually selected for the simulation\n"));
|
||||
return;
|
||||
|
@ -421,7 +417,7 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
|||
|
||||
IntParams int_params = parameters.get_registered_int_parameters();
|
||||
|
||||
for(IntParams::iterator it = int_params.begin(); it != int_params.end();)
|
||||
for (IntParams::iterator it = int_params.begin(); it != int_params.end();)
|
||||
{
|
||||
PolicyParameters::Parameter<int> &p = it->second;
|
||||
CommandParameter<int> cmd_p(p);
|
||||
|
@ -442,7 +438,7 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
|||
|
||||
FloatParams float_params = parameters.get_registered_float_parameters();
|
||||
|
||||
for(FloatParams::iterator it = float_params.begin(); it != float_params.end();)
|
||||
for (FloatParams::iterator it = float_params.begin(); it != float_params.end();)
|
||||
{
|
||||
PolicyParameters::Parameter<float> &p = it->second;
|
||||
|
||||
|
@ -459,7 +455,7 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
|||
|
||||
StringParams string_params = parameters.get_registered_string_parameters();
|
||||
|
||||
for(StringParams::iterator it = string_params.begin(); it != string_params.end();)
|
||||
for (StringParams::iterator it = string_params.begin(); it != string_params.end();)
|
||||
{
|
||||
PolicyParameters::Parameter<ustring> &p = it->second;
|
||||
|
||||
|
@ -479,20 +475,20 @@ TextSimulation::on_help(const Tokens& arguments)
|
|||
{
|
||||
ustring command;
|
||||
|
||||
if(arguments.size() > 0)
|
||||
if (arguments.size() > 0)
|
||||
{
|
||||
command = arguments[0].uppercase();
|
||||
// print warning if necessary
|
||||
check_arguments_num(arguments, 1);
|
||||
}
|
||||
|
||||
if(command.size() == 0)
|
||||
if (command.size() == 0)
|
||||
p_stdout(_("Avaiable commands:\nRUN\nSTOP\nPAUSE\n"
|
||||
"CONFIGURE-CPU-POLICY\nHELP\nGET\nSET\nSHOW\nADD\n"
|
||||
"REMOVE\nSAVE\nLOAD\nQUIT\n\n"
|
||||
"HELP followed by a command name shows help about it.\n"
|
||||
"ex. `HELP RUN` shows help about the command RUN\n"));
|
||||
else if(command == "RUN")
|
||||
else if (command == "RUN")
|
||||
p_stdout(_("-- RUN COMMAND --\nStarts the simulation. It can be "
|
||||
"continuous or step-by-step depending on the mode configured with "
|
||||
"SET CONTINUOUS (default=true).\n\n"
|
||||
|
@ -501,25 +497,25 @@ TextSimulation::on_help(const Tokens& arguments)
|
|||
"The instant 0 represents the initial state, "
|
||||
"during which no process is running. The scheduler "
|
||||
"activity begins at instant 1.\n"));
|
||||
else if(command == "STOP")
|
||||
else if (command == "STOP")
|
||||
p_stdout(_("-- STOP COMMAND --\nStops the simulation. The next call to RUN will "
|
||||
"bring the simulation to the first instant and start it.\n"));
|
||||
else if(command == "PAUSE")
|
||||
else if (command == "PAUSE")
|
||||
p_stdout(_("-- PAUSE COMMAND --\nPauses the simulation. The next call to RUN will "
|
||||
"continue it.\n"));
|
||||
else if(command == "CONFIGURE-CPU-POLICY")
|
||||
else if (command == "CONFIGURE-CPU-POLICY")
|
||||
p_stdout(_("-- CONFIGURE-CPU-POLICY COMMAND --\nConfigure parameters exposed by "
|
||||
"the cpu policy.\n\nThis is currently the only way to control the behaviour of "
|
||||
"cpu policies without modifying their source code.\n"));
|
||||
else if(command == "HELP")
|
||||
else if (command == "HELP")
|
||||
p_stdout(_("-- HELP COMMAND --\nThe help you're reading.\n"));
|
||||
else if(command == "GET")
|
||||
else if (command == "GET")
|
||||
p_stdout(_("-- GET COMMAND --\nSyntax: GET <attr_name>\n"
|
||||
"\twhere <attr_name> may be simulation-tick or continuous.\n"));
|
||||
else if(command == "SET")
|
||||
else if (command == "SET")
|
||||
p_stdout(_("-- SET COMMAND --\nSyntax: SET <attr_name> [=] <value>\n"
|
||||
"\twhere <attr_name> may be simulation-tick, continuous or cpu-policy.\n"));
|
||||
else if(command == "SHOW")
|
||||
else if (command == "SHOW")
|
||||
p_stderr(_("-- SHOW COMMAND --\nDisplays the name of the entities (if available) "
|
||||
"and other informations prefixed by its numeric identifier.\n\n"
|
||||
"Syntax depends from entities being displayed:\n"
|
||||
|
@ -530,7 +526,7 @@ TextSimulation::on_help(const Tokens& arguments)
|
|||
"identifier of the thread child of process identified by <process_id>\n"
|
||||
"`SHOW subrequests <process_id> <thread_id> <request_id>` where the numeric ids "
|
||||
"follow the same logic of the previous commands\n"));
|
||||
else if(command == "ADD")
|
||||
else if (command == "ADD")
|
||||
p_stderr(_("-- ADD COMMAND --\nAdds an entity by using a questionary-like approach.\n\n"
|
||||
"Syntax depends from entity being added:\n"
|
||||
"`ADD process|resource`\n"
|
||||
|
@ -540,7 +536,7 @@ TextSimulation::on_help(const Tokens& arguments)
|
|||
"identifier of the thread child of process identified by <process_id>\n"
|
||||
"`ADD subrequest <process_id> <thread_id> <request_id>` where the numeric ids "
|
||||
"follow the same logic of the previous commands\n"));
|
||||
else if(command == "REMOVE")
|
||||
else if (command == "REMOVE")
|
||||
p_stderr(_("-- REMOVE COMMAND --\nRemoves an entity.\n\n"
|
||||
"Syntax depends from entity being removed:\n"
|
||||
"`REMOVE process|resource <id>` where <id> is the process or resource identifier\n"
|
||||
|
@ -550,13 +546,13 @@ TextSimulation::on_help(const Tokens& arguments)
|
|||
"numeric ids follow the same logic of the previous commands\n"
|
||||
"`REMOVE subrequest <process_id> <thread_id> <request_id> <subrequest_id>` where the "
|
||||
"numeric ids follow the same logic of the previous commands\n"));
|
||||
else if(command == "SAVE")
|
||||
else if (command == "SAVE")
|
||||
p_stderr(_("-- SAVE COMMAND --\nSaves the simulation.\n\n"
|
||||
"Syntax: SAVE <filename>\n"));
|
||||
else if(command == "LOAD")
|
||||
else if (command == "LOAD")
|
||||
p_stderr(_("-- LOAD COMMAND --\nLoads the simulation.\n\n"
|
||||
"Syntax: LOAD <filename>\n"));
|
||||
else if(command == "QUIT")
|
||||
else if (command == "QUIT")
|
||||
p_stderr(_("-- QUIT COMMAND --\nGently closes the program.\n"));
|
||||
else
|
||||
p_stderr(_("ERROR: Sorry, no help available for this command.\n"));
|
||||
|
@ -567,7 +563,7 @@ TextSimulation::on_quit(const Tokens& arguments)
|
|||
{
|
||||
check_arguments_num(arguments, 0);
|
||||
|
||||
if(!unsaved_ask_confirm())
|
||||
if (!unsaved_ask_confirm())
|
||||
return;
|
||||
|
||||
p_stdout(_("\n\n*** Thank you for using SGPEM by Sirius Cybernetics Corporation ***\n\n"));
|
||||
|
@ -579,18 +575,18 @@ TextSimulation::on_quit(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_get(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring attr = arguments[0].uppercase();
|
||||
|
||||
if(attr == "SIMULATION-TICK")
|
||||
if (attr == "SIMULATION-TICK")
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "simulation-tick = " << Simulation::get_instance().get_timer() << "ms" << endl;
|
||||
p_stdout(oss.str());
|
||||
}
|
||||
else if(attr == "CONTINUOUS")
|
||||
else if (attr == "CONTINUOUS")
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "continuous = " << boolalpha << Simulation::get_instance().get_mode() << endl;
|
||||
|
@ -605,38 +601,38 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
{
|
||||
// handle the optional "=' (I knew that I was buying myself a problem when I
|
||||
// decided to support the assigment operator!)
|
||||
if(arguments.size() >= 3)
|
||||
if (arguments.size() >= 3)
|
||||
check_arguments_num(arguments, 3);
|
||||
else if(!check_arguments_num(arguments, 2))
|
||||
else if (!check_arguments_num(arguments, 2))
|
||||
return;
|
||||
|
||||
ustring attr = arguments[0].uppercase();
|
||||
|
||||
ustring value;
|
||||
|
||||
if(arguments[1] == "=")
|
||||
if (arguments[1] == "=")
|
||||
value = arguments[2];
|
||||
else
|
||||
value = arguments[1];
|
||||
|
||||
if(attr == "SIMULATION-TICK")
|
||||
if (attr == "SIMULATION-TICK")
|
||||
{
|
||||
try
|
||||
{
|
||||
int timer = string_to<int>(value);
|
||||
|
||||
if(timer < 0)
|
||||
if (timer < 0)
|
||||
throw domain_error("");
|
||||
|
||||
Simulation::get_instance().set_timer(timer);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: you must provide a valid unsigned integer value\n"));
|
||||
}
|
||||
|
||||
}
|
||||
else if(attr == "CPU-POLICY")
|
||||
else if (attr == "CPU-POLICY")
|
||||
{
|
||||
int policy;
|
||||
|
||||
|
@ -644,7 +640,7 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
{
|
||||
policy = string_to<int>(value) - 1;
|
||||
|
||||
if(policy < 0)
|
||||
if (policy < 0)
|
||||
throw domain_error("");
|
||||
|
||||
typedef vector<CPUPolicyManager*> ManagerVec;
|
||||
|
@ -654,27 +650,27 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
|
||||
ManagerVec managers = gatekeeper.get_registered();
|
||||
|
||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
for (ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
{
|
||||
vector<CPUPolicy*> policies = (*it)->get_avail_policies();
|
||||
for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
for (CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
{
|
||||
if(policy == 0)
|
||||
if (policy == 0)
|
||||
Simulation::get_instance().set_policy(*it);
|
||||
|
||||
--policy;
|
||||
}
|
||||
}
|
||||
|
||||
if(policy >= 0)
|
||||
if (policy >= 0)
|
||||
throw domain_error("");
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: invalid unsigned integer or not a valid policy index\n"));
|
||||
}
|
||||
}
|
||||
else if(attr == "CONTINUOUS")
|
||||
else if (attr == "CONTINUOUS")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -682,7 +678,7 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
|
||||
Simulation::get_instance().set_mode(continuous);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: you must provide a valid boolean value ('true' or 'false')\n"));
|
||||
}
|
||||
|
@ -694,7 +690,7 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_show(const Tokens& arguments)
|
||||
{
|
||||
if(arguments.size() < 1)
|
||||
if (arguments.size() < 1)
|
||||
{
|
||||
//print error
|
||||
check_arguments_num(arguments, 1);
|
||||
|
@ -718,7 +714,7 @@ TextSimulation::on_show(const Tokens& arguments)
|
|||
entities_handlers["CPU-POLICIES"] = &TextSimulation::on_show_cpu_policies;
|
||||
entities_handlers["RESOURCE-POLICIES"] = &TextSimulation::on_show_resource_policies;
|
||||
|
||||
if(entities_handlers.find(entities) == entities_handlers.end())
|
||||
if (entities_handlers.find(entities) == entities_handlers.end())
|
||||
p_stderr(_("ERROR: invalid argument\n"));
|
||||
else
|
||||
(this->*(entities_handlers[entities]))(args);
|
||||
|
@ -749,7 +745,7 @@ TextSimulation::on_show_resources(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_show_threads(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -764,12 +760,12 @@ TextSimulation::on_show_threads(const Tokens& arguments)
|
|||
int pid = string_to<int>(process) - 1;
|
||||
threads = processes.at(pid)->get_threads();
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided process identifier is not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: this process identifier does not belong to an existing process\n"));
|
||||
return;
|
||||
|
@ -782,7 +778,7 @@ TextSimulation::on_show_threads(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_show_requests(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 2))
|
||||
if (!check_arguments_num(arguments, 2))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -800,12 +796,12 @@ TextSimulation::on_show_requests(const Tokens& arguments)
|
|||
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||
requests = threads.at(tid)->get_requests();
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -817,7 +813,7 @@ TextSimulation::on_show_requests(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_show_subrequests(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 3))
|
||||
if (!check_arguments_num(arguments, 3))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -838,12 +834,12 @@ TextSimulation::on_show_subrequests(const Tokens& arguments)
|
|||
vector<Request*> requests = threads.at(tid)->get_requests();
|
||||
subrequests = requests.at(rid)->get_subrequests();
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -865,10 +861,10 @@ TextSimulation::on_show_cpu_policies(const Tokens& arguments)
|
|||
ManagerVec managers = gatekeeper.get_registered();
|
||||
|
||||
unsigned int index = 1;
|
||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
for (ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
{
|
||||
vector<CPUPolicy*> policies = (*it)->get_avail_policies();
|
||||
for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
for (CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << index << ". " << (*it)->get_name() << endl;
|
||||
|
@ -891,14 +887,14 @@ TextSimulation::on_show_resource_policies(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_add(const Tokens& arguments)
|
||||
{
|
||||
if(arguments.size() < 1)
|
||||
if (arguments.size() < 1)
|
||||
{
|
||||
//print error
|
||||
check_arguments_num(arguments, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Simulation::get_instance().get_state() != Simulation::state_stopped)
|
||||
if (Simulation::get_instance().get_state() != Simulation::state_stopped)
|
||||
{
|
||||
p_stderr(_("WARNING: Simulation is not stopped, it will be automatically stopped\n"));
|
||||
Simulation::get_instance().stop();
|
||||
|
@ -919,7 +915,7 @@ TextSimulation::on_add(const Tokens& arguments)
|
|||
entity_handlers["REQUEST"] = &TextSimulation::on_add_request;
|
||||
entity_handlers["SUBREQUEST"] = &TextSimulation::on_add_subrequest;
|
||||
|
||||
if(entity_handlers.find(entity) == entity_handlers.end())
|
||||
if (entity_handlers.find(entity) == entity_handlers.end())
|
||||
p_stderr(_("ERROR: invalid argument\n"));
|
||||
else
|
||||
(this->*(entity_handlers[entity]))(args);
|
||||
|
@ -966,7 +962,7 @@ TextSimulation::on_add_resource(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_add_thread(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -980,12 +976,12 @@ TextSimulation::on_add_thread(const Tokens& arguments)
|
|||
{
|
||||
p = processes.at(string_to<int>(process) - 1);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1010,7 +1006,7 @@ TextSimulation::on_add_thread(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_add_request(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 2))
|
||||
if (!check_arguments_num(arguments, 2))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -1029,12 +1025,12 @@ TextSimulation::on_add_request(const Tokens& arguments)
|
|||
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||
t = threads.at(tid);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1052,7 +1048,7 @@ TextSimulation::on_add_request(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_add_subrequest(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 3))
|
||||
if (!check_arguments_num(arguments, 3))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -1075,12 +1071,12 @@ TextSimulation::on_add_subrequest(const Tokens& arguments)
|
|||
r = requests.at(rid);
|
||||
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1095,10 +1091,10 @@ TextSimulation::on_add_subrequest(const Tokens& arguments)
|
|||
{
|
||||
get_parameter(resource_key);
|
||||
|
||||
if(resources.find(resource_key.value) == resources.end())
|
||||
if (resources.find(resource_key.value) == resources.end())
|
||||
p_stderr(_("ERROR: invalid resource identifier\n"));
|
||||
}
|
||||
while(resources.find(resource_key.value) == resources.end());
|
||||
while (resources.find(resource_key.value) == resources.end());
|
||||
|
||||
get_parameter(duration);
|
||||
|
||||
|
@ -1110,14 +1106,14 @@ TextSimulation::on_add_subrequest(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_remove(const Tokens& arguments)
|
||||
{
|
||||
if(arguments.size() < 1)
|
||||
if (arguments.size() < 1)
|
||||
{
|
||||
//print error
|
||||
check_arguments_num(arguments, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if(Simulation::get_instance().get_state() != Simulation::state_stopped)
|
||||
if (Simulation::get_instance().get_state() != Simulation::state_stopped)
|
||||
p_stderr(_("WARNING: Simulation is not stopped, it will be automatically stopped"));
|
||||
|
||||
//make a local copy which we'll probably modify
|
||||
|
@ -1135,7 +1131,7 @@ TextSimulation::on_remove(const Tokens& arguments)
|
|||
entity_handlers["REQUEST"] = &TextSimulation::on_remove_request;
|
||||
entity_handlers["SUBREQUEST"] = &TextSimulation::on_remove_subrequest;
|
||||
|
||||
if(entity_handlers.find(entity) == entity_handlers.end())
|
||||
if (entity_handlers.find(entity) == entity_handlers.end())
|
||||
p_stderr(_("ERROR: invalid argument\n"));
|
||||
else
|
||||
(this->*(entity_handlers[entity]))(args);
|
||||
|
@ -1144,7 +1140,7 @@ TextSimulation::on_remove(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_remove_process(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -1158,12 +1154,12 @@ TextSimulation::on_remove_process(const Tokens& arguments)
|
|||
{
|
||||
p = processes.at(string_to<int>(process) - 1);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1176,7 +1172,7 @@ TextSimulation::on_remove_process(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_remove_resource(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring resource = arguments[0];
|
||||
|
@ -1192,15 +1188,15 @@ TextSimulation::on_remove_resource(const Tokens& arguments)
|
|||
const Environment::Resources& resources =
|
||||
h.get_environment_at(0).get_resources();
|
||||
|
||||
if(resources.find(rid) == resources.end())
|
||||
if (resources.find(rid) == resources.end())
|
||||
throw out_of_range(_("invalid resource id"));
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1212,7 +1208,7 @@ TextSimulation::on_remove_resource(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_remove_thread(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 2))
|
||||
if (!check_arguments_num(arguments, 2))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -1231,12 +1227,12 @@ TextSimulation::on_remove_thread(const Tokens& arguments)
|
|||
vector<Thread*> threads = processes.at(pid)->get_threads();
|
||||
t = threads.at(tid);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1249,7 +1245,7 @@ TextSimulation::on_remove_thread(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_remove_request(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 3))
|
||||
if (!check_arguments_num(arguments, 3))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -1271,12 +1267,12 @@ TextSimulation::on_remove_request(const Tokens& arguments)
|
|||
vector<Request*> requests = threads.at(tid)->get_requests();
|
||||
r = requests.at(rid);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1289,7 +1285,7 @@ TextSimulation::on_remove_request(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 4))
|
||||
if (!check_arguments_num(arguments, 4))
|
||||
return;
|
||||
|
||||
ustring process = arguments[0];
|
||||
|
@ -1314,12 +1310,12 @@ TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
|||
vector<SubRequest*> subrequests = requests.at(rid)->get_subrequests();
|
||||
r = subrequests.at(srid);
|
||||
}
|
||||
catch(domain_error e)
|
||||
catch (domain_error e)
|
||||
{
|
||||
p_stderr(_("ERROR: provided identifier(s) not a valid integer\n"));
|
||||
return;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: the identifier(s) do not belong to an existing entity\n"));
|
||||
return;
|
||||
|
@ -1332,7 +1328,7 @@ TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_save(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring filename = arguments[0];
|
||||
|
@ -1353,11 +1349,11 @@ TextSimulation::on_save(const Tokens& arguments)
|
|||
|
||||
_saved = true;
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: No registered serializer available\n"));
|
||||
}
|
||||
catch(SerializerError e)
|
||||
catch (SerializerError e)
|
||||
{
|
||||
string msg = _("ERROR: ");
|
||||
|
||||
|
@ -1368,12 +1364,12 @@ TextSimulation::on_save(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_load(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
if (!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring filename = arguments[0];
|
||||
|
||||
if(!unsaved_ask_confirm())
|
||||
if (!unsaved_ask_confirm())
|
||||
return;
|
||||
|
||||
try
|
||||
|
@ -1390,11 +1386,11 @@ TextSimulation::on_load(const Tokens& arguments)
|
|||
|
||||
serializer.restore_snapshot(filename, history);
|
||||
}
|
||||
catch(out_of_range e)
|
||||
catch (out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: No registered serializer available\n"));
|
||||
}
|
||||
catch(SerializerError e)
|
||||
catch (SerializerError e)
|
||||
{
|
||||
string msg = _("ERROR: ");
|
||||
|
||||
|
@ -1447,12 +1443,12 @@ TextSimulation::parse_command(TextSimulation& sim, const ustring& str)
|
|||
|
||||
Tokens arguments = tokenize(str);
|
||||
|
||||
if(arguments.size() == 0)
|
||||
if (arguments.size() == 0)
|
||||
return;
|
||||
|
||||
ustring key = arguments[0].uppercase();
|
||||
|
||||
if(command_handlers.find(key) == command_handlers.end())
|
||||
if (command_handlers.find(key) == command_handlers.end())
|
||||
{
|
||||
p_stderr(_("ERROR: command not supported\n"));
|
||||
return;
|
||||
|
@ -1462,14 +1458,14 @@ TextSimulation::parse_command(TextSimulation& sim, const ustring& str)
|
|||
|
||||
(sim.*(command_handlers[key]))(arguments);
|
||||
|
||||
if(key == "ADD" || key == "REMOVE")
|
||||
if (key == "ADD" || key == "REMOVE")
|
||||
sim._saved = false;
|
||||
}
|
||||
|
||||
static ostream&
|
||||
operator<<(ostream& os, Schedulable::state state)
|
||||
{
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case Schedulable::state_running:
|
||||
os << "RUNNING";
|
||||
|
@ -1496,7 +1492,7 @@ operator<<(ostream& os, Schedulable::state state)
|
|||
static ostream&
|
||||
operator<<(ostream& os, Request::state state)
|
||||
{
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case Request::state_unallocable:
|
||||
os << "UNALLOCABLE";
|
||||
|
@ -1534,7 +1530,7 @@ TextSimulation::update(const History& changed_history)
|
|||
// this is a damn uint, so we must hack and hack
|
||||
int printed_instant;
|
||||
|
||||
if(changed_history.get_size() > 1)
|
||||
if (changed_history.get_size() > 1)
|
||||
printed_instant = static_cast<int>(changed_history.get_size()) - 2;
|
||||
else
|
||||
printed_instant = -1;
|
||||
|
@ -1548,7 +1544,7 @@ TextSimulation::update(const History& changed_history)
|
|||
const Environment& env = changed_history.get_last_environment();
|
||||
const ReadyQueue& q = env.get_sorted_queue();
|
||||
|
||||
for(unsigned int i = 0; i < q.size(); ++i)
|
||||
for (unsigned int i = 0; i < q.size(); ++i)
|
||||
{
|
||||
const Thread& t = q.get_item_at(i);
|
||||
|
||||
|
@ -1562,7 +1558,7 @@ TextSimulation::update(const History& changed_history)
|
|||
const Environment::Resources& resources = env.get_resources();
|
||||
typedef Environment::Resources::const_iterator ResourceIt;
|
||||
|
||||
for(ResourceIt it = resources.begin(); it != resources.end(); ++it)
|
||||
for (ResourceIt it = resources.begin(); it != resources.end(); ++it)
|
||||
{
|
||||
const Resource& r = *it->second;
|
||||
Environment::resource_key_t key = it->first;
|
||||
|
@ -1580,7 +1576,7 @@ TextSimulation::update(const History& changed_history)
|
|||
|
||||
p_stdout(_("\t\t\tqueue: { "));
|
||||
|
||||
for(unsigned int i = 0; i < req_queue.size(); ++i)
|
||||
for (unsigned int i = 0; i < req_queue.size(); ++i)
|
||||
{
|
||||
if (i == r.get_places())
|
||||
oss << " || ";
|
||||
|
@ -1603,7 +1599,7 @@ TextSimulation::update(const History& changed_history)
|
|||
|
||||
const Environment::Processes& processes = env.get_processes();
|
||||
|
||||
for(unsigned int pi = 0; pi < processes.size(); ++pi)
|
||||
for (unsigned int pi = 0; pi < processes.size(); ++pi)
|
||||
{
|
||||
Process& p = *processes[pi];
|
||||
|
||||
|
@ -1619,7 +1615,7 @@ TextSimulation::update(const History& changed_history)
|
|||
|
||||
vector<Thread*> threads = p.get_threads();
|
||||
|
||||
for(unsigned int ti = 0; ti < threads.size(); ++ti)
|
||||
for (unsigned int ti = 0; ti < threads.size(); ++ti)
|
||||
{
|
||||
Thread& t = *threads[ti];
|
||||
|
||||
|
@ -1635,13 +1631,13 @@ TextSimulation::update(const History& changed_history)
|
|||
|
||||
vector<Request*> requests = t.get_requests();
|
||||
|
||||
for(unsigned int ri = 0; ri < requests.size(); ++ri)
|
||||
for (unsigned int ri = 0; ri < requests.size(); ++ri)
|
||||
{
|
||||
Request& r = *requests[ri];
|
||||
|
||||
vector<SubRequest*> subrequests = r.get_subrequests();
|
||||
|
||||
for(unsigned int sri = 0; sri < subrequests.size(); ++sri)
|
||||
for (unsigned int sri = 0; sri < subrequests.size(); ++sri)
|
||||
{
|
||||
SubRequest& sr = *subrequests[sri];
|
||||
oss << _(" --> request ") << ri + 1 << "." << sri + 1 << ") ";
|
||||
|
|
Loading…
Reference in New Issue