/* $Id$ */ /* * Cantus Tag Editor * Copyright © 2002-2004 by Samuel Abels * Copyright © 2007 by Tim Huetz * * 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 3 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, see **/ #if !defined( _CANTUS_PLUGIN_H_ ) #define _CANTUS_PLUGIN_H_ /* if we have a config.h, include it */ #ifdef HAVE_CONFIG_H # include #endif /* we need to tell that there will be a defition for "class Plugin" before we include */ class CantusPlugin; /* some headers we need */ #include #include #include #include #include #include #include /**/ #define PLUGIN_COMPAT_LEVEL 1 /** * \brief * \author * \date */ typedef struct { const gchar * name; // A symbol name. const gchar * keyname; // The plugindata hash key name. gboolean required; // Whether or not the symbol is mandatory. } Symbol; /** * \brief * \author * \date */ class CantusPlugin : public sigc::trackable { public: CantusPlugin(); ~CantusPlugin(); /* Triggered directly before the plugin will be deleted (= when the */ /* refcounter has reached a value <= 0). */ SigC::Signal1 signalPluginDeleted; /* Loads a plugin and all its symbols into the object. */ gint loadPlugin( const gchar * filename ); /* Increase a plugin's refcounter. When the refcounter is <= 0 the plugin will * be unloaded. On object creation, the refcounter is 1. */ void ref(); /* Decrease a plugin's refcounter. */ void unref(); /* Define the plugin's priority. */ void setPriority( gint priority ); /* Returns the plugin's priority. */ gint getPriority(); /* Returns the plugin name. */ const gchar * getName(); /* Returns the name of the tags handled by this plugin. */ const gchar * getTagname(); /* Returns the title for the plugin's notebook tab label. */ const gchar * getLabel(); /* Returns the the plugin description (should be 200 chars max.). */ const gchar * getDescription(); /* Returns the plugin's major version number. */ gint getMajorVersion(); /* Returns the plugin's minor version number. */ gint getMinorVersion(); /* Returns a function pointer to the plugin's read() function. */ const ReadFunc getReadFunction(); /* Returns a function pointer to the plugin's write() function. */ const WriteFunc getWriteFunction(); /* Calls the plugin's uiwidget() function. */ void * getUIWidget( gboolean vertical ); /* Given a file name, this function returns TRUE if the plugin is responsible * for handling this filetype, otherwise FALSE. */ gboolean isHandling( const gchar * filename ); private: /* Checks, whether the plugin meets all mandatory requirements. Returns TRUE * if the plugin is valid, otherwise FALSE. */ gboolean checkPlugin(void); void * m_dlHandle; // The handle for dl_open. CantusHash * m_pluginData; // A pointer to the C-compatible plugin data. gint m_refCounter; // A refcounter indicating whether the plugin is // still needed. gint m_pluginPriority; // A priority, to be used by the backend only. }; #endif