- Written code for plugin management system, some code is missing (Matteo, please...)
- TODO Integrate this new plugin management system into the application git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@697 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
7d62f4b937
commit
fac2a08e26
|
@ -156,6 +156,9 @@ src_backend_libbackend_la_SOURCES = \
|
||||||
src/backend/global_preferences.cc \
|
src/backend/global_preferences.cc \
|
||||||
src/backend/history.cc \
|
src/backend/history.cc \
|
||||||
src/backend/history_observer.cc \
|
src/backend/history_observer.cc \
|
||||||
|
src/backend/invalid_plugin_exception.cc \
|
||||||
|
src/backend/module.cc \
|
||||||
|
src/backend/plugin_manager.cc \
|
||||||
src/backend/policies_gatekeeper.cc \
|
src/backend/policies_gatekeeper.cc \
|
||||||
src/backend/policy.cc \
|
src/backend/policy.cc \
|
||||||
src/backend/policy_manager.cc \
|
src/backend/policy_manager.cc \
|
||||||
|
@ -186,7 +189,10 @@ pkginclude_HEADERS += \
|
||||||
src/backend/global_preferences.hh \
|
src/backend/global_preferences.hh \
|
||||||
src/backend/history.hh \
|
src/backend/history.hh \
|
||||||
src/backend/history_observer.hh \
|
src/backend/history_observer.hh \
|
||||||
|
src/backend/invalid_plugin_exception.hh \
|
||||||
|
src/backend/module.hh \
|
||||||
src/backend/plugin.hh \
|
src/backend/plugin.hh \
|
||||||
|
src/backend/plugin_manager.hh \
|
||||||
src/backend/policies_gatekeeper.hh \
|
src/backend/policies_gatekeeper.hh \
|
||||||
src/backend/policy.hh \
|
src/backend/policy.hh \
|
||||||
src/backend/policy_manager.hh \
|
src/backend/policy_manager.hh \
|
||||||
|
|
|
@ -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 INVALID_PLUGIN_EXCEPTION_HH
|
||||||
|
#define INVALID_PLUGIN_EXCEPTION_HH 1
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace sgpem
|
||||||
|
{
|
||||||
|
class InvalidPluginException : std::runtime_error
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InvalidPluginException(const std::string& what);
|
||||||
|
}; //~ class InvalidPluginException
|
||||||
|
|
||||||
|
} //~ namespace sgpem
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,74 @@
|
||||||
|
// src/backend/module.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
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "module.hh"
|
||||||
|
|
||||||
|
using namespace sgpem;
|
||||||
|
|
||||||
|
Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) :
|
||||||
|
Glib::Module(identifier), _enabled(false), _id(identifier)
|
||||||
|
{
|
||||||
|
//FIXME Don't know what to doh!!!
|
||||||
|
throw InvalidPluginException(Glib::Module::get_last_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Module::set_enabled(bool enabled)
|
||||||
|
{
|
||||||
|
//FIXME Don't know what to doh!!!
|
||||||
|
_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
Glib::ustring
|
||||||
|
Module::get_name() const
|
||||||
|
{
|
||||||
|
//FIXME Don't know what to doh!!!
|
||||||
|
return "doh!";
|
||||||
|
}
|
||||||
|
|
||||||
|
Glib::ustring
|
||||||
|
Module::get_author() const
|
||||||
|
{
|
||||||
|
//FIXME Don't know what to doh!!!
|
||||||
|
return "doh! doh!";
|
||||||
|
}
|
||||||
|
|
||||||
|
Glib::ustring
|
||||||
|
Module::describe() const
|
||||||
|
{
|
||||||
|
//FIXME Don't know what to doh!!!
|
||||||
|
return "homer insists in saying doh!";
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
Module::get_version() const
|
||||||
|
{
|
||||||
|
//FIXME Don't know what to doh!!!
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Module::get_enabled() const
|
||||||
|
{
|
||||||
|
return _enabled;
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
// src/backend/module.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 MODULE_HH
|
||||||
|
#define MODULE_HH 1
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "invalid_plugin_exception.hh"
|
||||||
|
|
||||||
|
#include <glibmm/module.h>
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
|
namespace sgpem
|
||||||
|
{
|
||||||
|
class Module;
|
||||||
|
|
||||||
|
class Module : public Glib::Module
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Module(const Glib::ustring& identifier) throw(InvalidPluginException);
|
||||||
|
|
||||||
|
void set_enabled(bool enabled = true);
|
||||||
|
|
||||||
|
Glib::ustring get_name() const;
|
||||||
|
|
||||||
|
Glib::ustring get_author() const;
|
||||||
|
|
||||||
|
Glib::ustring describe() const;
|
||||||
|
|
||||||
|
float get_version() const;
|
||||||
|
|
||||||
|
bool get_enabled() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _enabled;
|
||||||
|
Glib::ustring _id;
|
||||||
|
|
||||||
|
}; //~ class Module
|
||||||
|
|
||||||
|
} //~ namespace sgpem
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
// src/backend/plugin_manager.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 "plugin_manager.hh"
|
||||||
|
#include "module.hh"
|
||||||
|
#include "global_preferences.hh"
|
||||||
|
|
||||||
|
#include "singleton.tcc"
|
||||||
|
|
||||||
|
#include <glibmm/fileutils.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace sgpem;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
template class Singleton<PluginManager>;
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<Module*>
|
||||||
|
PluginManager::get_module_list() const
|
||||||
|
{
|
||||||
|
return _modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PluginManager::rescan_dirs()
|
||||||
|
{
|
||||||
|
Module* module = NULL;
|
||||||
|
|
||||||
|
for_each(_modules.begin(), _modules.end(), ptr_fun(operator delete));
|
||||||
|
_modules.clear();
|
||||||
|
|
||||||
|
GlobalPreferences& prefs = GlobalPreferences::get_instance();
|
||||||
|
GlobalPreferences::dir_iterator it = prefs.modules_dir_begin();
|
||||||
|
|
||||||
|
while(it != prefs.modules_dir_end())
|
||||||
|
{
|
||||||
|
Glib::Dir dir(*it);
|
||||||
|
|
||||||
|
for(Glib::DirIterator dir_it = dir.begin(); dir_it != dir.end(); ++dir_it)
|
||||||
|
{
|
||||||
|
std::string module_path = Module::build_path(*it, *dir_it);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
module = new Module(module_path);
|
||||||
|
|
||||||
|
if(*module)
|
||||||
|
_modules.push_back(module);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << Glib::Module::get_last_error() << std::endl;
|
||||||
|
delete module;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(InvalidPluginException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginManager::PluginManager()
|
||||||
|
{
|
||||||
|
rescan_dirs();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
// src/backend/plugin_manager.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 PLUGIN_MANAGER_HH
|
||||||
|
#define PLUGIN_MANAGER_HH 1
|
||||||
|
|
||||||
|
namespace sgpem
|
||||||
|
{
|
||||||
|
class Module;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "singleton.hh"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sgpem
|
||||||
|
{
|
||||||
|
class PluginManager;
|
||||||
|
|
||||||
|
class PluginManager : public Singleton<PluginManager>
|
||||||
|
{
|
||||||
|
friend class Singleton<PluginManager>;
|
||||||
|
public:
|
||||||
|
std::vector<Module*> get_module_list() const;
|
||||||
|
|
||||||
|
void rescan_dirs();
|
||||||
|
|
||||||
|
private:
|
||||||
|
PluginManager();
|
||||||
|
|
||||||
|
std::vector<Module*> _modules;
|
||||||
|
|
||||||
|
}; //~ class PluginManager
|
||||||
|
|
||||||
|
} //~ namespace sgpem
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue