diff --git a/panda/src/event/Sources.pp b/panda/src/event/Sources.pp index bb70c49885..f237119e39 100644 --- a/panda/src/event/Sources.pp +++ b/panda/src/event/Sources.pp @@ -6,14 +6,15 @@ #define TARGET event #define SOURCES \ - config_event.cxx config_event.h event.cxx event.h eventHandler.cxx \ + config_event.cxx config_event.h \ + event.I event.cxx event.h eventHandler.cxx \ eventHandler.h eventParameter.I eventParameter.cxx \ eventParameter.h eventQueue.I eventQueue.cxx eventQueue.h \ eventReceiver.cxx eventReceiver.h pt_Event.cxx pt_Event.h \ throw_event.I throw_event.h #define INSTALL_HEADERS \ - event.h eventHandler.h eventParameter.I eventParameter.h \ + event.I event.h eventHandler.h eventParameter.I eventParameter.h \ eventQueue.h eventQueue.I throw_event.h throw_event.I \ eventReceiver.h \ pt_Event.h diff --git a/panda/src/event/event.I b/panda/src/event/event.I new file mode 100644 index 0000000000..b83de2d728 --- /dev/null +++ b/panda/src/event/event.I @@ -0,0 +1,52 @@ +// Filename: event.I +// Created by: drose (15May01) +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: Event::set_name +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void Event:: +set_name(const string &name) { + _name = name; +} + +//////////////////////////////////////////////////////////////////// +// Function: Event::clear_name +// Access: Public +// Description: Resets the Event's name to empty. +//////////////////////////////////////////////////////////////////// +INLINE void Event:: +clear_name() { + _name = ""; +} + +//////////////////////////////////////////////////////////////////// +// Function: Event::has_name +// Access: Public +// Description: Returns true if the Event has a nonempty name set, +// false if the name is empty. +//////////////////////////////////////////////////////////////////// +INLINE bool Event:: +has_name() const { + return !_name.empty(); +} + +//////////////////////////////////////////////////////////////////// +// Function: Event::get_name +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE const string &Event:: +get_name() const { + return _name; +} + + +INLINE ostream &operator << (ostream &out, const Event &n) { + n.output(out); + return out; +} diff --git a/panda/src/event/event.cxx b/panda/src/event/event.cxx index 46964a9db1..e94f59a741 100644 --- a/panda/src/event/event.cxx +++ b/panda/src/event/event.cxx @@ -15,7 +15,7 @@ TypeHandle Event::_type_handle; //////////////////////////////////////////////////////////////////// Event:: Event(const string &event_name, EventReceiver *receiver) : - Namable(event_name) + _name(event_name) { _receiver = receiver; } @@ -27,9 +27,9 @@ Event(const string &event_name, EventReceiver *receiver) : //////////////////////////////////////////////////////////////////// Event:: Event(const Event ©) : - Namable(copy), _parameters(copy._parameters), - _receiver(copy._receiver) + _receiver(copy._receiver), + _name(copy._name) { } @@ -40,9 +40,9 @@ Event(const Event ©) : //////////////////////////////////////////////////////////////////// void Event:: operator = (const Event ©) { - Namable::operator = (copy); _parameters = copy._parameters; _receiver = copy._receiver; + _name = copy._name; } //////////////////////////////////////////////////////////////////// @@ -126,3 +126,13 @@ void Event:: clear_receiver() { _receiver = (EventReceiver *)NULL; } + +//////////////////////////////////////////////////////////////////// +// Function: Event::output +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void Event:: +output(ostream &out) const { + out << get_name(); +} diff --git a/panda/src/event/event.h b/panda/src/event/event.h index 9acb293f71..24f54cbc01 100644 --- a/panda/src/event/event.h +++ b/panda/src/event/event.h @@ -10,9 +10,7 @@ #include "eventParameter.h" - #include -#include class EventReceiver; @@ -22,14 +20,23 @@ class EventReceiver; // any thread may throw an event at any time; there will // be one process responsible for reading and dispacting // on the events (but not necessarily immediately). +// +// This function use to inherit from Namable, but that +// makes it too expensive to get its name the Python +// code. Now it just copies the Namable interface in. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS Event : public TypedReferenceCount, public Namable { +class EXPCL_PANDAEXPRESS Event : public TypedReferenceCount { PUBLISHED: Event(const string &event_name, EventReceiver *receiver = NULL); Event(const Event ©); void operator = (const Event ©); ~Event(); + INLINE void set_name(const string &name); + INLINE void clear_name(); + INLINE bool has_name() const; + INLINE const string &get_name() const; + void add_parameter(const EventParameter &obj); int get_num_parameters() const; @@ -40,21 +47,24 @@ PUBLISHED: void set_receiver(EventReceiver *receiver); void clear_receiver(); + void output(ostream &out) const; + protected: typedef vector ParameterList; ParameterList _parameters; EventReceiver *_receiver; +private: + string _name; + public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - Namable::init_type(); register_type(_type_handle, "Event", - TypedReferenceCount::get_class_type(), - Namable::get_class_type()); + TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); @@ -65,4 +75,8 @@ private: static TypeHandle _type_handle; }; +INLINE ostream &operator << (ostream &out, const Event &n); + +#include "event.I" + #endif