Code::Blocks  SVN r11506
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
PluginManager Class Reference

PluginManager manages plugins. More...

#include <pluginmanager.h>

Inheritance diagram for PluginManager:
Collaboration diagram for PluginManager:

Classes

struct  PluginRegistration
 

Public Types

typedef std::vector< cbCompilerPlugin * > CompilerPlugins
 

Public Member Functions

void CreateMenu (wxMenuBar *menuBar)
 
void ReleaseMenu (wxMenuBar *menuBar)
 
void RegisterPlugin (const wxString &name, CreatePluginProc createProc, FreePluginProc freeProc, PluginSDKVersionProc versionProc)
 
int ScanForPlugins (const wxString &path)
 
bool LoadPlugin (const wxString &pluginName)
 
void LoadAllPlugins ()
 
void UnloadAllPlugins ()
 
void UnloadPlugin (cbPlugin *plugin)
 
int ExecutePlugin (const wxString &pluginName)
 
bool AttachPlugin (cbPlugin *plugin, bool ignoreSafeMode=false)
 
bool DetachPlugin (cbPlugin *plugin)
 
bool InstallPlugin (const wxString &pluginName, bool forAllUsers=true, bool askForConfirmation=true)
 
bool UninstallPlugin (cbPlugin *plugin, bool removeFiles=true)
 
bool ExportPlugin (cbPlugin *plugin, const wxString &filename)
 
const PluginInfoGetPluginInfo (const wxString &pluginName)
 
const PluginInfoGetPluginInfo (cbPlugin *plugin)
 
const PluginElementsArray & GetPlugins () const
 
PluginElementFindElementByName (const wxString &pluginName)
 
cbPluginFindPluginByName (const wxString &pluginName)
 
cbPluginFindPluginByFileName (const wxString &pluginFileName)
 
const CompilerPluginsGetCompilerPlugins () const
 
cbCompilerPluginGetFirstCompiler () const
 
PluginsArray GetToolOffers ()
 
PluginsArray GetMimeOffers ()
 
PluginsArray GetDebuggerOffers ()
 
PluginsArray GetCodeCompletionOffers ()
 
PluginsArray GetSmartIndentOffers ()
 
PluginsArray GetOffersFor (PluginType type)
 
void AskPluginsForModuleMenu (const ModuleType type, wxMenu *menu, const FileTreeData *data=nullptr)
 
void ResetModuleMenu ()
 Called by the code creating the context menu for the editor. More...
 
void RegisterFindMenuItems (bool before, int count)
 Can be called by plugins' BuildModuleMenu when building the EditorManager's context menu. More...
 
int GetFindMenuItemCount () const
 Returns the number of items in the find group already added to the menu. More...
 
int GetFindMenuItemFirst () const
 Returns the position of the first menu item in the find group. More...
 
void RegisterLastNonPluginMenuItem (int id)
 Called by the editor code which adds the non-plugin related menu items to store the id of the last fixed menu item. More...
 
int FindSortedMenuItemPosition (wxMenu &popup, const wxString &label) const
 Called by plugins when they want to add menu items to the editor's context menu. More...
 
cbMimePluginGetMIMEHandlerForFile (const wxString &filename)
 
void GetConfigurationPanels (int group, wxWindow *parent, ConfigurationPanelsArray &arrayToFill)
 
void GetProjectConfigurationPanels (wxWindow *parent, cbProject *project, ConfigurationPanelsArray &arrayToFill)
 
int Configure ()
 
void SetupLocaleDomain (const wxString &DomainName)
 
void NotifyPlugins (CodeBlocksEvent &event)
 
void NotifyPlugins (CodeBlocksDockEvent &event)
 
void NotifyPlugins (CodeBlocksLayoutEvent &event)
 

Static Public Member Functions

static void SetSafeMode (bool on)
 
static bool GetSafeMode ()
 
- Static Public Member Functions inherited from Mgr< PluginManager >
static bool Valid ()
 
static PluginManagerGet ()
 
static void Free ()
 

Private Member Functions

 PluginManager ()
 
 ~PluginManager () override
 
void OnScriptMenu (wxCommandEvent &event)
 
void OnScriptModuleMenu (wxCommandEvent &event)
 
bool ReadManifestFile (const wxString &pluginFilename, const wxString &pluginName=wxEmptyString, PluginInfo *infoOut=nullptr)
 
void ReadExtraFilesFromManifestFile (const wxString &pluginFilename, wxArrayString &extraFiles)
 
bool ExtractFile (const wxString &bundlename, const wxString &src_filename, const wxString &dst_filename, bool isMandatory=true)
 

