- 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:
parent
574723a35b
commit
96728edfce
14 changed files with 95 additions and 36 deletions
|
@ -122,6 +122,10 @@ DynamicProcess::get_state() const
|
|||
if (future > 0) // running == 0 && ready == 0 && blocked == 0 && terminated == 0
|
||||
return state_future;
|
||||
|
||||
// I'm not sure if we can get here (maybe if there are no threads?),
|
||||
// but I don't like this compiler warning: 'control reaches end of non-void function'
|
||||
return state_future;
|
||||
|
||||
// Since premature optimization is the root of all evil, and the
|
||||
// following code was very fast but also very wrong, the coder
|
||||
// will be punished by allowing her to code in C++ just after
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
|
||||
using namespace sgpem;
|
||||
|
||||
Serializer::Serializer()
|
||||
{
|
||||
SerializersGatekeeper::get_instance().register_serializer(this);
|
||||
}
|
||||
|
||||
Serializer::~Serializer()
|
||||
{}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "history.hh"
|
||||
#include "serializer_error.hh"
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
|
@ -33,10 +34,11 @@ namespace sgpem
|
|||
class Serializer
|
||||
{
|
||||
public:
|
||||
Serializer();
|
||||
virtual ~Serializer() = 0;
|
||||
|
||||
virtual void save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializeError) = 0;
|
||||
virtual void restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializeError) = 0;
|
||||
virtual void save_snapshot(const Glib::ustring& filename, const History& hist) throw(SerializerError) = 0;
|
||||
virtual void restore_snapshot(const Glib::ustring& filename, History& hist) throw(SerializerError) = 0;
|
||||
virtual const Glib::ustring get_filename_extension() = 0;
|
||||
virtual const Glib::ustring get_filename_description() = 0;
|
||||
protected:
|
||||
|
|
|
@ -419,7 +419,7 @@ main(int argc, char** argv)
|
|||
}
|
||||
test << endl;
|
||||
|
||||
ThreadCreationData p1_3_d = { "p1_3", &p1, 3, 4 };
|
||||
ThreadCreationData p1_3_d = { "p1_3", &p1, 3, 4, 0 };
|
||||
|
||||
Thread& p1_3 = h.add_thread(p1_3_d.name,
|
||||
*p1_3_d.parent,
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "backend/cpu_policy_manager.hh"
|
||||
#include "backend/policy_parameters.hh"
|
||||
#include "backend/history.hh"
|
||||
#include "backend/serializers_gatekeeper.hh"
|
||||
#include "backend/serializer.hh"
|
||||
#include "backend/static_process.hh"
|
||||
#include "backend/static_resource.hh"
|
||||
#include "backend/static_thread.hh"
|
||||
|
@ -1288,6 +1290,37 @@ TextSimulation::on_remove_subrequest(const Tokens& arguments)
|
|||
h.remove(*r);
|
||||
}
|
||||
|
||||
void
|
||||
TextSimulation::on_save(const Tokens& arguments)
|
||||
{
|
||||
if(!check_arguments_num(arguments, 1))
|
||||
return;
|
||||
|
||||
ustring filename = arguments[0];
|
||||
|
||||
try
|
||||
{
|
||||
vector<Serializer*> serializers =
|
||||
SerializersGatekeeper::get_instance().get_registered();
|
||||
|
||||
Serializer& serializer = *serializers.at(0);
|
||||
|
||||
const History& history = Simulation::get_instance().get_history();
|
||||
|
||||
serializer.save_snapshot(filename, history);
|
||||
}
|
||||
catch(out_of_range e)
|
||||
{
|
||||
p_stderr(_("ERROR: No registered serializer available\n"));
|
||||
}
|
||||
catch(SerializerError e)
|
||||
{
|
||||
string msg = _("ERROR: ");
|
||||
|
||||
p_stderr(msg + e.what() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextSimulation::p_stdout(const ustring& str)
|
||||
{
|
||||
|
@ -1327,6 +1360,7 @@ TextSimulation::parse_command(TextSimulation& sim, const ustring& str)
|
|||
command_handlers["SHOW"] = &TextSimulation::on_show;
|
||||
command_handlers["ADD"] = &TextSimulation::on_add;
|
||||
command_handlers["REMOVE"] = &TextSimulation::on_remove;
|
||||
command_handlers["SAVE"] = &TextSimulation::on_save;
|
||||
command_handlers["QUIT"] = &TextSimulation::on_quit;
|
||||
|
||||
Tokens arguments = tokenize(str);
|
||||
|
|
|
@ -106,6 +106,7 @@ namespace sgpem
|
|||
void on_remove_thread(const Tokens& arguments);
|
||||
void on_remove_request(const Tokens& arguments);
|
||||
void on_remove_subrequest(const Tokens& arguments);
|
||||
void on_save(const Tokens& arguments);
|
||||
|
||||
// FIXME This is a temporary replacement for the
|
||||
// to-be written I/O layer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue