92 if (filename ==
"")
return;
97 u_int16 argssize = args == NULL ? 1 : PyTuple_Size (args) + 1;
98 PyObject *theargs = PyTuple_New (argssize);
103 for (
u_int16 i = 1; i < argssize; i++)
105 PyObject *intref = PyTuple_GetItem (args, i - 1);
107 PyTuple_SetItem (theargs, i, intref);
194 PyObject * args = NULL;
214 default:
return true;
#define EVENTS_DIR
Directory where event scripts reside.
Class to write data from a Gzip compressed file.
Declares the event_handler class.
#define s_int32
32 bits long signed integer
Class to read data from a Gzip compressed file.
u_int8 Action
What happens if the event occurs - see enum above.
virtual void put_state(ogzstream &out) const
Saves the basic event data (such as the type or script data) to a file.
PyObject * Args
The arguments passed to the script.
#define u_int16
16 bits long unsigned integer
void set_callback(PyObject *callback, PyObject *args=NULL)
Sets a python function/method to be executed whenever the event occurs.
virtual void pause()
Disable the event temporarily.
void set_script(string filename, PyObject *args=NULL)
Sets a script to be executed whenever the event occurs.
static void put_tuple(PyObject *tuple, ogzstream &file)
Save a Python tuple into a file.
s_int32 Repeat
Defines how often the event should be repeated.
void put_state(ogzstream &out) const
Saves the callback and it's arguments to file.
std::string class_name() const
Returns the class name of this object.
bool Registered
Whether the event is registered with the event handler.
virtual bool get_state(igzstream &in)
Loads the basic event date from a file.
virtual ~event()
Destructor.
bool Paused
Whether the event temporarily disabled or not.
bool get_state(igzstream &in)
Restores the callback from a file.
bool create_instance(string file, string classname, PyObject *args=NULL)
Creates an instance of a Python class.
u_int8 Type
Event type - see enum above.
static PyObject * get_tuple(igzstream &file)
Loads a Python tuple previously saved with put_tuple ().
virtual void resume()
Re-enable an event that has been paused.
static void remove_event(event *ev)
Unregister an event.
py_callback * PyFunc
Python callback that may be executed instead of the script.
py_object * Script
The Python script accociated with this event.
static PyObject * pass_instance(void *instance, const char *class_name)
Magic function that makes any C object available to Python!
void set_list(event_list *list)
Tell the whether it is kept in an event_list.
Functor0 Callback
C++ callback that may be executed when the event gets triggered.
Declares the event class.
static void register_event(event *ev)
Registers an event.
s_int32 do_repeat()
Decrease the event's repeat count and return the number of repeats left.
Stores the C++ <-> Python callback binding.
void remove_event(event *ev)
Removes an event from the list.
string Id
(Optional) Id of the event
Base class for objects that want to register events.
event_list * List
The event_list this event is kept in.