Private Attributes

PluginElementsArray m_Plugins
 
wxString m_CurrentlyLoadingFilename
 
wxDynamicLibrarym_pCurrentlyLoadingLib
 
TiXmlDocument * m_pCurrentlyLoadingManifestDoc
 
std::vector< PluginRegistrationm_RegisteredPlugins
 
CompilerPlugins m_CompilerPlugins
 
int m_FindMenuItemCount = 0
 
int m_FindMenuItemFirst = 0
 
int m_LastNonPluginMenuId = 0
 

Static Private Attributes

static bool s_SafeMode = false
 

Friends

class Mgr< PluginManager >
 
class Manager
 

Additional Inherited Members

- Protected Member Functions inherited from Mgr< PluginManager >
 Mgr ()
 
virtual ~Mgr ()
 

Detailed Description

PluginManager manages plugins.

There are two plugin types: binary and scripted.

Binary plugins are dynamically loaded shared libraries (dll/so) which can do pretty much anything with the SDK.

Script plugins are more lightweight and are very convenient for smaller scale/functionality plugins.

Definition at line 76 of file pluginmanager.h.

Member Typedef Documentation

◆ CompilerPlugins

Definition at line 79 of file pluginmanager.h.

Constructor & Destructor Documentation

◆ PluginManager()

PluginManager::PluginManager ( )
private

Definition at line 168 of file pluginmanager.cpp.

References Manager::Get(), and Manager::GetAppWindow().

◆ ~PluginManager()

PluginManager::~PluginManager ( )
overrideprivate

Definition at line 176 of file pluginmanager.cpp.

Member Function Documentation

◆ AskPluginsForModuleMenu()

void PluginManager::AskPluginsForModuleMenu ( const ModuleType  type,
wxMenu menu,
const FileTreeData data = nullptr 
)

◆ AttachPlugin()

bool PluginManager::AttachPlugin ( cbPlugin plugin,
bool  ignoreSafeMode = false 
)

Definition at line 189 of file pluginmanager.cpp.

References cbPlugin::Attach(), and cbPlugin::IsAttached().

Referenced by PluginsConfigurationDlg::OnToggle().

◆ Configure()

int PluginManager::Configure ( )

Definition at line 1495 of file pluginmanager.cpp.

References Manager::Get(), PlaceWindow(), and wxDialog::ShowModal().

◆ CreateMenu()

void PluginManager::CreateMenu ( wxMenuBar menuBar)

Definition at line 181 of file pluginmanager.cpp.

◆ DetachPlugin()

bool PluginManager::DetachPlugin ( cbPlugin plugin)

◆ ExecutePlugin()

int PluginManager::ExecutePlugin ( const wxString pluginName)

◆ ExportPlugin()

bool PluginManager::ExportPlugin ( cbPlugin plugin,
const wxString filename 
)

◆ ExtractFile()

bool PluginManager::ExtractFile ( const wxString bundlename,
const wxString src_filename,
const wxString dst_filename,
bool  isMandatory = true 
)
private

◆ FindElementByName()

PluginElement * PluginManager::FindElementByName ( const wxString pluginName)

Definition at line 1178 of file pluginmanager.cpp.

References PluginElement::info, and PluginInfo::name.

◆ FindPluginByFileName()

cbPlugin * PluginManager::FindPluginByFileName ( const wxString pluginFileName)

Definition at line 1202 of file pluginmanager.cpp.

References PluginElement::fileName, and PluginElement::plugin.

◆ FindPluginByName()

cbPlugin * PluginManager::FindPluginByName ( const wxString pluginName)

◆ FindSortedMenuItemPosition()

int PluginManager::FindSortedMenuItemPosition ( wxMenu popup,
const wxString label 
) const

Called by plugins when they want to add menu items to the editor's context menu.

Using this method will produce a menu which is sorted alphabetically (case insensitive). The menu items are added at the bottom of the menu.

Parameters
popupThe context menu passed to BuildModuleMenu.
labelThe label of the new menu item. It will be used to find the correct position.
Returns
The position where to insert the item.

Definition at line 1437 of file pluginmanager.cpp.

References wxString::begin(), wxString::CmpNoCase(), wxString::end(), wxString::erase(), wxMenu::GetMenuItems(), and wxITEM_SEPARATOR.

◆ GetCodeCompletionOffers()

PluginsArray PluginManager::GetCodeCompletionOffers ( )

Definition at line 1331 of file pluginmanager.cpp.

References ptCodeCompletion.

Referenced by CCManager::GetProviderFor().

◆ GetCompilerPlugins()

const CompilerPlugins& PluginManager::GetCompilerPlugins ( ) const
inline

◆ GetConfigurationPanels()

void PluginManager::GetConfigurationPanels ( int  group,
wxWindow parent,
ConfigurationPanelsArray &  arrayToFill 
)

◆ GetDebuggerOffers()

PluginsArray PluginManager::GetDebuggerOffers ( )

Definition at line 1326 of file pluginmanager.cpp.

References ptDebugger.

◆ GetFindMenuItemCount()

int PluginManager::GetFindMenuItemCount ( ) const

Returns the number of items in the find group already added to the menu.

Definition at line 1422 of file pluginmanager.cpp.

Referenced by DebuggerMenuHandler::BuildContextMenu(), and EditorBase::DisplayContextMenu().

◆ GetFindMenuItemFirst()

int PluginManager::GetFindMenuItemFirst ( ) const

Returns the position of the first menu item in the find group.

Definition at line 1427 of file pluginmanager.cpp.

Referenced by DebuggerMenuHandler::BuildContextMenu(), CodeCompletion::BuildModuleMenu(), and EditorBase::DisplayContextMenu().

◆ GetFirstCompiler()

cbCompilerPlugin * PluginManager::GetFirstCompiler ( ) const

◆ GetMIMEHandlerForFile()

cbMimePlugin * PluginManager::GetMIMEHandlerForFile ( const wxString filename)

◆ GetMimeOffers()

PluginsArray PluginManager::GetMimeOffers ( )

Definition at line 1321 of file pluginmanager.cpp.

References ptMime.

Referenced by ProjectManagerUI::OnOpenWith(), and ProjectManagerUI::ShowMenu().

◆ GetOffersFor()

PluginsArray PluginManager::GetOffersFor ( PluginType  type)

◆ GetPluginInfo() [1/2]

const PluginInfo * PluginManager::GetPluginInfo ( const wxString pluginName)

◆ GetPluginInfo() [2/2]

const PluginInfo * PluginManager::GetPluginInfo ( cbPlugin plugin)

Definition at line 1223 of file pluginmanager.cpp.

References PluginElement::info, and PluginElement::plugin.

◆ GetPlugins()

const PluginElementsArray& PluginManager::GetPlugins ( ) const
inline

◆ GetProjectConfigurationPanels()

void PluginManager::GetProjectConfigurationPanels ( wxWindow parent,
cbProject project,
ConfigurationPanelsArray &  arrayToFill 
)

◆ GetSafeMode()

static bool PluginManager::GetSafeMode ( )
inlinestatic

◆ GetSmartIndentOffers()

PluginsArray PluginManager::GetSmartIndentOffers ( )

Definition at line 1336 of file pluginmanager.cpp.

References ptSmartIndent.

◆ GetToolOffers()

PluginsArray PluginManager::GetToolOffers ( )

Definition at line 1316 of file pluginmanager.cpp.

References ptTool.

◆ InstallPlugin()

bool PluginManager::InstallPlugin ( const wxString pluginName,
bool  forAllUsers = true,
bool  askForConfirmation = true 
)

◆ LoadAllPlugins()

void PluginManager::LoadAllPlugins ( )

◆ LoadPlugin()

bool PluginManager::LoadPlugin ( const wxString pluginName)

◆ NotifyPlugins() [1/3]

void PluginManager::NotifyPlugins ( CodeBlocksEvent event)

◆ NotifyPlugins() [2/3]

void PluginManager::NotifyPlugins ( CodeBlocksDockEvent event)

Definition at line 1525 of file pluginmanager.cpp.

References Manager::Get(), and Manager::ProcessEvent().

◆ NotifyPlugins() [3/3]

void PluginManager::NotifyPlugins ( CodeBlocksLayoutEvent event)

Definition at line 1530 of file pluginmanager.cpp.

References Manager::Get(), and Manager::ProcessEvent().

◆ OnScriptMenu()

void PluginManager::OnScriptMenu ( wxCommandEvent event)
private

◆ OnScriptModuleMenu()

void PluginManager::OnScriptModuleMenu ( wxCommandEvent event)
private

◆ ReadExtraFilesFromManifestFile()

void PluginManager::ReadExtraFilesFromManifestFile ( const wxString pluginFilename,
wxArrayString extraFiles 
)
private

◆ ReadManifestFile()

bool PluginManager::ReadManifestFile ( const wxString pluginFilename,
const wxString pluginName = wxEmptyString,
PluginInfo infoOut = nullptr 
)
private

