/* -*- mia-c++ -*-
*
* Copyright (c) 2007 Gert Wollny <gert dot wollny at acm dot org>
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <sstream>
#include <stdexcept>
#include <mia/core/msgstream.hh>
#include <mia/core/module.hh>
NS_MIA_BEGIN
CPluginModule::CPluginModule(const char *path):
_M_module(g_module_open(path, G_MODULE_BIND_MASK))
{
if (!_M_module) {
stringstream msg;
msg << "Module '" << path << "' can not be loaded";
throw invalid_argument(msg.str());
}
}
CPluginModule::~CPluginModule()
{
// g_module_close(_M_module);
}
CPluginBase *CPluginModule::get_interface() const
{
union {
FPluginInterface f;
gpointer pointer;
}interface;
if (!g_module_symbol(_M_module, "get_plugin_interface", &interface.pointer)) {
cvdebug() << "g_module_symbol 'get_plugin_interface' failed\n";
return NULL;
}
return interface.f();
}
NS_MIA_END