00001 /* 00002 Copyright (C) 1999-2006 Id Software, Inc. and contributors. 00003 For a list of contributors, see the accompanying CONTRIBUTORS file. 00004 00005 This file is part of GtkRadiant. 00006 00007 GtkRadiant is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 GtkRadiant is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GtkRadiant; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 /* greebo: The plugin system is organised like this: 00023 * 00024 * Each PlugIn is "stored" in a CPluginSlot class. All of these slots are stored 00025 * in a list owned by the surrounding CPlugInSlots class (note the plural s :). 00026 * 00027 * The class CPlugInSlots is in turn controlled by the CPluginManager class, which 00028 * passes its calles to the according CPlugInSlots methods. 00029 * 00030 * If the "world" calls a method, the call is dispatched this way: 00031 * "World" > CPluginManager > CPlugInSlots > CPluginSlot 00032 * 00033 */ 00034 00035 #if !defined(INCLUDED_PLUGINMANAGER_H) 00036 #define INCLUDED_PLUGINMANAGER_H 00037 00038 #include <cstddef> 00039 #include <string> 00040 #include "PluginsVisitor.h" 00041 #include "PluginSlots.h" 00042 00043 // Forward declaration to avoid including the whole GTK headers 00044 typedef struct _GtkWidget GtkWidget; 00045 00046 class CPluginManager 00047 { 00048 00049 private: 00050 // The private list of pluginSlots 00051 CPluginSlots _pluginSlots; 00052 00053 public: 00054 // Initialises the Manager by filling all the PluginSlots 00055 void Init (GtkWidget* main_window); 00056 00057 // Dispatches the <command> to all the plugins 00058 void Dispatch (std::size_t n, const std::string& command); 00059 00060 // Populate a menu using the passed pluginvisitor class 00061 void constructMenu (PluginsVisitor& menu); 00062 00063 void Shutdown (); 00064 00065 private: 00066 void fillPluginSlots (GtkWidget* main_window); 00067 }; 00068 00069 // This is the gateway function to access the PluginManager in the radiant core 00070 CPluginManager& GetPlugInMgr (); 00071 00072 #endif