open_toontown_panda3d/panda/src/event/asyncTask.I

101 lines
3.3 KiB
Plaintext

// Filename: asyncTask.I
// Created by: drose (23Aug06)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: AsyncTask::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE AsyncTask::
AsyncTask() :
_state(S_inactive),
_manager(NULL)
{
#ifdef HAVE_PYTHON
_python_object = NULL;
#endif // HAVE_PYTHON
}
////////////////////////////////////////////////////////////////////
// Function: AsyncTask::get_state
// Access: Published
// Description: Returns the current state of the task.
////////////////////////////////////////////////////////////////////
INLINE AsyncTask::State AsyncTask::
get_state() const {
return _state;
}
////////////////////////////////////////////////////////////////////
// Function: AsyncTask::set_done_event
// Access: Published
// Description: Sets the event name that will be triggered
// when the task finishes. This should only be called
// before the task has been started, or after it has
// finished and before it is about to be restarted
// (i.e. when get_state() returns S_inactive).
////////////////////////////////////////////////////////////////////
INLINE void AsyncTask::
set_done_event(const string &done_event) {
nassertv(_state == S_inactive);
_done_event = done_event;
}
////////////////////////////////////////////////////////////////////
// Function: AsyncTask::get_done_event
// Access: Published
// Description: Returns the event name that will be triggered
// when the task finishes. See set_done_event().
////////////////////////////////////////////////////////////////////
INLINE const string &AsyncTask::
get_done_event() const {
return _done_event;
}
#ifdef HAVE_PYTHON
////////////////////////////////////////////////////////////////////
// Function: AsyncTask::set_python_object
// Access: Published
// Description: Specifies an arbitrary Python object that will be
// piggybacked on the task object.
////////////////////////////////////////////////////////////////////
INLINE void AsyncTask::
set_python_object(PyObject *python_object) {
Py_XINCREF(python_object);
Py_XDECREF(_python_object);
_python_object = python_object;
}
#endif // HAVE_PYTHON
#ifdef HAVE_PYTHON
////////////////////////////////////////////////////////////////////
// Function: AsyncTask::get_python_object
// Access: Published
// Description: Returns the Python object that was specified to
// set_python_object(), if any, or None if no object was
// specified.
////////////////////////////////////////////////////////////////////
INLINE PyObject *AsyncTask::
get_python_object() const {
if (_python_object != (PyObject *)NULL) {
Py_XINCREF(_python_object);
return _python_object;
}
Py_INCREF(Py_None);
return Py_None;
}
#endif // HAVE_PYTHON