2006-07-08 07:54:21 +02:00
|
|
|
// 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 XML_VISITOR_HH
|
|
|
|
#define XML_VISITOR_HH 1
|
|
|
|
|
|
|
|
namespace sgpem
|
|
|
|
{
|
|
|
|
class Resource;
|
|
|
|
class Process;
|
|
|
|
class Thread;
|
|
|
|
class Request;
|
|
|
|
class SubRequest;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "config.h"
|
2006-07-15 03:28:35 +02:00
|
|
|
#include "serialize_visitor.hh"
|
2006-07-08 07:54:21 +02:00
|
|
|
|
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
#include <libxml/xmlmemory.h>
|
|
|
|
#include <libxml/parser.h>
|
|
|
|
|
|
|
|
namespace sgpem
|
|
|
|
{
|
|
|
|
class XMLVisitor;
|
|
|
|
|
2006-07-15 03:28:35 +02:00
|
|
|
/**
|
|
|
|
\brief Serialize objects to XML
|
|
|
|
|
|
|
|
This class is a concrete class derived from SerializeVisitor
|
|
|
|
and implements each methodto serialize
|
|
|
|
into an xml tree.
|
|
|
|
The pointer to the sgpem (root) node must be passed as constructor parameter.
|
|
|
|
*/
|
|
|
|
class XMLVisitor : public SerializeVisitor
|
2006-07-08 07:54:21 +02:00
|
|
|
{
|
|
|
|
public:
|
2006-07-15 03:28:35 +02:00
|
|
|
/**
|
|
|
|
\brief Class constructor to save to the passed XML tree
|
|
|
|
|
|
|
|
Build an XMLVisitor taking a pointer to an xml node as parameter.
|
|
|
|
Every called method see this node as his relative root.
|
|
|
|
*/
|
2006-07-08 07:54:21 +02:00
|
|
|
XMLVisitor(xmlNodePtr current);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief A pretty virtual destructor
|
|
|
|
*/
|
2006-07-08 07:54:21 +02:00
|
|
|
virtual ~XMLVisitor();
|
|
|
|
|
2006-07-15 03:28:35 +02:00
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from history
|
|
|
|
Wrapper method: call from_history(xmlNodePtr parent, const History& obj);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_history(const History& obj) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from environment
|
|
|
|
Wrapper method: call from_environment(xmlNodePtr parent, const Environment& obj);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_environment(const Environment& obj) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from resource
|
|
|
|
BUG: a resource must be saved with her own associated key.
|
|
|
|
Throw an exception.
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_resource(const Resource& obj) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\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);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_resource(const Resource& obj, const Glib::ustring& key) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from process
|
|
|
|
Wrapper method: call from_process(xmlNodePtr parent, const Process& obj);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_process(const Process& obj) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from thread
|
|
|
|
Wrapper method: call from_thread(xmlNodePtr parent, const Thread& obj);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_thread(const Thread& obj) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from request
|
|
|
|
Wrapper method: call from_request(xmlNodePtr parent, const Request& obj);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_request(const Request& obj) throw(SerializerError);
|
2006-07-15 03:28:35 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Add output to the serializer taking data from subrequest
|
|
|
|
Wrapper method: call from_subrequest(xmlNodePtr parent, const SubRequest& obj);
|
|
|
|
*/
|
2006-08-04 02:29:37 +02:00
|
|
|
virtual void from_subrequest(const SubRequest& obj) throw(SerializerError);
|
2006-07-11 02:06:40 +02:00
|
|
|
|
2006-07-15 03:28:35 +02:00
|
|
|
|
2006-07-08 07:54:21 +02:00
|
|
|
private:
|
2006-08-04 02:29:37 +02:00
|
|
|
void from_history(xmlNodePtr parent, const History& obj) throw(SerializerError);
|
|
|
|
void from_environment(xmlNodePtr parent, const Environment& obj) throw(SerializerError);
|
|
|
|
void from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key) throw(SerializerError);
|
|
|
|
void from_process(xmlNodePtr parent, const Process& obj) throw(SerializerError);
|
|
|
|
void from_thread(xmlNodePtr parent, const Thread& obj) throw(SerializerError);
|
|
|
|
void from_request(xmlNodePtr parent, const Request& obj) throw(SerializerError);
|
|
|
|
void from_subrequest(xmlNodePtr parent, const SubRequest& obj) throw(SerializerError);
|
2006-07-11 02:06:40 +02:00
|
|
|
|
2006-07-08 07:54:21 +02:00
|
|
|
xmlNodePtr _current;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|