mirror of https://github.com/KLayout/klayout.git
WIP
This commit is contained in:
parent
80d1aad90a
commit
d1216b5891
|
|
@ -31,6 +31,8 @@ namespace edt
|
|||
// ---------------------------------------------------------------
|
||||
// EditorHooksManager definition and implementation
|
||||
|
||||
class EditorHooksManager;
|
||||
|
||||
static EditorHooksManager *sp_instance = 0;
|
||||
static bool sp_instance_initialized = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "edtCommon.h"
|
||||
#include "dbTrans.h"
|
||||
#include "gsiObject.h"
|
||||
#include "tlExceptions.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
|
@ -161,6 +162,87 @@ private:
|
|||
EditorHooks (const EditorHooks &);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to call editor hooks in the right sequence and with error handling
|
||||
*/
|
||||
|
||||
inline
|
||||
void call_editor_hooks (const std::vector<EditorHooks *> &hooks, void (EditorHooks::*meth) ())
|
||||
{
|
||||
for (auto h = hooks.begin (); h != hooks.end (); ++h) {
|
||||
BEGIN_PROTECTED
|
||||
try {
|
||||
((*h)->*meth) ();
|
||||
} catch (tl::CancelException &) {
|
||||
return;
|
||||
}
|
||||
END_PROTECTED
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper function to call editor hooks in the right sequence and with error handling
|
||||
*
|
||||
* This version provides one argument
|
||||
*/
|
||||
|
||||
template <class A1>
|
||||
inline
|
||||
void call_editor_hooks (const std::vector<EditorHooks *> &hooks, void (EditorHooks::*meth) (A1), A1 a1)
|
||||
{
|
||||
for (auto h = hooks.begin (); h != hooks.end (); ++h) {
|
||||
BEGIN_PROTECTED
|
||||
try {
|
||||
((*h)->*meth) (a1);
|
||||
} catch (tl::CancelException &) {
|
||||
return;
|
||||
}
|
||||
END_PROTECTED
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper function to call editor hooks in the right sequence and with error handling
|
||||
*
|
||||
* This version provides two arguments
|
||||
*/
|
||||
|
||||
template <class A1, class A2>
|
||||
inline
|
||||
void call_editor_hooks (const std::vector<EditorHooks *> &hooks, void (EditorHooks::*meth) (A1, A2), A1 a1, A2 a2)
|
||||
{
|
||||
for (auto h = hooks.begin (); h != hooks.end (); ++h) {
|
||||
BEGIN_PROTECTED
|
||||
try {
|
||||
((*h)->*meth) (a1, a2);
|
||||
} catch (tl::CancelException &) {
|
||||
return;
|
||||
}
|
||||
END_PROTECTED
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper function to call editor hooks in the right sequence and with error handling
|
||||
*
|
||||
* This version provides three arguments
|
||||
*/
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
inline
|
||||
void call_editor_hooks (const std::vector<EditorHooks *> &hooks, void (EditorHooks::*meth) (A1, A2), A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
for (auto h = hooks.begin (); h != hooks.end (); ++h) {
|
||||
BEGIN_PROTECTED
|
||||
try {
|
||||
((*h)->*meth) (a1, a2, a3);
|
||||
} catch (tl::CancelException &) {
|
||||
return;
|
||||
}
|
||||
END_PROTECTED
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue