From dd4898ca55bb896b9a267fed4bab531670569a70 Mon Sep 17 00:00:00 2001 From: elvez Date: Tue, 4 Jul 2006 22:34:39 +0000 Subject: [PATCH] - Added SerializeVisitor class and written various serialize() methods git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@716 3ecf2c5c-341e-0410-92b4-d18e462d057c --- Makefile.am | 2 ++ src/backend/dynamic_process.cc | 3 +- src/backend/dynamic_request.cc | 3 +- src/backend/dynamic_resource.cc | 3 +- src/backend/dynamic_sub_request.cc | 3 +- src/backend/dynamic_thread.cc | 3 +- src/backend/serialize_visitor.cc | 27 +++++++++++++++ src/backend/serialize_visitor.hh | 55 ++++++++++++++++++++++++++++++ 8 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 src/backend/serialize_visitor.cc create mode 100644 src/backend/serialize_visitor.hh diff --git a/Makefile.am b/Makefile.am index 1eac1c5..1df2919 100644 --- a/Makefile.am +++ b/Makefile.am @@ -170,6 +170,7 @@ src_backend_libbackend_la_SOURCES = \ src/backend/resource.cc \ src/backend/schedulable.cc \ src/backend/scheduler.cc \ + src/backend/serialize_visitor.cc \ src/backend/static_process.cc \ src/backend/static_request.cc \ src/backend/static_resource.cc \ @@ -203,6 +204,7 @@ pkginclude_HEADERS += \ src/backend/process.hh \ src/backend/schedulable.hh \ src/backend/scheduler.hh \ + src/backend/serialize_visitor.cc \ src/backend/sub_request.hh \ src/backend/thread.hh \ src/backend/user_interrupt_exception.hh diff --git a/src/backend/dynamic_process.cc b/src/backend/dynamic_process.cc index 1640e26..779197b 100644 --- a/src/backend/dynamic_process.cc +++ b/src/backend/dynamic_process.cc @@ -21,6 +21,7 @@ #include "dynamic_process.hh" #include "static_process.hh" #include "dynamic_thread.hh" +#include "serialize_visitor.hh" #include #include @@ -133,7 +134,7 @@ DynamicProcess::get_state() const void DynamicProcess::serialize(SerializeVisitor& translator) const { - //FIXME write this code. I'm predictable, I know + translator.from_process(*_core); } StaticProcess& diff --git a/src/backend/dynamic_request.cc b/src/backend/dynamic_request.cc index b5cc072..ae926d6 100644 --- a/src/backend/dynamic_request.cc +++ b/src/backend/dynamic_request.cc @@ -22,6 +22,7 @@ #include "static_request.hh" #include "dynamic_sub_request.hh" #include "dynamic_thread.hh" +#include "serialize_visitor.hh" #include "smartp.tcc" @@ -92,7 +93,7 @@ DynamicRequest::get_state() const void DynamicRequest::serialize(SerializeVisitor& translator) const { - // Let a drunk monkey write this code ;P + translator.from_request(*this); } diff --git a/src/backend/dynamic_resource.cc b/src/backend/dynamic_resource.cc index fe55eeb..e42bc82 100644 --- a/src/backend/dynamic_resource.cc +++ b/src/backend/dynamic_resource.cc @@ -20,6 +20,7 @@ #include "dynamic_resource.hh" #include "static_resource.hh" +#include "serialize_visitor.hh" #include "smartp.tcc" @@ -55,7 +56,7 @@ DynamicResource::get_places() const void DynamicResource::serialize(SerializeVisitor& translator) const { - // Let a drunk monkey write this code ;P + translator.from_resource(*this); } StaticResource& diff --git a/src/backend/dynamic_sub_request.cc b/src/backend/dynamic_sub_request.cc index 274ab43..e66b19c 100644 --- a/src/backend/dynamic_sub_request.cc +++ b/src/backend/dynamic_sub_request.cc @@ -20,6 +20,7 @@ #include "dynamic_sub_request.hh" #include "dynamic_request.hh" +#include "serialize_visitor.hh" #include "smartp.tcc" @@ -92,7 +93,7 @@ DynamicSubRequest::get_request() void DynamicSubRequest::serialize(SerializeVisitor& translator) const { - //blah blah blah TODO + translator.from_subrequest(*this); } diff --git a/src/backend/dynamic_thread.cc b/src/backend/dynamic_thread.cc index 6ed594d..ed57beb 100644 --- a/src/backend/dynamic_thread.cc +++ b/src/backend/dynamic_thread.cc @@ -21,6 +21,7 @@ #include "dynamic_thread.hh" #include "static_thread.hh" #include "dynamic_request.hh" +#include "serialize_visitor.hh" #include #include @@ -89,7 +90,7 @@ DynamicThread::get_requests() void DynamicThread::serialize(SerializeVisitor& translator) const { - // TODO fill-in appropriate code + translator.from_thread(*_core); } StaticThread& diff --git a/src/backend/serialize_visitor.cc b/src/backend/serialize_visitor.cc new file mode 100644 index 0000000..ef5160b --- /dev/null +++ b/src/backend/serialize_visitor.cc @@ -0,0 +1,27 @@ +// src/backend/serialize_visitor.cc - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#include "serialize_visitor.hh" + +using namespace sgpem; + +SerializeVisitor::~SerializeVisitor() +{} + diff --git a/src/backend/serialize_visitor.hh b/src/backend/serialize_visitor.hh new file mode 100644 index 0000000..27f24ce --- /dev/null +++ b/src/backend/serialize_visitor.hh @@ -0,0 +1,55 @@ +// src/backend/serialize_visitor.hh - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef SERIALIZE_VISITOR_HH +#define SERIALIZE_VISITOR_HH 1 + +namespace sgpem +{ + class Resource; + class StaticProcess; + class StaticThread; + class Request; + class SubRequest; +} + +#include "config.h" + +#include + +namespace sgpem +{ + class SerializeVisitor; + + class SerializeVisitor + { + public: + virtual ~SerializeVisitor() = 0; + + virtual void from_resource(const Resource& obj) = 0; + virtual void from_process(const StaticProcess& obj) = 0; + virtual void from_thread(const StaticThread& obj) = 0; + virtual void from_request(const Request& obj) = 0; + virtual void from_subrequest(const SubRequest& obj) = 0; + }; +} + +#endif +