diff --git a/panda/src/dgraph/dataNode.cxx b/panda/src/dgraph/dataNode.cxx index 3f115cc4d5..ffd4d6a71c 100644 --- a/panda/src/dgraph/dataNode.cxx +++ b/panda/src/dgraph/dataNode.cxx @@ -58,7 +58,49 @@ transmit_data(const DataNodeTransmit inputs[], new_input.set_data(connect._input_index, data); } +#ifndef NDEBUG + if (dgraph_cat.is_spam()) { + bool any_data = false; + Wires::const_iterator wi; + for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) { + const string &name = (*wi).first; + const WireDef &def = (*wi).second; + if (new_input.has_data(def._index)) { + if (!any_data) { + dgraph_cat.spam() + << *this << " receives:\n"; + any_data = true; + } + dgraph_cat.spam(false) + << " " << name << " = " << new_input.get_data(def._index) + << "\n"; + } + } + } +#endif // NDEBUG + do_transmit_data(new_input, output); + +#ifndef NDEBUG + if (dgraph_cat.is_spam()) { + bool any_data = false; + Wires::const_iterator wi; + for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) { + const string &name = (*wi).first; + const WireDef &def = (*wi).second; + if (output.has_data(def._index)) { + if (!any_data) { + dgraph_cat.spam() + << *this << " transmits:\n"; + any_data = true; + } + dgraph_cat.spam(false) + << " " << name << " = " << output.get_data(def._index) + << "\n"; + } + } + } +#endif // NDEBUG } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index 6f760e0812..30825e36ad 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -29,6 +29,7 @@ NotifyCategoryDef(event, ""); ConfigureFn(config_event) { Event::init_type(); EventHandler::init_type(); + EventStoreValueBase::init_type(); EventStoreInt::init_type("EventStoreInt"); EventStoreDouble::init_type("EventStoreDouble"); EventStoreString::init_type("EventStoreString"); diff --git a/panda/src/event/eventParameter.I b/panda/src/event/eventParameter.I index 17d81d1f09..176301cb3b 100644 --- a/panda/src/event/eventParameter.I +++ b/panda/src/event/eventParameter.I @@ -200,6 +200,12 @@ get_ptr() const { return _ptr; } +INLINE ostream & +operator << (ostream &out, const EventParameter ¶m) { + param.output(out); + return out; +} + //////////////////////////////////////////////////////////////////// // Function: EventStoreValue::set_value @@ -225,3 +231,14 @@ INLINE const Type &EventStoreValue:: get_value() const { return _value; } + +//////////////////////////////////////////////////////////////////// +// Function: EventStoreValue::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void EventStoreValue:: +output(ostream &out) const { + out << _value; +} diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index eb3dec0275..37f21289d8 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -17,8 +17,31 @@ //////////////////////////////////////////////////////////////////// #include "eventParameter.h" +#include "dcast.h" // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ #pragma implementation #endif + +TypeHandle EventStoreValueBase::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: EventParameter::output +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void EventParameter:: +output(ostream &out) const { + if (_ptr == (TypedReferenceCount *)NULL) { + out << "(empty)"; + + } else if (_ptr->is_of_type(EventStoreValueBase::get_class_type())) { + const EventStoreValueBase *sv_ptr; + DCAST_INTO_V(sv_ptr, _ptr); + sv_ptr->output(out); + + } else { + out << _ptr->get_type(); + } +} diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index b3f271345d..9d0fce7f29 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -62,10 +62,41 @@ PUBLISHED: INLINE const TypedReferenceCount *get_ptr() const; + void output(ostream &out) const; + private: CPT(TypedReferenceCount) _ptr; }; +INLINE ostream &operator << (ostream &out, const EventParameter ¶m); + +//////////////////////////////////////////////////////////////////// +// Class : EventStoreValueBase +// Description : A non-template base class of EventStoreValue (below), +// which serves mainly to define the placeholder for the +// virtual output function. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDAEXPRESS EventStoreValueBase : public TypedReferenceCount { +public: + virtual void output(ostream &out) const=0; + +public: + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedReferenceCount::init_type(); + register_type(_type_handle, "EventStoreValueBase", + TypedReferenceCount::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; //////////////////////////////////////////////////////////////////// // Class : EventStoreValue @@ -77,13 +108,15 @@ private: // EventParameter. //////////////////////////////////////////////////////////////////// template -class EventStoreValue : public TypedReferenceCount { +class EventStoreValue : public EventStoreValueBase { public: EventStoreValue(const Type &value) : _value(value) { } INLINE void set_value(const Type &value); INLINE const Type &get_value() const; + virtual void output(ostream &out) const; + Type _value; public: @@ -91,9 +124,9 @@ public: return _type_handle; } static void init_type(const string &type_name = "UndefinedEventStoreValue") { - TypedReferenceCount::init_type(); + EventStoreValueBase::init_type(); _type_handle = register_dynamic_type - (type_name, TypedReferenceCount::get_class_type()); + (type_name, EventStoreValueBase::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 5915f24369..79dadcda63 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -226,8 +226,7 @@ init_libpgraph() { PosHprScaleLerpFunctor::init_type(); ColorLerpFunctor::init_type(); ColorScaleLerpFunctor::init_type(); - - EventStoreTransform::init_type("EventStoreTransform"); + EventStoreTransform::init_type(); AlphaTestAttrib::register_with_read_factory(); AmbientLight::register_with_read_factory(); diff --git a/panda/src/pgraph/transformState.I b/panda/src/pgraph/transformState.I index 8faa449a6b..4d9408d078 100644 --- a/panda/src/pgraph/transformState.I +++ b/panda/src/pgraph/transformState.I @@ -498,3 +498,34 @@ is_destructing() const { return false; #endif } + +//////////////////////////////////////////////////////////////////// +// Function: EventStoreTransform::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE EventStoreTransform:: +EventStoreTransform(const TransformState *value) : + _value(value) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: EventStoreTransform::set_value +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void EventStoreTransform:: +set_value(const TransformState *value) { + _value = value; +} + +//////////////////////////////////////////////////////////////////// +// Function: EventStoreTransform::get_value +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE const TransformState *EventStoreTransform:: +get_value() const { + return _value; +} diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index d579349e48..4a16da931f 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -27,6 +27,7 @@ TransformState::States *TransformState::_states = NULL; CPT(TransformState) TransformState::_identity_state; TypeHandle TransformState::_type_handle; +TypeHandle EventStoreTransform::_type_handle; //////////////////////////////////////////////////////////////////// // Function: TransformState::Constructor @@ -1291,3 +1292,13 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } } + +//////////////////////////////////////////////////////////////////// +// Function: EventStoreTransform::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void EventStoreTransform:: +output(ostream &out) const { + out << *_value; +} diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 25dff071d8..7349816ace 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -230,11 +230,39 @@ INLINE ostream &operator << (ostream &out, const TransformState &state) { return out; } -// This class is used to pass TransformState pointers as parameters to -// events, or as elements on a data graph. -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, EventStoreValue< CPT(TransformState) >); -typedef EventStoreValue EventStoreTransform; +//////////////////////////////////////////////////////////////////// +// Class : EventStoreTransform +// Description : This class is used to pass TransformState pointers as +// parameters to events, or as elements on a data graph. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA EventStoreTransform : public EventStoreValueBase { +public: + INLINE EventStoreTransform(const TransformState *value); + INLINE void set_value(const TransformState *value); + INLINE const TransformState *get_value() const; + + virtual void output(ostream &out) const; + + CPT(TransformState) _value; + +public: + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + EventStoreValueBase::init_type(); + register_type(_type_handle, "EventStoreTransform", + EventStoreValueBase::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; #include "transformState.I" diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index 46119ae6f0..39c66606d2 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -1,6 +1,6 @@ #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m -#define LOCAL_LIBS express pandabase +#define LOCAL_LIBS express event pandabase #begin lib_target #define TARGET putil diff --git a/panda/src/putil/buttonEventList.cxx b/panda/src/putil/buttonEventList.cxx index a01dd802b1..c5b65c0206 100644 --- a/panda/src/putil/buttonEventList.cxx +++ b/panda/src/putil/buttonEventList.cxx @@ -39,12 +39,24 @@ update_mods(ModifierButtons &mods) const { //////////////////////////////////////////////////////////////////// // Function: ButtonEventList::output -// Access: Public +// Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// void ButtonEventList:: output(ostream &out) const { - out << get_type() << " (" << get_num_events() << " events)"; + if (_events.empty()) { + out << "(no buttons)"; + } else { + Events::const_iterator ei; + ei = _events.begin(); + out << "(" << (*ei); + ++ei; + while (ei != _events.end()) { + out << " " << (*ei); + ++ei; + } + out << ")"; + } } //////////////////////////////////////////////////////////////////// @@ -54,7 +66,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void ButtonEventList:: write(ostream &out, int indent_level) const { - indent(out, indent_level) << *this << ":\n"; + indent(out, indent_level) << _events.size() << " events:\n"; Events::const_iterator ei; for (ei = _events.begin(); ei != _events.end(); ++ei) { indent(out, indent_level + 2) << (*ei) << "\n"; diff --git a/panda/src/putil/buttonEventList.h b/panda/src/putil/buttonEventList.h index d0b75b7e24..036b16b9f9 100644 --- a/panda/src/putil/buttonEventList.h +++ b/panda/src/putil/buttonEventList.h @@ -23,6 +23,7 @@ #include "buttonEvent.h" #include "typedReferenceCount.h" +#include "eventParameter.h" #include "pvector.h" class ModifierButtons; @@ -35,7 +36,7 @@ class ModifierButtons; // but it may be used anywhere a list of ButtonEvents // is desired. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA ButtonEventList : public TypedReferenceCount { +class EXPCL_PANDA ButtonEventList : public EventStoreValueBase { public: INLINE ButtonEventList(); @@ -46,7 +47,7 @@ public: void update_mods(ModifierButtons &mods) const; - void output(ostream &out) const; + virtual void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; private: @@ -58,9 +59,9 @@ public: return _type_handle; } static void init_type() { - TypedReferenceCount::init_type(); + EventStoreValueBase::init_type(); register_type(_type_handle, "ButtonEventList", - TypedReferenceCount::get_class_type()); + EventStoreValueBase::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type();