EventParameter
from panda3d.core import EventParameter
- class EventParameter
Bases:
An optional parameter associated with an event. Each event may have zero or more of these. Each parameter stores a pointer to a
TypedWritableReferenceCount
object, which of course could be pretty much anything. To store a simple value like a double or a string, the EventParameter constructors transparently use the ParamValue template class from paramValue.h.Inheritance diagram
- __init__()
- __init__(copy: EventParameter)
- __init__(ptr: TypedReferenceCount)
Defines an
EventParameter
that stores a pointer to aTypedReferenceCount
object. Note that aTypedReferenceCount
is not the same kind of pointer as aTypedWritableReferenceCount
, hence we require both constructors.This accepts a const pointer, even though it stores (and eventually returns) a non-const pointer. This is just the simplest way to allow both const and non-const pointers to be stored, but it does lose the constness. Be careful.
- __init__(ptr: TypedWritableReferenceCount)
Defines an
EventParameter
that stores a pointer to any kind ofTypedWritableReferenceCount
object. This is the most general constructor.This accepts a const pointer, even though it stores (and eventually returns) a non-const pointer. This is just the simplest way to allow both const and non-const pointers to be stored, but it does lose the constness. Be careful.
- __init__(value: float)
Defines an
EventParameter
that stores a floating-point value.
- __init__(value: int)
Defines an
EventParameter
that stores an integer value.
- __init__(param0: nullptr_t)
- __init__(value: str)
Defines an
EventParameter
that stores a string value.
- __init__(value: str)
Defines an
EventParameter
that stores a wstring value.
- assign(copy: EventParameter) EventParameter
- get_double_value() float
Retrieves the value stored in the
EventParameter
. It is only valid to call this ifis_double()
has already returned true.
- get_int_value() int
Retrieves the value stored in the
EventParameter
. It is only valid to call this ifis_int()
has already returned true.
- get_ptr() TypedWritableReferenceCount
Retrieves a pointer to the actual value stored in the parameter. The
TypeHandle
of this pointer may be examined to determine the actual type of parameter it contains. This is the only way to retrieve the value when it is not one of the above predefined types.
- get_string_value() str
Retrieves the value stored in the
EventParameter
. It is only valid to call this ifis_string()
has already returned true.
- get_typed_ref_count_value() TypedReferenceCount
Retrieves the value stored in the
EventParameter
. It is only valid to call this ifis_typed_ref_count()
has already returned true.
- get_wstring_value() str
Retrieves the value stored in the
EventParameter
. It is only valid to call this ifis_wstring()
has already returned true.
- is_double() bool
Returns true if the
EventParameter
stores a double floating-point value, false otherwise.
- is_empty() bool
These functions are conveniences to easily determine if the
EventParameter
is one of the predefined parameter types, and retrieve the corresponding value. Of course, it is possible that theEventParameter
is some user-defined type, and is none of these.
- is_int() bool
Returns true if the
EventParameter
stores an integer value, false otherwise.
- is_string() bool
Returns true if the
EventParameter
stores a string value, false otherwise.
- is_typed_ref_count() bool
Returns true if the
EventParameter
stores aTypedReferenceCount
pointer, false otherwise. Note that aTypedReferenceCount
is not exactly the same kind of pointer as aTypedWritableReferenceCount
, hence the need for this separate call.
- is_wstring() bool
Returns true if the
EventParameter
stores a wstring value, false otherwise.