- Fix compilation of backend::Module

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@705 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-07-04 08:27:51 +00:00
parent 9a7b39ed82
commit cb3305c425
2 changed files with 30 additions and 29 deletions

View File

@ -25,23 +25,24 @@
using namespace sgpem; using namespace sgpem;
Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) : Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) :
Glib::Module(identifier), _enabled(false), _id(identifier) 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)
{ {
// too stuff to put it on an inizialization list, don't you think? // Type-safeness here is an optional, as always. :-)
on_init_ptr = NULL; if(!(get_symbol("on_init", (void*&) on_init_ptr) &&
on_exit_ptr = NULL; get_symbol("on_exit", (void*&) on_exit_ptr) &&
describe_ptr = NULL; get_symbol("describe", (void*&) describe_ptr) &&
get_name_ptr = NULL; get_symbol("get_name", (void*&) get_name_ptr) &&
get_author_ptr = NULL; get_symbol("get_author", (void*&) get_author_ptr) &&
get_version_ptr = NULL; get_symbol("get_version", (void*&) get_version_ptr)))
throw InvalidPluginException("incomplete/wrong exported interface");
if(!(get_symbol("on_init", on_init_ptr) &&
get_symbol("on_exit", on_exit_ptr) &&
get_symbol("describe", describe_ptr) &&
get_symbol("get_name", get_name_ptr) &&
get_symbol("get_author", get_author_ptr) &&
get_symbol("get_version", get_version_ptr)))
throw InvalidPluginException("incomplete/wrong exported interface");
} }
@ -52,9 +53,9 @@ Module::set_enabled(bool enabled)
return; return;
if(enabled) if(enabled)
reinterpret_cast<f_void>(on_init_ptr)(); on_init_ptr();
else else
reinterpret_cast<f_void>(on_exit_ptr)(); on_exit_ptr();
_enabled = enabled; _enabled = enabled;
} }
@ -62,25 +63,25 @@ Module::set_enabled(bool enabled)
Glib::ustring Glib::ustring
Module::get_name() const Module::get_name() const
{ {
return reinterpret_cast<f_ustring>(get_name_ptr)(); return get_name_ptr();
} }
Glib::ustring Glib::ustring
Module::get_author() const Module::get_author() const
{ {
return reinterpret_cast<f_ustring>(get_author_ptr)(); return get_author_ptr();
} }
Glib::ustring Glib::ustring
Module::describe() const Module::describe() const
{ {
return reinterpret_cast<f_ustring>(describe_ptr)(); return describe_ptr();
} }
float float
Module::get_version() const Module::get_version() const
{ {
return reinterpret_cast<f_float>(get_version_ptr)(); return get_version_ptr();
} }
bool bool

View File

@ -57,12 +57,12 @@ namespace sgpem
bool _enabled; bool _enabled;
Glib::ustring _id; Glib::ustring _id;
void* on_init_ptr; f_void on_init_ptr;
void* on_exit_ptr; f_void on_exit_ptr;
void* describe_ptr; f_ustring describe_ptr;
void* get_name_ptr; f_ustring get_name_ptr;
void* get_author_ptr; f_ustring get_author_ptr;
void* get_version_ptr; f_float get_version_ptr;
}; //~ class Module }; //~ class Module