- added classes needed by serialization
- serializers_gatekeeper - serializer - serializer_error - serializer_visitor (should replace serialize_visitor) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@742 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
c1d104dba8
commit
4d862a3c2f
|
@ -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 "serializer.hh"
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
Serializer::~Serializer()
|
||||
{}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
// src/backend/serializer.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 SERIALIZER_HH
|
||||
#define SERIALIZER_HH 1
|
||||
|
||||
#include "config.h"
|
||||
#include "backend/history.hh"
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class Serializer;
|
||||
|
||||
class Serializer
|
||||
{
|
||||
public:
|
||||
virtual ~Serializer() = 0;
|
||||
|
||||
virtual void save_snapshot(const Glib::ustring& filename, const History& hist) = 0;
|
||||
virtual void restore_snapshot(const Glib::ustring& filename, History& hist) = 0;
|
||||
virtual const Glib::ustring get_filename_extension() = 0;
|
||||
virtual const Glib::ustring get_filename_description() = 0;
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
// src/backend/invalid_plugin_exception.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 "config.h"
|
||||
|
||||
#include "serializer_error.hh"
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
SerializerError::SerializerError(const std::string& what) :
|
||||
std::runtime_error(what)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// src/backend/invalid_plugin_exception.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 SERIALIZER_ERROR_HH
|
||||
#define SERIALIZER_ERROR_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class SerializerError : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
SerializerError(const std::string& what);
|
||||
}; //~ class SerializerError
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
||||
#endif
|
|
@ -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 "serializer_visitor.hh"
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
SerializerVisitor::~SerializerVisitor()
|
||||
{}
|
||||
|
|
@ -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 SERIALIZER_VISITOR_HH
|
||||
#define SERIALIZER_VISITOR_HH 1
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class Resource;
|
||||
class Process;
|
||||
class Thread;
|
||||
class Request;
|
||||
class SubRequest;
|
||||
}
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class SerializerVisitor;
|
||||
|
||||
class SerializerVisitor
|
||||
{
|
||||
public:
|
||||
virtual ~SerializerVisitor() = 0;
|
||||
|
||||
virtual void from_resource(const Resource& obj) = 0;
|
||||
virtual void from_process(const Process& obj) = 0;
|
||||
virtual void from_thread(const Thread& obj) = 0;
|
||||
virtual void from_request(const Request& obj) = 0;
|
||||
virtual void from_subrequest(const SubRequest& obj) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
// src/backend/policies_gatekeeper.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 "config.h"
|
||||
|
||||
#include "serializers_gatekeeper.hh"
|
||||
#include "serializer.hh"
|
||||
|
||||
// Include full template definition only in implementation files:
|
||||
#include "singleton.tcc"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
using std::vector;
|
||||
using std::find;
|
||||
using std::runtime_error;
|
||||
using namespace sgpem;
|
||||
|
||||
// Explicit template instantiation to allow to export symbols from the DSO.
|
||||
template class SG_DLLEXPORT Singleton<SerializersGatekeeper>;
|
||||
|
||||
typedef vector<Serializer*>::iterator SerializerIterator;
|
||||
|
||||
vector<Serializer*>
|
||||
SerializersGatekeeper::get_registered() const
|
||||
{
|
||||
return _registered;
|
||||
}
|
||||
|
||||
void
|
||||
SerializersGatekeeper::register(Serializer* serializer)
|
||||
{
|
||||
assert(serializer != NULL);
|
||||
|
||||
SerializerIterator end = _registered.end();
|
||||
|
||||
if(find(_registered.begin(), end, serializer) == end)
|
||||
_registered.push_back(serializer);
|
||||
}
|
||||
|
||||
void
|
||||
SerializersGatekeeper::unregister(Serializer* serializer)
|
||||
{
|
||||
assert(serializer != NULL);
|
||||
|
||||
SerializerIterator end = _registered.end();
|
||||
SerializerIterator pos = find(_registered.begin(), end, serializer);
|
||||
|
||||
if(pos != end)
|
||||
{
|
||||
_registered.erase(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
SerializersGatekeeper::PoliciesGatekeeper()
|
||||
{}
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
// src/backend/policies_gatekeeper.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 SERIALIZERS_GATEKEEPER_HH
|
||||
#define SERIALIZERS_GATEKEEPER_HH 1
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class Serializer;
|
||||
}
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "singleton.hh"
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class SerializersGatekeeper;
|
||||
|
||||
/** \brief Keeps all registered serializer in order to access to available serializers
|
||||
|
||||
This Singleton derived class keep every registered Serializer in order to
|
||||
give more file saving formats using disticnt Serializers.
|
||||
|
||||
*/
|
||||
|
||||
class SG_DLLEXPORT SerializersGatekeeper : public Singleton<SerializersGatekeeper>
|
||||
{
|
||||
friend class Singleton<SerializersGatekeeper>;
|
||||
|
||||
public:
|
||||
/** \brief Gets the registered serializers container
|
||||
*/
|
||||
std::vector<Serializer*> get_registered() const;
|
||||
|
||||
/** \brief Add a serializer to the serializers container
|
||||
*/
|
||||
void register(Serializer* serializer);
|
||||
|
||||
/** \brief Remove a serializer from the serializers container
|
||||
*/
|
||||
void unregister(Serializer* serializer);
|
||||
|
||||
private:
|
||||
SerializersGatekeeper(); //private constructor.
|
||||
SerializersGatekeeper(const SerializersGatekeeper&);
|
||||
SerializersGatekeeper& operator=(const SerializersGatekeeper&);
|
||||
|
||||
/** \brief The registered serializers container
|
||||
|
||||
*/
|
||||
std::vector<Serializer*> _registered;
|
||||
};
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
#endif //SERIALIZERS_GATEKEEPER_HH
|
||||
|
Loading…
Reference in New Issue