- 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
108 changed files with 3196 additions and 3180 deletions
|
@ -27,27 +27,27 @@ using namespace sgpem;
|
|||
|
||||
sgpem::XMLSerializer* _serializer = NULL;
|
||||
|
||||
void
|
||||
void
|
||||
sgpem__Plugin__on_init()
|
||||
{
|
||||
if(_serializer == NULL)
|
||||
if (_serializer == NULL)
|
||||
_serializer = new sgpem::XMLSerializer();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
sgpem__Plugin__on_exit()
|
||||
{
|
||||
delete _serializer;
|
||||
_serializer = NULL;
|
||||
}
|
||||
|
||||
const char*
|
||||
const char*
|
||||
sgpem__Plugin__describe()
|
||||
{
|
||||
return "This plugin saves the simulation to an XML file";
|
||||
}
|
||||
|
||||
const char*
|
||||
const char*
|
||||
sgpem__Plugin__get_name()
|
||||
{
|
||||
return "XmlSave";
|
||||
|
|
|
@ -42,7 +42,7 @@ using namespace std;
|
|||
|
||||
/*
|
||||
* This program tests the XML serialization via the XMLSerializer class.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
@ -62,13 +62,13 @@ main(int argc, char** argv)
|
|||
{
|
||||
// output file name
|
||||
Glib::ustring outfile("xml-visit.xml");
|
||||
|
||||
|
||||
// string stream to compare print dump of environment
|
||||
ostringstream os1;
|
||||
ostringstream os2;
|
||||
ostringstream os3;
|
||||
ostringstream os4;
|
||||
|
||||
|
||||
ConcreteHistory hist;
|
||||
cout << "create ConcreteHistory hist" << endl;
|
||||
|
||||
|
@ -90,38 +90,38 @@ main(int argc, char** argv)
|
|||
// add something other to history
|
||||
addSomethingHistory(hist);
|
||||
cout << "add other data to hist" << endl;
|
||||
|
||||
|
||||
// print on a string stream os2
|
||||
dumpEnvironment(hist.get_last_environment(), os2);
|
||||
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;
|
||||
|
@ -131,7 +131,7 @@ main(int argc, char** argv)
|
|||
cout << "test failed" << endl;
|
||||
ret = 1;
|
||||
}
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,10 +145,10 @@ void fillHistory(History &hist)
|
|||
History::ResourcePair respair0 = hist.add_resource(Glib::ustring("Resource 0"), false, 1, 2);
|
||||
// add a resource - name, preemptable, places, availability
|
||||
History::ResourcePair respair00 = hist.add_resource(Glib::ustring("Resource 00"), false, 1, 2);
|
||||
|
||||
|
||||
// add a resource - name, preemptable, places, availability
|
||||
History::ResourcePair respair = hist.add_resource(Glib::ustring("Resource 1"), false, 1, 2);
|
||||
|
||||
|
||||
// add a resource - name, preemptable, places, availability
|
||||
History::ResourcePair respair2 = hist.add_resource(Glib::ustring("Invalid? Resource <n> 1"), false, 1, 2);
|
||||
// and print his values
|
||||
|
@ -201,32 +201,32 @@ 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()
|
||||
/* << " key: " << (*riter).first */
|
||||
<< " places: " << r->get_places() << endl;
|
||||
/* << " key: " << (*riter).first */
|
||||
<< " places: " << r->get_places() << endl;
|
||||
riter++;
|
||||
}
|
||||
|
||||
|
||||
const Environment::Processes& pvect = env.get_processes();
|
||||
typedef std::vector<Process*>::const_iterator proc_iterator;
|
||||
|
||||
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()
|
||||
<< " arrival_time: " << p->get_arrival_time()
|
||||
<< " base_priority: " << p->get_base_priority() << endl;
|
||||
<< " arrival_time: " << p->get_arrival_time()
|
||||
<< " base_priority: " << p->get_base_priority() << endl;
|
||||
iter++;
|
||||
|
||||
typedef std::vector<Thread*> Threads;
|
||||
|
@ -234,20 +234,20 @@ 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);
|
||||
os << " thread name: " << t->get_name()
|
||||
<< " arrival_time: " << t->get_arrival_time()
|
||||
<< " base_priority: " << t->get_base_priority() << endl;
|
||||
<< " arrival_time: " << t->get_arrival_time()
|
||||
<< " base_priority: " << t->get_base_priority() << endl;
|
||||
|
||||
typedef std::vector<Request*> Requests;
|
||||
typedef std::vector<Request*>::const_iterator req_iterator;
|
||||
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()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
@ -45,13 +43,14 @@ void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History&
|
|||
/* COMPAT: Do not genrate nodes for formatting spaces */
|
||||
LIBXML_TEST_VERSION
|
||||
xmlKeepBlanksDefault(0);
|
||||
|
||||
|
||||
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.");
|
||||
}
|
||||
|
@ -60,48 +59,49 @@ void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History&
|
|||
{
|
||||
throw SerializerError("Internal Error creating xml doc.");
|
||||
}
|
||||
|
||||
|
||||
/* Clean up everything else before quitting. */
|
||||
xmlCleanupParser();
|
||||
}
|
||||
|
||||
void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializerError)
|
||||
{
|
||||
// TODO - all to do!!
|
||||
// DEBUG - remove me when finished
|
||||
// TODO - all to do!!
|
||||
// DEBUG - remove me when finished
|
||||
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
xmlDocPtr doc;
|
||||
|
||||
LIBXML_TEST_VERSION
|
||||
xmlKeepBlanksDefault(0);
|
||||
xmlDocPtr doc;
|
||||
|
||||
/*
|
||||
* build an XML tree from a the file;
|
||||
*/
|
||||
doc = xmlParseFile(filename.c_str());
|
||||
if (doc == NULL) {
|
||||
xmlCleanupParser();
|
||||
throw SerializerError("Parsing Error: doc is invalid.");
|
||||
}
|
||||
LIBXML_TEST_VERSION
|
||||
xmlKeepBlanksDefault(0);
|
||||
|
||||
clear_history(hist);
|
||||
XMLSerializerFactory fact(hist);
|
||||
|
||||
// read all elements and fill hist
|
||||
read_doc(doc, fact);
|
||||
|
||||
// frees all xml related data
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
/* Clean up everything else before quitting. */
|
||||
/*
|
||||
* build an XML tree from a the file;
|
||||
*/
|
||||
doc = xmlParseFile(filename.c_str());
|
||||
if (doc == NULL)
|
||||
{
|
||||
xmlCleanupParser();
|
||||
throw SerializerError("Parsing Error: doc is invalid.");
|
||||
}
|
||||
|
||||
clear_history(hist);
|
||||
XMLSerializerFactory fact(hist);
|
||||
|
||||
// read all elements and fill hist
|
||||
read_doc(doc, fact);
|
||||
|
||||
// frees all xml related data
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
/* Clean up everything else before quitting. */
|
||||
xmlCleanupParser();
|
||||
|
||||
#else
|
||||
/*
|
||||
* the library has been compiled without some of the old interfaces
|
||||
*/
|
||||
#error Compilation of LIBXML with SAX1 support must be enabled
|
||||
/*
|
||||
* the library has been compiled without some of the old interfaces
|
||||
*/
|
||||
#error Compilation of LIBXML with SAX1 support must be enabled
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
}
|
||||
|
||||
|
@ -112,57 +112,57 @@ void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& his
|
|||
|
||||
const Glib::ustring XMLSerializer::get_filename_extension()
|
||||
{
|
||||
return Glib::ustring("xsgp");
|
||||
return Glib::ustring("xsgp");
|
||||
}
|
||||
|
||||
|
||||
const Glib::ustring XMLSerializer::get_filename_description()
|
||||
{
|
||||
return Glib::ustring("SGPEMv2 XML savefile");
|
||||
return Glib::ustring("SGPEMv2 XML savefile");
|
||||
}
|
||||
|
||||
void XMLSerializer::fill_doc(xmlDocPtr doc, const History& hist)
|
||||
{
|
||||
xmlNodePtr root_node = NULL;/* node pointers */
|
||||
/*
|
||||
* Creates a new document, a node and set it as a root node
|
||||
*/
|
||||
root_node = xmlNewNode(NULL, (const xmlChar *) "sgpem");
|
||||
xmlDocSetRootElement(doc, root_node);
|
||||
xmlNodePtr root_node = NULL;/* node pointers */
|
||||
/*
|
||||
* Creates a new document, a node and set it as a root node
|
||||
*/
|
||||
root_node = xmlNewNode(NULL, (const xmlChar *) "sgpem");
|
||||
xmlDocSetRootElement(doc, root_node);
|
||||
|
||||
/*
|
||||
* Creates a DTD declaration. Isn't mandatory.
|
||||
*/
|
||||
xmlDtdPtr dtd = xmlCreateIntSubset(doc, (const xmlChar *) "sgpem", NULL, (const xmlChar *) "sgpem.dtd");
|
||||
/*
|
||||
* Creates a DTD declaration. Isn't mandatory.
|
||||
*/
|
||||
xmlDtdPtr dtd = xmlCreateIntSubset(doc, (const xmlChar *) "sgpem", NULL, (const xmlChar *) "sgpem.dtd");
|
||||
|
||||
XMLVisitor xvisit(root_node);
|
||||
xvisit.from_history(hist);
|
||||
/*
|
||||
//
|
||||
// xmlNewChild() creates a new node, which is "attached" as child node
|
||||
// of root_node node.
|
||||
//
|
||||
xmlNodePtr resources_node = xmlNewChild(root_node, NULL, (const xmlChar *) "resources", NULL);
|
||||
//
|
||||
// The same as above, but the new child node doesn't have a content
|
||||
//
|
||||
xmlNodePtr schedulables_node = xmlNewChild(root_node, NULL, (const xmlChar *) "schedulables", NULL);
|
||||
XMLVisitor xvisit(root_node);
|
||||
xvisit.from_history(hist);
|
||||
/*
|
||||
//
|
||||
// xmlNewChild() creates a new node, which is "attached" as child node
|
||||
// of root_node node.
|
||||
//
|
||||
xmlNodePtr resources_node = xmlNewChild(root_node, NULL, (const xmlChar *) "resources", NULL);
|
||||
//
|
||||
// The same as above, but the new child node doesn't have a content
|
||||
//
|
||||
xmlNodePtr schedulables_node = xmlNewChild(root_node, NULL, (const xmlChar *) "schedulables", NULL);
|
||||
|
||||
fill_resources(resources_node, hist);
|
||||
fill_schedulables(schedulables_node, hist);
|
||||
*/
|
||||
fill_resources(resources_node, hist);
|
||||
fill_schedulables(schedulables_node, hist);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
void XMLSerializer::fill_resources(xmlNodePtr resources_node, const History& hist)
|
||||
{
|
||||
|
||||
|
||||
|
||||
const Environment& env = hist.get_last_environment();
|
||||
|
||||
const Environment::Resources& rvect = env.get_resources();
|
||||
typedef Environment::Resources::const_iterator res_iterator;
|
||||
|
||||
|
||||
res_iterator iter = rvect.begin();
|
||||
res_iterator end = rvect.end();
|
||||
while(iter!=end)
|
||||
|
@ -177,13 +177,13 @@ void XMLSerializer::fill_resources(xmlNodePtr resources_node, const History& his
|
|||
|
||||
void XMLSerializer::fill_schedulables(xmlNodePtr schedulables_node, const History& hist)
|
||||
{
|
||||
|
||||
|
||||
|
||||
const Environment& env = hist.get_last_environment();
|
||||
|
||||
const Environment::Processes& pvect = env.get_processes();
|
||||
typedef std::vector<Process*>::const_iterator proc_iterator;
|
||||
|
||||
|
||||
proc_iterator iter = pvect.begin();
|
||||
proc_iterator end = pvect.end();
|
||||
while(iter!=end)
|
||||
|
@ -198,71 +198,74 @@ void XMLSerializer::fill_schedulables(xmlNodePtr schedulables_node, const Histor
|
|||
void XMLSerializer::clear_history(History& hist)
|
||||
{
|
||||
|
||||
const Environment& env = hist.get_last_environment();
|
||||
const Environment& env = hist.get_last_environment();
|
||||
|
||||
const Environment::Processes& pvect = env.get_processes();
|
||||
typedef std::vector<Process*>::const_iterator proc_iterator;
|
||||
|
||||
proc_iterator iter = pvect.begin();
|
||||
while(iter!=pvect.end())
|
||||
{
|
||||
hist.remove(*(*iter));
|
||||
iter = pvect.begin();
|
||||
}
|
||||
const Environment::Processes& pvect = env.get_processes();
|
||||
typedef std::vector<Process*>::const_iterator proc_iterator;
|
||||
|
||||
const Environment::Resources& rvect = env.get_resources();
|
||||
typedef Environment::Resources::const_iterator res_iterator;
|
||||
|
||||
res_iterator riter = rvect.begin();
|
||||
while(riter!=rvect.end())
|
||||
{
|
||||
hist.remove((*riter).first);
|
||||
riter = rvect.begin();
|
||||
}
|
||||
proc_iterator iter = pvect.begin();
|
||||
while (iter != pvect.end())
|
||||
{
|
||||
hist.remove(*(*iter));
|
||||
iter = pvect.begin();
|
||||
}
|
||||
|
||||
const Environment::Resources& rvect = env.get_resources();
|
||||
typedef Environment::Resources::const_iterator res_iterator;
|
||||
|
||||
res_iterator riter = rvect.begin();
|
||||
while (riter != rvect.end())
|
||||
{
|
||||
hist.remove((*riter).first);
|
||||
riter = rvect.begin();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError)
|
||||
{
|
||||
/*
|
||||
* Check the document is of the right kind
|
||||
*/
|
||||
xmlNodePtr root;
|
||||
root = xmlDocGetRootElement(doc);
|
||||
if (root == NULL) {
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
throw SerializerError("Reading Error: xml doc is empty.");
|
||||
}
|
||||
/*
|
||||
* Check the document is of the right kind
|
||||
*/
|
||||
xmlNodePtr root;
|
||||
root = xmlDocGetRootElement(doc);
|
||||
if (root == NULL)
|
||||
{
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
throw SerializerError("Reading Error: xml doc is empty.");
|
||||
}
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = root->children;
|
||||
while(cur!=NULL)
|
||||
xmlNodePtr cur;
|
||||
cur = root->children;
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring name((const char *)cur->name);
|
||||
if (name == "resources")
|
||||
{
|
||||
Glib::ustring name((const char *)cur->name);
|
||||
if(name=="resources")
|
||||
{
|
||||
read_resources(cur, fact);
|
||||
}
|
||||
if(name=="schedulables")
|
||||
{
|
||||
read_schedulables(cur, fact);
|
||||
}
|
||||
cur = cur->next;
|
||||
read_resources(cur, fact);
|
||||
}
|
||||
if (name == "schedulables")
|
||||
{
|
||||
read_schedulables(cur, fact);
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -276,129 +279,129 @@ XMLSerializerFactory::Parameters* read_properties(xmlAttrPtr prop)
|
|||
|
||||
void XMLSerializer::read_resources(xmlNodePtr resources_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
xmlNodePtr cur;
|
||||
cur = resources_node->children;
|
||||
while(cur!=NULL)
|
||||
xmlNodePtr cur;
|
||||
cur = resources_node->children;
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if (node_name == "resource")
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="resource")
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Resource"), *par);
|
||||
}
|
||||
// fact.create_resource(*par);
|
||||
fact.factory_method(Glib::ustring("Resource"), *par);
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
// fact.create_resource(*par);
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
void XMLSerializer::read_schedulables(xmlNodePtr schedulables_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(schedulables_node==NULL)
|
||||
return;
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = schedulables_node->children;
|
||||
while(cur!=NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="process")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Process"), *par);
|
||||
}
|
||||
// pass the "threads node"
|
||||
read_threads(cur->children, fact);
|
||||
}
|
||||
if (schedulables_node == NULL)
|
||||
return;
|
||||
|
||||
cur = cur->next;
|
||||
xmlNodePtr cur;
|
||||
cur = schedulables_node->children;
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if (node_name == "process")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Process"), *par);
|
||||
}
|
||||
// pass the "threads node"
|
||||
read_threads(cur->children, fact);
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
void XMLSerializer::read_threads(xmlNodePtr threads_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(threads_node==NULL)
|
||||
return;
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = threads_node->children;
|
||||
while(cur!=NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="thread")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Thread"), *par);
|
||||
}
|
||||
// pass the "requests node"
|
||||
read_requests(cur->children, fact);
|
||||
}
|
||||
if (threads_node == NULL)
|
||||
return;
|
||||
|
||||
cur = cur->next;
|
||||
xmlNodePtr cur;
|
||||
cur = threads_node->children;
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if (node_name == "thread")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Thread"), *par);
|
||||
}
|
||||
// pass the "requests node"
|
||||
read_requests(cur->children, fact);
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
void XMLSerializer::read_requests(xmlNodePtr requests_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(requests_node==NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = requests_node->children;
|
||||
while(cur!=NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="request")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Request"), *par);
|
||||
}
|
||||
// pass the "subrequest nodes"
|
||||
read_subrequests(cur->children, fact);
|
||||
}
|
||||
if (requests_node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
xmlNodePtr cur;
|
||||
cur = requests_node->children;
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if (node_name == "request")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("Request"), *par);
|
||||
}
|
||||
// pass the "subrequest nodes"
|
||||
read_subrequests(cur->children, fact);
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
void XMLSerializer::read_subrequests(xmlNodePtr subrequest_node, XMLSerializerFactory& fact)
|
||||
{
|
||||
if(subrequest_node==NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr cur;
|
||||
cur = subrequest_node;
|
||||
while(cur!=NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if(node_name=="subrequest")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par=read_properties(prop);
|
||||
if(par!=NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("SubRequest"), *par);
|
||||
}
|
||||
}
|
||||
if (subrequest_node == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
xmlNodePtr cur;
|
||||
cur = subrequest_node;
|
||||
while (cur != NULL)
|
||||
{
|
||||
Glib::ustring node_name((const char *)cur->name);
|
||||
if (node_name == "subrequest")
|
||||
{
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
XMLSerializerFactory::Parameters* par = read_properties(prop);
|
||||
if (par != NULL)
|
||||
{
|
||||
fact.factory_method(Glib::ustring("SubRequest"), *par);
|
||||
}
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* comment */
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace sgpem
|
|||
then calls fill_resources and fill_schedulables to fill all with data.
|
||||
*/
|
||||
void fill_doc(xmlDocPtr doc, const History& hist);
|
||||
|
||||
|
||||
/**
|
||||
\brief Take a resources node and fill it with the data
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace sgpem
|
|||
Uses an XMLVisitor object to do the task.
|
||||
*/
|
||||
// void fill_resources(xmlNodePtr resources_node, const History& hist);
|
||||
|
||||
|
||||
/**
|
||||
\brief Take a schedulables node and fill it with the data
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace sgpem
|
|||
rebuild the correct image using the XMLSerializerFactory object.
|
||||
*/
|
||||
void read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError);
|
||||
|
||||
|
||||
/**
|
||||
\brief Restore all the resources from the passed xml node
|
||||
|
||||
|
@ -134,7 +134,7 @@ namespace sgpem
|
|||
object.
|
||||
*/
|
||||
void read_resources(xmlNodePtr resources_node, XMLSerializerFactory& fact);
|
||||
|
||||
|
||||
/**
|
||||
\brief Restore all the schedulables (processes) from the passed xml node
|
||||
|
||||
|
@ -143,7 +143,7 @@ namespace sgpem
|
|||
XMLSerializerFactory object.
|
||||
*/
|
||||
void read_schedulables(xmlNodePtr schedulables_node, XMLSerializerFactory& fact);
|
||||
|
||||
|
||||
/**
|
||||
\brief Restore all threads from the passed xml node
|
||||
|
||||
|
@ -152,7 +152,7 @@ namespace sgpem
|
|||
XMLSerializerFactory object.
|
||||
*/
|
||||
void read_threads(xmlNodePtr schedulables_node, XMLSerializerFactory& fact);
|
||||
|
||||
|
||||
/**
|
||||
\brief Restore all the requests from the passed xml node
|
||||
|
||||
|
@ -161,7 +161,7 @@ namespace sgpem
|
|||
XMLSerializerFactory object.
|
||||
*/
|
||||
void read_requests(xmlNodePtr schedulables_node, XMLSerializerFactory& fact);
|
||||
|
||||
|
||||
/**
|
||||
\brief Restore all the subrequests from the passed xml node
|
||||
|
||||
|
|
|
@ -35,13 +35,11 @@ using namespace std;
|
|||
|
||||
|
||||
XMLSerializerFactory::XMLSerializerFactory(History& hist)
|
||||
: _hist(&hist)
|
||||
{
|
||||
}
|
||||
: _hist(&hist)
|
||||
{}
|
||||
|
||||
XMLSerializerFactory::~XMLSerializerFactory()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
History* XMLSerializerFactory::get_history()
|
||||
{
|
||||
|
@ -51,27 +49,27 @@ 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);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
throw SerializerError("Factory for Unknown class: " + class_name + " doesn't exists.");
|
||||
}
|
||||
|
@ -85,48 +83,53 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
History::ResourcePair respair = _hist->add_resource(name, preemptable, how_many, arrival_time);
|
||||
_temp_map.insert(TempMap::value_type((resource_key_t)old_key, respair.first));
|
||||
|
||||
|
@ -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,26 +249,28 @@ 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;
|
||||
|
||||
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// read "priority" property
|
||||
//pos = parameters.find(Glib::ustring("how-many"));
|
||||
//if (pos != parameters.end()) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,12 +51,12 @@ namespace sgpem
|
|||
{
|
||||
public:
|
||||
typedef std::map<Glib::ustring, Glib::ustring> Parameters;
|
||||
|
||||
|
||||
/**
|
||||
\brief Contructor takes an history as readed data destination
|
||||
*/
|
||||
XMLSerializerFactory(History& hist);
|
||||
|
||||
|
||||
/**
|
||||
\brief A destructor, nothing else
|
||||
*/
|
||||
|
@ -83,22 +83,22 @@ namespace sgpem
|
|||
typedef Environment::resource_key_t resource_key_t;
|
||||
// associate old keys with new ones
|
||||
typedef std::map<resource_key_t, resource_key_t> TempMap;
|
||||
|
||||
|
||||
/**
|
||||
Resource factory from given parameters
|
||||
*/
|
||||
History::ResourcePair create_resource(Parameters& parameters);
|
||||
|
||||
|
||||
/**
|
||||
Process factory from given parameters
|
||||
*/
|
||||
Process& create_process(Parameters& parameters);
|
||||
|
||||
|
||||
/**
|
||||
Thread factory from given parameters
|
||||
*/
|
||||
Thread& create_thread(Parameters& parameters);
|
||||
|
||||
|
||||
/**
|
||||
Request factory from given parameters
|
||||
*/
|
||||
|
|
|
@ -36,19 +36,17 @@ using namespace sgpem;
|
|||
|
||||
|
||||
XMLVisitor::XMLVisitor(xmlNodePtr current)
|
||||
: _current(current)
|
||||
{
|
||||
}
|
||||
: _current(current)
|
||||
{}
|
||||
|
||||
XMLVisitor::~XMLVisitor()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void XMLVisitor::from_resource(const Resource& obj) throw(SerializerError)
|
||||
{
|
||||
throw SerializerError(
|
||||
_("XMLVisitor: unsupported method from_resource(const Resource& obj)")
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,9 +98,9 @@ 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());
|
||||
from_environment(parent, hist.get_last_environment());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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."));
|
||||
}
|
||||
|
@ -124,10 +122,10 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
|
|||
xmlNodePtr resources_node = xmlNewChild(parent, NULL, (const xmlChar *) "resources", NULL);
|
||||
const Environment::Resources& rvect = env.get_resources();
|
||||
typedef Environment::Resources::const_iterator res_iterator;
|
||||
|
||||
|
||||
res_iterator iter = rvect.begin();
|
||||
res_iterator end = rvect.end();
|
||||
while(iter!=end)
|
||||
while (iter != end)
|
||||
{
|
||||
//XMLVisitor xvisit(resources_node);
|
||||
Glib::ustring key;
|
||||
|
@ -144,10 +142,10 @@ void XMLVisitor::from_environment(xmlNodePtr parent, const Environment& env) thr
|
|||
xmlNodePtr schedulables_node = xmlNewChild(parent, NULL, (const xmlChar *) "schedulables", NULL);
|
||||
const Environment::Processes& pvect = env.get_processes();
|
||||
typedef std::vector<Process*>::const_iterator proc_iterator;
|
||||
|
||||
|
||||
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,10 +203,10 @@ 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;
|
||||
|
||||
|
||||
from_thread(threads_node, *(*iter));
|
||||
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;
|
||||
|
@ -237,7 +235,7 @@ void XMLVisitor::from_thread(xmlNodePtr parent, const Thread& obj) throw(Seriali
|
|||
xmlNewProp(thread_node, (const xmlChar *) "priority", (const xmlChar *) strPriority.c_str());
|
||||
xmlNewProp(thread_node, (const xmlChar *) "arrival-delta", (const xmlChar *) strArrivalTime.c_str());
|
||||
xmlNewProp(thread_node, (const xmlChar *) "lasts-for", (const xmlChar *) strLastsTime.c_str());
|
||||
|
||||
|
||||
// make a requests subnode
|
||||
xmlNodePtr requests_node = xmlNewChild(thread_node, NULL, (const xmlChar *) "requests", NULL);
|
||||
// iterate on requests
|
||||
|
@ -246,10 +244,10 @@ 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;
|
||||
|
||||
|
||||
from_request(requests_node, *(*iter));
|
||||
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;
|
||||
|
@ -271,7 +269,7 @@ void XMLVisitor::from_request(xmlNodePtr parent, const Request& obj) throw(Seria
|
|||
|
||||
xmlNodePtr request_node = xmlNewChild(parent, NULL, (const xmlChar *) "request", NULL);
|
||||
xmlNewProp(request_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str());
|
||||
|
||||
|
||||
// make a requests subnode
|
||||
// xmlNodePtr subrequests_node = xmlNewChild(thread_node, NULL, (const xmlChar *) "requests", NULL);
|
||||
// iterate on subrequests
|
||||
|
@ -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;
|
||||
|
|
|
@ -83,39 +83,39 @@ namespace sgpem
|
|||
Throw an exception.
|
||||
*/
|
||||
virtual void from_resource(const Resource& obj) throw(SerializerError);
|
||||
|
||||
|
||||
/**
|
||||
\brief Add output to the serializer taking data from resource and key
|
||||
BUG FIXED: This save a resource with her own associated key.
|
||||
Wrapper method: call from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key);
|
||||
*/
|
||||
virtual void from_resource(const Resource& obj, const Glib::ustring& key) throw(SerializerError);
|
||||
|
||||
|
||||
/**
|
||||
\brief Add output to the serializer taking data from process
|
||||
Wrapper method: call from_process(xmlNodePtr parent, const Process& obj);
|
||||
*/
|
||||
virtual void from_process(const Process& obj) throw(SerializerError);
|
||||
|
||||
|
||||
/**
|
||||
\brief Add output to the serializer taking data from thread
|
||||
Wrapper method: call from_thread(xmlNodePtr parent, const Thread& obj);
|
||||
*/
|
||||
virtual void from_thread(const Thread& obj) throw(SerializerError);
|
||||
|
||||
|
||||
/**
|
||||
\brief Add output to the serializer taking data from request
|
||||
Wrapper method: call from_request(xmlNodePtr parent, const Request& obj);
|
||||
*/
|
||||
virtual void from_request(const Request& obj) throw(SerializerError);
|
||||
|
||||
|
||||
/**
|
||||
\brief Add output to the serializer taking data from subrequest
|
||||
Wrapper method: call from_subrequest(xmlNodePtr parent, const SubRequest& obj);
|
||||
*/
|
||||
virtual void from_subrequest(const SubRequest& obj) throw(SerializerError);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void from_history(xmlNodePtr parent, const History& obj) throw(SerializerError);
|
||||
void from_environment(xmlNodePtr parent, const Environment& obj) throw(SerializerError);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue