Code::Blocks  SVN r11506
projectloader_hooks.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef PROJECTLOADER_HOOKS_H
7 #define PROJECTLOADER_HOOKS_H
8 
9 #include "settings.h"
10 
11 class TiXmlElement;
12 class cbProject;
13 
16 {
19  {
20  public:
21  virtual ~HookFunctorBase(){}
22  virtual void Call(cbProject*, TiXmlElement*, bool) const = 0;
23  };
24 
43  template<class T> class HookFunctor : public HookFunctorBase
44  {
45  public:
46  typedef void (T::*Func)(cbProject*, TiXmlElement*, bool);
47  HookFunctor(T* obj, Func func) : m_pObj(obj), m_pFunc(func)
48  { ; }
49  void Call(cbProject* project, TiXmlElement* elem, bool isLoading) const override
50  {
51  if (m_pObj && m_pFunc)
52  (m_pObj->*m_pFunc)(project, elem, isLoading);
53  }
54  protected:
55  T* m_pObj;
56  Func m_pFunc;
57  };
58 
63  extern DLLIMPORT int RegisterHook(HookFunctorBase* functor);
70  extern DLLIMPORT HookFunctorBase* UnregisterHook(int id, bool deleteHook = true);
74  extern DLLIMPORT bool HasRegisteredHooks();
81  extern DLLIMPORT void CallHooks(cbProject* project, TiXmlElement* elem, bool isLoading);
82 }
83 
84 #endif // PROJECTLOADER_HOOKS_H
void Call(cbProject *project, TiXmlElement *elem, bool isLoading) const override
DLLIMPORT void CallHooks(cbProject *project, TiXmlElement *elem, bool isLoading)
Call all registered hooks using the supplied parameters.
Provides static functions to add hooks to the project loading/saving procedure.
DLLIMPORT HookFunctorBase * UnregisterHook(int id, bool deleteHook=true)
Unregister a previously registered project loading/saving hook.
#define DLLIMPORT
Definition: settings.h:16
Represents a Code::Blocks project.
Definition: cbproject.h:96
DLLIMPORT int RegisterHook(HookFunctorBase *functor)
Register a project loading/saving hook.
Functor class for use as a project loading/saving hook.
Abstract base hook functor interface.
DLLIMPORT bool HasRegisteredHooks()
Are there any hooks registered?