/* -*- C++ -*- * Copyright ©2005 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #ifndef PLUGIN_H #define PLUGIN_H #include #include class PluginInitError { public: PluginInitError(const char* txt) : text(txt) { } PluginInitError(const std::string& txt) : text(txt) { } std::string text; }; class Configuration; class Plugin { public: Plugin() : _refs(1) { } // Copying to a new plugin: we don't copy the reference count Plugin(const Plugin& that) : _refs(1) { } virtual bool isbound(void) const { return true; } /* Bind the plugin to any referenced configuration objects that it * may have been configured with. This is done after the * configuration file has been read. Return NULL if the bind * operation failed, or a pointer to a fully-bound plugin if it * succeeds. Objects are responsible for cleaning up themselves if * binding results in a different object. */ virtual Plugin* bind(Configuration*); std::string name; // PluginInfo* what; // These are used to decide whether something has been used as a // reference or not void addreference(void) { _refs++; } bool destroy(void); protected: virtual ~Plugin(); private: int _refs; bool operator=(const Plugin&); // This isn't, and shouldn't, be used }; #endif