Panda3D
 All Classes Functions Variables Enumerations
pythonTask.I
1 // Filename: pythonTask.I
2 // Created by: drose (16Sep08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PythonTask::set_delay
18 // Access: Public
19 // Description: If None is passed, calls clear_delay, otherwise
20 // sets the delay time. See AsyncTask::set_delay()
21 // and AsyncTask::clear_delay().
22 ////////////////////////////////////////////////////////////////////
23 INLINE void PythonTask::
24 set_delay(PyObject *delay) {
25  if (delay == Py_None) {
27  return;
28  }
29 
30  PyObject *value = PyNumber_Float(delay);
31  if (value == NULL) {
32  return;
33  }
34 
35  AsyncTask::set_delay(PyFloat_AS_DOUBLE(value));
36  Py_DECREF(value);
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: PythonTask::get_delay
41 // Access: Public
42 // Description: Returns the delay time if set, None otherwise.
43 // See AsyncTask::has_delay() and AsyncTask::get_delay().
44 ////////////////////////////////////////////////////////////////////
45 INLINE PyObject *PythonTask::
46 get_delay() const {
47  if (AsyncTask::has_delay()) {
48  return PyFloat_FromDouble(AsyncTask::get_delay());
49  } else {
50  Py_INCREF(Py_None);
51  return Py_None;
52  }
53 }
bool has_delay() const
Returns true if a delay has been set for this task via set_delay(), or false otherwise.
Definition: asyncTask.I:112
double get_delay() const
Returns the delay value that has been set via set_delay, if any.
Definition: asyncTask.I:123
void clear_delay()
Removes any delay specified for the task.
Definition: asyncTask.I:100
void set_delay(double delay)
Specifies the amount of time, in seconds, by which this task will be delayed after it has been added ...
Definition: asyncTask.I:86