- Fixed compilation errors caused by latest changes to serialization code

- Setup makefile for xmlsave plugin. It still can`t be activated. why?
- Added a temporary command SAVE to commandline interface to try serialization

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@826 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-08-07 00:54:43 +00:00
parent 574723a35b
commit 96728edfce
14 changed files with 95 additions and 36 deletions

View file

@ -88,9 +88,15 @@ libxmlsave_la_LDFLAGS = \
# Please keep this in sorted order:
libxmlsave_la_SOURCES = \
src/plugin.cc
src/plugin.cc \
src/xml_serializer.cc \
src/xml_serializer_factory.cc \
src/xml_visitor.cc
noinst_HEADERS +=
noinst_HEADERS += \
src/xml_serializer_factory.hh \
src/xml_serializer.hh \
src/xml_visitor.hh
# ############################################################
#

View file

@ -21,27 +21,30 @@
#include "config.h"
#include "plugin.hh"
#include "xml_serializer.hh"
//static XMLSerializer* _serializer = NULL;
using namespace sgpem;
sgpem::XMLSerializer* _serializer = NULL;
void
sgpem__Plugin__on_init()
{
// if(_serializer == NULL)
// _serializer = new sgpem::XMLSerializer();
if(_serializer == NULL)
_serializer = new sgpem::XMLSerializer();
}
void
sgpem__Plugin__on_exit()
{
// delete _serializer;
// _serializer = NULL;
delete _serializer;
_serializer = NULL;
}
const char*
sgpem__Plugin__describe()
{
return "";
return "This plugin saves the simulation to an XML file";
}
const char*

View file

@ -22,11 +22,11 @@
#include "xml_serializer_factory.hh"
#include "xml_visitor.hh"
#include "backend/environment.hh"
#include "backend/history.hh"
#include "backend/process.hh"
#include "backend/serializer_error.hh"
#include "backend/string_utils.hh"
#include "environment.hh"
#include "history.hh"
#include "process.hh"
#include "serializer_error.hh"
#include "string_utils.hh"
using namespace sgpem;
@ -40,7 +40,7 @@ XMLSerializer::XMLSerializer()
void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializeError)
void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializerError)
{
/* COMPAT: Do not genrate nodes for formatting spaces */
LIBXML_TEST_VERSION
@ -65,7 +65,7 @@ void XMLSerializer::save_snapshot(const Glib::ustring& filename, const History&
xmlCleanupParser();
}
void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializeError)
void XMLSerializer::restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializerError)
{
// TODO - all to do!!
// DEBUG - remove me when finished
@ -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
*/
throw SerializerError("ERROR: Compilation with SAX1 must be enabled! (?)");
#error Compilation of LIBXML with SAX1 support must be enabled
#endif /* LIBXML_SAX1_ENABLED */
}
@ -222,7 +222,7 @@ void XMLSerializer::clear_history(History& hist)
}
void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializeError)
void XMLSerializer::read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError)
{
/*
* Check the document is of the right kind

View file

@ -61,7 +61,7 @@ namespace sgpem
\throws backend::SerializerError on error
*/
virtual void save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializeError);
virtual void save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializerError);
/**
\brief Re-initialize system status from a saved XML snapshot
@ -72,7 +72,7 @@ namespace sgpem
\throws backend::SerializerError
*/
virtual void restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializeError);
virtual void restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializerError);
/**
\return Constant string "xsgp"
@ -124,7 +124,7 @@ namespace sgpem
Traverse the passed (previously readed) xml document and
rebuild the correct image using the XMLSerializerFactory object.
*/
void read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializeError);
void read_doc(xmlDocPtr doc, XMLSerializerFactory& fact) throw(SerializerError);
/**
\brief Restore all the resources from the passed xml node

View file

@ -25,7 +25,6 @@
#include "history.hh"
#include "resource.hh"
// #include "backend/process.hh"
#include "backend/serializer_error.hh"
using namespace sgpem;
@ -50,7 +49,7 @@ History* XMLSerializerFactory::get_history()
}
void
XMLSerializerFactory::factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializeError)
XMLSerializerFactory::factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializerError)
{
if(class_name == "Resource")
{
@ -241,7 +240,7 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
int old_key=0;
int lasts_for=0;
int places=1;
//int places=1;
Parameters::iterator pos;
resource_key_t new_key = 0;
@ -260,10 +259,10 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
}
// read "priority" property
pos = parameters.find(Glib::ustring("how-many"));
if (pos != parameters.end()) {
string_to_int(pos->second, places);
}
//pos = parameters.find(Glib::ustring("how-many"));
//if (pos != parameters.end()) {
// string_to_int(pos->second, places);
//}
// read "priority" property
pos = parameters.find(Glib::ustring("lasts-for"));
@ -271,7 +270,8 @@ XMLSerializerFactory::create_subrequest(Parameters& parameters)
string_to_int(pos->second, lasts_for);
}
return _hist->add_subrequest(*_last_request, new_key, (History::time_t)lasts_for, (History::size_t)places);
//FIXME places?
return _hist->add_subrequest(*_last_request, new_key, (History::time_t)lasts_for/*, (History::size_t)places*/);
}
// add a sub request - Request, resource_key, duration, places
}

View file

@ -24,6 +24,7 @@
#include "config.h"
#include "history.hh"
#include "environment.hh"
#include "serializer_error.hh"
#include <glibmm/ustring.h>
#include <map>
@ -76,7 +77,7 @@ namespace sgpem
\throw SerializerError If not all necessary parameters for an object creation are provided
*/
void factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializeError);
void factory_method(const Glib::ustring& class_name, Parameters& parameters) throw(SerializerError);
protected:
private:
typedef Environment::resource_key_t resource_key_t;

View file

@ -300,15 +300,16 @@ void XMLVisitor::from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw
{
Glib::ustring strResource;
Glib::ustring strHowMany;
//Glib::ustring strHowMany;
Glib::ustring strLastsFor;
int_to_string(obj.get_resource_key(), strResource);
int_to_string(obj.get_places(), strHowMany);
//FIXME places?
//int_to_string(obj.get_places(), strHowMany);
int_to_string(obj.get_length(), strLastsFor);
xmlNodePtr subrequest_node = xmlNewChild(parent, NULL, (const xmlChar *) "subrequest", NULL);
xmlNewProp(subrequest_node, (const xmlChar *) "resource", (const xmlChar *) strResource.c_str());
xmlNewProp(subrequest_node, (const xmlChar *) "how-many", (const xmlChar *) strHowMany.c_str());
//xmlNewProp(subrequest_node, (const xmlChar *) "how-many", (const xmlChar *) strHowMany.c_str());
xmlNewProp(subrequest_node, (const xmlChar *) "lasts-for", (const xmlChar *) strLastsFor.c_str());
}
else