◆ RegisterFindMenuItems()

void PluginManager::RegisterFindMenuItems ( bool  before,
int  count 
)

Can be called by plugins' BuildModuleMenu when building the EditorManager's context menu.

This method has two purposes:

  1. to control the number of find related items in the menu
  2. to control the number of items that are placed before the find related items.
    Parameters
    beforePass true when you're adding items before the find group and false when adding in the find group.
    countThe number of items you're adding to the menu.

Definition at line 1414 of file pluginmanager.cpp.

Referenced by cbEditor::AddToContextMenu(), DebuggerMenuHandler::BuildContextMenu(), and CodeCompletion::BuildModuleMenu().

◆ RegisterLastNonPluginMenuItem()

void PluginManager::RegisterLastNonPluginMenuItem ( int  id)

Called by the editor code which adds the non-plugin related menu items to store the id of the last fixed menu item.

Must not be called by plugins.

Definition at line 1432 of file pluginmanager.cpp.

Referenced by cbEditor::AddToContextMenu().

◆ RegisterPlugin()

void PluginManager::RegisterPlugin ( const wxString name,
CreatePluginProc  createProc,
FreePluginProc  freeProc,
PluginSDKVersionProc  versionProc 
)

◆ ReleaseMenu()

void PluginManager::ReleaseMenu ( wxMenuBar menuBar)

Definition at line 185 of file pluginmanager.cpp.

◆ ResetModuleMenu()

void PluginManager::ResetModuleMenu ( )

Called by the code creating the context menu for the editor.

Must not be called by plugins.

Definition at line 1407 of file pluginmanager.cpp.

Referenced by EditorBase::DisplayContextMenu().

◆ ScanForPlugins()

int PluginManager::ScanForPlugins ( const wxString path)

◆ SetSafeMode()

static void PluginManager::SetSafeMode ( bool  on)
inlinestatic

Definition at line 163 of file pluginmanager.h.

Referenced by CodeBlocksApp::OnInit().

◆ SetupLocaleDomain()

void PluginManager::SetupLocaleDomain ( const wxString DomainName)

◆ UninstallPlugin()

bool PluginManager::UninstallPlugin ( cbPlugin plugin,
bool  removeFiles = true 
)

◆ UnloadAllPlugins()

void PluginManager::UnloadAllPlugins ( )

Definition at line 1127 of file pluginmanager.cpp.

References LibLoader::Cleanup().

◆ UnloadPlugin()

void PluginManager::UnloadPlugin ( cbPlugin plugin)

Friends And Related Function Documentation

◆ Manager

friend class Manager
friend

Definition at line 83 of file pluginmanager.h.

◆ Mgr< PluginManager >

friend class Mgr< PluginManager >
friend

Definition at line 82 of file pluginmanager.h.

Member Data Documentation

◆ m_CompilerPlugins

CompilerPlugins PluginManager::m_CompilerPlugins
private

Definition at line 213 of file pluginmanager.h.

◆ m_CurrentlyLoadingFilename

wxString PluginManager::m_CurrentlyLoadingFilename
private

Definition at line 184 of file pluginmanager.h.

◆ m_FindMenuItemCount

int PluginManager::m_FindMenuItemCount = 0
private

Definition at line 215 of file pluginmanager.h.

◆ m_FindMenuItemFirst

int PluginManager::m_FindMenuItemFirst = 0
private

Definition at line 216 of file pluginmanager.h.

◆ m_LastNonPluginMenuId

int PluginManager::m_LastNonPluginMenuId = 0
private

Definition at line 217 of file pluginmanager.h.

◆ m_pCurrentlyLoadingLib

wxDynamicLibrary* PluginManager::m_pCurrentlyLoadingLib
private

Definition at line 185 of file pluginmanager.h.

◆ m_pCurrentlyLoadingManifestDoc

TiXmlDocument* PluginManager::m_pCurrentlyLoadingManifestDoc
private

Definition at line 186 of file pluginmanager.h.

◆ m_Plugins

PluginElementsArray PluginManager::m_Plugins
private

Definition at line 183 of file pluginmanager.h.

◆ m_RegisteredPlugins

std::vector<PluginRegistration> PluginManager::m_RegisteredPlugins
private

Definition at line 212 of file pluginmanager.h.

◆ s_SafeMode

bool PluginManager::s_SafeMode = false
staticprivate

Definition at line 219 of file pluginmanager.h.

Referenced by LibLoader::Cleanup().


The documentation for this class was generated from the following files: