mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancement - Hooks
- First fully functioning Lua hooks. Woohoo.
This commit is contained in:
parent
eeefc8a992
commit
69cae7731f
6 changed files with 252 additions and 72 deletions
62
src/Hooks.h
62
src/Hooks.h
|
@ -32,31 +32,67 @@
|
|||
#include "API.h"
|
||||
#include "auto.h"
|
||||
|
||||
// Hook class representing a single hook.
|
||||
class Hook
|
||||
{
|
||||
public:
|
||||
Hook ()
|
||||
: event ("")
|
||||
, file ("")
|
||||
, function ("")
|
||||
{
|
||||
}
|
||||
|
||||
Hook (const std::string& e, const std::string& f, const std::string& fn)
|
||||
: event (e)
|
||||
, file (f)
|
||||
, function (fn)
|
||||
{
|
||||
}
|
||||
|
||||
Hook (const Hook& other)
|
||||
{
|
||||
event = other.event;
|
||||
file = other.file;
|
||||
function = other.function;
|
||||
}
|
||||
|
||||
Hook& operator= (const Hook& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
event = other.event;
|
||||
file = other.file;
|
||||
function = other.function;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string event;
|
||||
std::string file;
|
||||
std::string function;
|
||||
};
|
||||
|
||||
// Hooks class for managing the loading and calling of hook functions.
|
||||
class Hooks
|
||||
{
|
||||
public:
|
||||
Hooks (); // Default constructor
|
||||
~Hooks (); // Destructor
|
||||
Hooks (const Hooks&); // Deliberately unimplemented
|
||||
Hooks& operator= (const Hooks&); // Deliberately unimplemented
|
||||
Hooks (); // Default constructor
|
||||
~Hooks (); // Destructor
|
||||
Hooks (const Hooks&); // Deliberately unimplemented
|
||||
Hooks& operator= (const Hooks&); // Deliberately unimplemented
|
||||
|
||||
void initialize ();
|
||||
bool trigger (const std::string&);
|
||||
bool eventType (const std::string&, std::string&);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_LIBLUA
|
||||
bool triggerProgramEvent (const std::string&);
|
||||
bool triggerListEvent (const std::string&);
|
||||
bool triggerTaskEvent (const std::string&);
|
||||
bool triggerFieldEvent (const std::string&);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef HAVE_LIBLUA
|
||||
API api;
|
||||
#endif
|
||||
std::vector <std::string> scripts;
|
||||
std::vector <Hook> all; // All current hooks.
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue