sgpemv2/plugins/xmlsave/src/xml_visitor.hh

134 lines
4.2 KiB
C++
Raw Normal View History

// 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"
#include "serialize_visitor.hh"
#include <glibmm/ustring.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
namespace sgpem
{
class XMLVisitor;
/**
\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
{
public:
/**
\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.
*/
XMLVisitor(xmlNodePtr current);
/**
\brief A pretty virtual destructor
*/
virtual ~XMLVisitor();
/**
\brief Add output to the serializer taking data from history
Wrapper method: call from_history(xmlNodePtr parent, const History& obj);
*/
virtual void from_history(const History& obj);
/**
\brief Add output to the serializer taking data from environment
Wrapper method: call from_environment(xmlNodePtr parent, const Environment& obj);
*/
virtual void from_environment(const Environment& obj);
/**
\brief Add output to the serializer taking data from resource
BUG: a resource must be saved with her own associated key.
Throw an exception.
*/
virtual void from_resource(const Resource& obj);
/**
\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);
*/
virtual void from_resource(const Resource& obj, const Glib::ustring& key);
/**
\brief Add output to the serializer taking data from process
Wrapper method: call from_process(xmlNodePtr parent, const Process& obj);
*/
virtual void from_process(const Process& obj);
/**
\brief Add output to the serializer taking data from thread
Wrapper method: call from_thread(xmlNodePtr parent, const Thread& obj);
*/
virtual void from_thread(const Thread& obj);
/**
\brief Add output to the serializer taking data from request
Wrapper method: call from_request(xmlNodePtr parent, const Request& obj);
*/
virtual void from_request(const Request& obj);
/**
\brief Add output to the serializer taking data from subrequest
Wrapper method: call from_subrequest(xmlNodePtr parent, const SubRequest& obj);
*/
virtual void from_subrequest(const SubRequest& obj);
private:
void from_history(xmlNodePtr parent, const History& obj);
void from_environment(xmlNodePtr parent, const Environment& obj);
void from_resource(xmlNodePtr parent, const Resource& obj, const Glib::ustring& key);
void from_process(xmlNodePtr parent, const Process& obj);
void from_thread(xmlNodePtr parent, const Thread& obj);
void from_request(xmlNodePtr parent, const Request& obj);
void from_subrequest(xmlNodePtr parent, const SubRequest& obj);
xmlNodePtr _current;
};
}
#endif