- definive fix of xml serialization

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@769 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
paolo 2006-07-15 11:29:20 +00:00
parent 1ea164cb23
commit d26ee57e3c
3 changed files with 9 additions and 31 deletions

View File

@ -96,22 +96,18 @@ main(int argc, char** argv)
os2 << ends; // null terminated string os2 << ends; // null terminated string
cout << "dump hist(t2) in print format into os2" << endl; cout << "dump hist(t2) in print format into os2" << endl;
// int cmp = strcmp((const char *)os1.str(), (const char *)os2.str());
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;
// cout << "strcmp Comparing dump of hist(t1) and hist(t2): " << strcmp(os1.str().c_str(), os2.str().c_str()) << endl;
ConcreteHistory hist2; ConcreteHistory hist2;
xmlser.restore_snapshot(outfile, hist2); xmlser.restore_snapshot(outfile, hist2);
cout << "create ConcreteHistory hist" << endl; 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;
// cout << "history2 - copy of history " << endl;
dumpEnvironment(hist2.get_last_environment(), os3); dumpEnvironment(hist2.get_last_environment(), os3);
os3 << ends; // null terminated string os3 << ends; // null terminated string
cout << "dump hist2(t3) in print format into os3" << endl; 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;
// cout << "strcmp Comparing dump of hist(t1) and hist2(t3): " << strcmp(os1.str().c_str(), os3.str().c_str()) << endl;
xmlser.restore_snapshot(outfile, hist); 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;
@ -121,29 +117,6 @@ main(int argc, char** argv)
cout << "dump hist(t3) in print format into os4" << endl; 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;
// cout << "strcmp Comparing dump of hist(t1) and hist(t4): " << strcmp(os1.str().c_str(), os4.str().c_str()) << endl;
/*
cout << "************ REDUMP..." << endl;
cout << os1.str() << endl << "**********" << endl;
cout << "************ REDUMP..." << endl;
cout << os2.str() << endl << "**********" << endl;
cout << "************ REDUMP..." << endl;
cout << os3.str() << endl << "**********" << endl;
cout << "************ REDUMP..." << endl;
cout << os4.str() << endl << "**********" << endl;
cout << "strcmp 1 e 1 " << strcmp(os1.str().c_str(), os1.str().c_str()) << endl;
cout << "strcmp 1 e 2 " << strcmp(os1.str().c_str(), os2.str().c_str()) << endl;
cout << "strcmp 1 e 3 " << strcmp(os1.str().c_str(), os3.str().c_str()) << endl;
cout << "strcmp 1 e 4 " << strcmp(os1.str().c_str(), os4.str().c_str()) << endl;
cout << "strcmp 2 e 3 " << strcmp(os2.str().c_str(), os3.str().c_str()) << endl;
cout << "strcmp 2 e 4 " << strcmp(os2.str().c_str(), os4.str().c_str()) << endl;
cout << "strcmp 3 e 4 " << strcmp(os3.str().c_str(), os4.str().c_str()) << endl;
// typedef std::vector<Process*> Processes;
*/
int ret = 1; int ret = 1;
if(os1.str()!=os2.str() if(os1.str()!=os2.str()

View File

@ -99,11 +99,15 @@ XMLSerializerFactory::create_resource(Parameters& parameters)
} }
// read "key" property // read "key" property
pos = parameters.find(Glib::ustring("key")); pos = parameters.find(Glib::ustring("id"));
if (pos != parameters.end()) { if (pos != parameters.end()) {
key = pos->second; Glib::ustring id = key = pos->second;
if(id.length()>6 && id.substr(0,6)==Glib::ustring("reskey"))
{
key = id.substr(6);
string_to_int(key, old_key); string_to_int(key, old_key);
} }
}
// read "preemptable" property // read "preemptable" property
pos = parameters.find(Glib::ustring("preemptable")); pos = parameters.find(Glib::ustring("preemptable"));

View File

@ -162,6 +162,7 @@ void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Gli
{ {
if(parent!=NULL) if(parent!=NULL)
{ {
Glib::ustring id = "reskey" + key;
Glib::ustring strPreemptible("false"); // fixed?? Glib::ustring strPreemptible("false"); // fixed??
Glib::ustring strArrivalTime("0"); // fixed?? Glib::ustring strArrivalTime("0"); // fixed??
Glib::ustring strPlaces; Glib::ustring strPlaces;
@ -169,7 +170,7 @@ void XMLVisitor::from_resource(xmlNodePtr parent, const Resource& obj, const Gli
xmlNodePtr process_node = xmlNewChild(parent, NULL, (const xmlChar *) "resource", NULL); xmlNodePtr process_node = xmlNewChild(parent, NULL, (const xmlChar *) "resource", NULL);
xmlNewProp(process_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str()); xmlNewProp(process_node, (const xmlChar *) "name", (const xmlChar *) obj.get_name().c_str());
xmlNewProp(process_node, (const xmlChar *) "key", (const xmlChar *) key.c_str()); xmlNewProp(process_node, (const xmlChar *) "id", (const xmlChar *) id.c_str());
xmlNewProp(process_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str()); xmlNewProp(process_node, (const xmlChar *) "arrival-time", (const xmlChar *) strArrivalTime.c_str());
xmlNewProp(process_node, (const xmlChar *) "how-many", (const xmlChar *) strPlaces.c_str()); xmlNewProp(process_node, (const xmlChar *) "how-many", (const xmlChar *) strPlaces.c_str());
xmlNewProp(process_node, (const xmlChar *) "pre-emptible", (const xmlChar *) strPreemptible.c_str()); xmlNewProp(process_node, (const xmlChar *) "pre-emptible", (const xmlChar *) strPreemptible.c_str());