sgpemv2/src/backend/module.cc
tchernobog d128ee8608 - Fix portability issues with config.h header. Now it is
included by the compiler (via a flag) and the visibility
macros have been moved to a separate header. You'll
probably need to cleanup your source dir and re-run autogen.sh
before compiling sgpem again.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1191 3ecf2c5c-341e-0410-92b4-d18e462d057c
2006-09-16 13:34:43 +00:00

96 lines
2.3 KiB
C++

// 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 <sgpemv2/module.hh>
using namespace sgpem;
Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) :
Glib::Module(identifier),
_enabled(false),
_id(identifier),
on_init_ptr(NULL),
on_exit_ptr(NULL),
describe_ptr(NULL),
get_name_ptr(NULL),
get_author_ptr(NULL),
get_version_ptr(NULL)
{
if (!*this) throw InvalidPluginException(Module::get_last_error());
// Type-safeness here is an optional, as always. :-)
std::string prefix = "sgpem__Plugin__";
if (!(get_symbol(prefix + "on_init", (void*&) on_init_ptr) &&
get_symbol(prefix + "on_exit", (void*&) on_exit_ptr) &&
get_symbol(prefix + "describe", (void*&) describe_ptr) &&
get_symbol(prefix + "get_name", (void*&) get_name_ptr) &&
get_symbol(prefix + "get_author", (void*&) get_author_ptr) &&
get_symbol(prefix + "get_version", (void*&) get_version_ptr)))
throw InvalidPluginException("incomplete/wrong exported interface");
}
void
Module::set_enabled(bool enabled)
{
if (_enabled == enabled)
return;
if (enabled)
on_init_ptr();
else
on_exit_ptr();
_enabled = enabled;
}
Glib::ustring
Module::get_name() const
{
return get_name_ptr();
}
Glib::ustring
Module::get_author() const
{
return get_author_ptr();
}
Glib::ustring
Module::describe() const
{
return describe_ptr();
}
float
Module::get_version() const
{
return get_version_ptr();
}
bool
Module::get_enabled() const
{
return _enabled;
}