From 5251fa56672126af0f52b290c0fb2e6fac523fa3 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Wed, 25 Apr 2001 23:00:11 +0000 Subject: [PATCH] make graph be un-inlined for dll's other than panda --- panda/src/egg2sg/deferredArcProperty.h | 2 +- panda/src/graph/Sources.pp | 181 ++-- panda/src/graph/allAttributesWrapper.I | 59 +- panda/src/graph/allAttributesWrapper.T | 28 + panda/src/graph/allAttributesWrapper.h | 46 +- panda/src/graph/allTransitionsWrapper.I | 91 +- panda/src/graph/allTransitionsWrapper.T | 36 + panda/src/graph/allTransitionsWrapper.cxx | 1 + panda/src/graph/allTransitionsWrapper.h | 78 +- panda/src/graph/arcChain.I | 72 +- panda/src/graph/arcChain.cxx | 1 + panda/src/graph/arcChain.h | 75 +- panda/src/graph/bitMaskAttribute.I | 12 +- panda/src/graph/bitMaskAttribute.T | 103 ++ panda/src/graph/bitMaskAttribute.h | 14 +- panda/src/graph/bitMaskTransition.I | 16 +- panda/src/graph/bitMaskTransition.T | 228 ++++ panda/src/graph/bitMaskTransition.h | 18 +- panda/src/graph/boundedObject.I | 15 +- panda/src/graph/boundedObject.h | 16 +- panda/src/graph/dftraverser.I | 6 +- panda/src/graph/dftraverser.T | 124 +++ panda/src/graph/dftraverser.h | 31 +- panda/src/graph/immediateAttribute.I | 6 +- panda/src/graph/immediateAttribute.h | 10 +- panda/src/graph/immediateTransition.I | 6 +- panda/src/graph/immediateTransition.h | 8 +- panda/src/graph/matrixAttribute.I | 10 +- panda/src/graph/matrixAttribute.T | 103 ++ panda/src/graph/matrixAttribute.h | 14 +- panda/src/graph/matrixTransition.I | 12 +- panda/src/graph/matrixTransition.T | 240 +++++ panda/src/graph/matrixTransition.h | 14 +- panda/src/graph/multiAttribute.I | 16 +- panda/src/graph/multiAttribute.T | 324 ++++++ panda/src/graph/multiAttribute.h | 20 +- panda/src/graph/multiNodeAttribute.I | 6 +- panda/src/graph/multiNodeAttribute.h | 11 +- panda/src/graph/multiNodeTransition.I | 6 +- panda/src/graph/multiNodeTransition.h | 11 +- panda/src/graph/multiTransition.I | 10 +- panda/src/graph/multiTransition.T | 559 ++++++++++ panda/src/graph/multiTransition.h | 12 +- panda/src/graph/multiTransitionHelpers.h | 2 + panda/src/graph/namedNode.I | 11 +- panda/src/graph/namedNode.cxx | 2 +- panda/src/graph/namedNode.h | 16 +- panda/src/graph/node.I | 8 +- panda/src/graph/node.h | 34 +- panda/src/graph/nodeAttribute.I | 29 +- panda/src/graph/nodeAttribute.h | 31 +- panda/src/graph/nodeAttributeWrapper.I | 42 +- panda/src/graph/nodeAttributeWrapper.T | 28 + panda/src/graph/nodeAttributeWrapper.h | 31 +- panda/src/graph/nodeAttributes.I | 44 +- panda/src/graph/nodeAttributes.T | 28 + panda/src/graph/nodeAttributes.h | 33 +- panda/src/graph/nodeRelation.I | 81 +- panda/src/graph/nodeRelation.T | 34 + panda/src/graph/nodeRelation.cxx | 2 +- panda/src/graph/nodeRelation.h | 78 +- panda/src/graph/nodeTransition.I | 33 +- panda/src/graph/nodeTransition.cxx | 1 - panda/src/graph/nodeTransition.h | 35 +- panda/src/graph/nodeTransitionCache.I | 13 +- panda/src/graph/nodeTransitionCache.h | 15 +- panda/src/graph/nodeTransitionCacheEntry.I | 49 +- panda/src/graph/nodeTransitionCacheEntry.h | 51 +- panda/src/graph/nodeTransitionWrapper.I | 64 +- panda/src/graph/nodeTransitionWrapper.T | 27 + panda/src/graph/nodeTransitionWrapper.h | 55 +- panda/src/graph/nodeTransitions.I | 17 +- panda/src/graph/nodeTransitions.T | 34 + panda/src/graph/nodeTransitions.h | 24 +- panda/src/graph/nullAttributeWrapper.I | 26 +- panda/src/graph/nullAttributeWrapper.h | 27 +- panda/src/graph/nullLevelState.h | 6 +- panda/src/graph/nullTransitionWrapper.I | 45 +- panda/src/graph/nullTransitionWrapper.h | 47 +- panda/src/graph/onAttribute.I | 6 +- panda/src/graph/onAttribute.h | 10 +- panda/src/graph/onOffAttribute.I | 14 +- panda/src/graph/onOffAttribute.h | 16 +- panda/src/graph/onOffTransition.I | 18 +- panda/src/graph/onOffTransition.h | 23 +- panda/src/graph/onTransition.I | 6 +- panda/src/graph/onTransition.h | 11 +- panda/src/graph/setTransitionHelpers.T | 1104 ++++++++++++++++++++ panda/src/graph/setTransitionHelpers.h | 2 +- panda/src/graph/traverserVisitor.I | 6 +- panda/src/graph/traverserVisitor.T | 57 + panda/src/graph/traverserVisitor.h | 8 +- panda/src/graph/wrt.I | 22 +- panda/src/graph/wrt.h | 20 +- panda/src/pandabase/pandasymbols.h | 46 + 95 files changed, 4056 insertions(+), 1067 deletions(-) create mode 100644 panda/src/graph/allAttributesWrapper.T create mode 100644 panda/src/graph/allTransitionsWrapper.T create mode 100644 panda/src/graph/bitMaskAttribute.T create mode 100644 panda/src/graph/bitMaskTransition.T create mode 100644 panda/src/graph/dftraverser.T create mode 100644 panda/src/graph/matrixAttribute.T create mode 100644 panda/src/graph/matrixTransition.T create mode 100644 panda/src/graph/multiAttribute.T create mode 100644 panda/src/graph/multiTransition.T create mode 100644 panda/src/graph/nodeAttributeWrapper.T create mode 100644 panda/src/graph/nodeAttributes.T create mode 100644 panda/src/graph/nodeRelation.T create mode 100644 panda/src/graph/nodeTransitionWrapper.T create mode 100644 panda/src/graph/nodeTransitions.T create mode 100644 panda/src/graph/setTransitionHelpers.T create mode 100644 panda/src/graph/traverserVisitor.T diff --git a/panda/src/egg2sg/deferredArcProperty.h b/panda/src/egg2sg/deferredArcProperty.h index 5dd4d9ab16..4792464982 100644 --- a/panda/src/egg2sg/deferredArcProperty.h +++ b/panda/src/egg2sg/deferredArcProperty.h @@ -10,7 +10,7 @@ #include -class NodeRelation; +#include "nodeRelation.h" class Node; /////////////////////////////////////////////////////////////////// diff --git a/panda/src/graph/Sources.pp b/panda/src/graph/Sources.pp index c4b85cab3f..58faec7824 100644 --- a/panda/src/graph/Sources.pp +++ b/panda/src/graph/Sources.pp @@ -6,78 +6,119 @@ #define LOCAL_LIBS \ putil mathutil - #define SOURCES \ - allAttributesWrapper.I allAttributesWrapper.cxx \ - allAttributesWrapper.h allTransitionsWrapper.I \ - allTransitionsWrapper.cxx allTransitionsWrapper.h \ - arcChain.I arcChain.cxx arcChain.h \ - bitMask32Transition.cxx bitMask32Transition.h \ - bitMaskAttribute.I bitMaskAttribute.h \ - bitMaskTransition.I bitMaskTransition.h \ - boundedObject.I \ - boundedObject.N boundedObject.cxx boundedObject.h config_graph.cxx \ - config_graph.h graphReducer.cxx graphReducer.h immediateAttribute.I \ - immediateAttribute.cxx immediateAttribute.h immediateTransition.I \ - immediateTransition.cxx immediateTransition.h \ - lmatrix4fTransition.cxx lmatrix4fTransition.h \ - matrixAttribute.I matrixAttribute.h matrixTransition.I \ - matrixTransition.h \ - multiAttribute.I multiAttribute.h \ - multiNodeAttribute.I \ - multiNodeAttribute.cxx multiNodeAttribute.h multiNodeTransition.I \ - multiNodeTransition.cxx multiNodeTransition.h \ - multiTransition.I multiTransition.h multiTransitionHelpers.I \ - multiTransitionHelpers.h namedNode.I \ - namedNode.cxx namedNode.h node.I node.cxx node.h nodeAttribute.I \ - nodeAttribute.N nodeAttribute.cxx nodeAttribute.h \ - nodeAttributeWrapper.I nodeAttributeWrapper.cxx \ - nodeAttributeWrapper.h nodeAttributes.I nodeAttributes.N \ - nodeAttributes.cxx nodeAttributes.h nodeRelation.I nodeRelation.N \ - nodeRelation.cxx nodeRelation.h nodeTransition.I nodeTransition.N \ - nodeTransition.cxx nodeTransition.h nodeTransitionCache.I \ - nodeTransitionCache.cxx nodeTransitionCache.h \ - nodeTransitionCacheEntry.I nodeTransitionCacheEntry.cxx \ - nodeTransitionCacheEntry.h nodeTransitionWrapper.I \ - nodeTransitionWrapper.cxx nodeTransitionWrapper.h nodeTransitions.I \ - nodeTransitions.cxx nodeTransitions.h nullAttributeWrapper.I \ - nullAttributeWrapper.cxx nullAttributeWrapper.h nullLevelState.cxx \ - nullLevelState.h nullTransitionWrapper.I nullTransitionWrapper.cxx \ - nullTransitionWrapper.h onAttribute.I onAttribute.cxx onAttribute.h \ - onOffAttribute.I onOffAttribute.cxx onOffAttribute.h \ - onOffTransition.I onOffTransition.cxx onOffTransition.h \ - onTransition.I onTransition.cxx onTransition.h pt_NamedNode.N \ - pt_NamedNode.cxx pt_NamedNode.h pt_Node.N pt_Node.cxx pt_Node.h \ - setTransitionHelpers.I setTransitionHelpers.h \ - traverserVisitor.I traverserVisitor.h \ - vector_PT_Node.cxx vector_PT_Node.h wrt.I wrt.h wrt.cxx + #define SOURCES \ + allAttributesWrapper.I nodeAttributes.T \ + allAttributesWrapper.T nodeAttributes.cxx \ + allAttributesWrapper.cxx nodeAttributes.h \ + allAttributesWrapper.h nodeRelation.I \ + allTransitionsWrapper.I nodeRelation.N \ + allTransitionsWrapper.T nodeRelation.T \ + allTransitionsWrapper.cxx nodeRelation.cxx \ + allTransitionsWrapper.h nodeRelation.h \ + arcChain.I nodeTransition.I \ + arcChain.cxx nodeTransition.N \ + arcChain.h nodeTransition.cxx \ + bitMask32Transition.cxx nodeTransition.h \ + bitMask32Transition.h nodeTransitionCache.I \ + bitMaskAttribute.T nodeTransitionCache.cxx \ + bitMaskAttribute.h nodeTransitionCache.h \ + bitMaskTransition.T nodeTransitionCacheEntry.I \ + bitMaskTransition.h nodeTransitionCacheEntry.cxx \ + boundedObject.I nodeTransitionCacheEntry.h \ + boundedObject.N nodeTransitionWrapper.I \ + boundedObject.cxx nodeTransitionWrapper.T \ + boundedObject.h nodeTransitionWrapper.cxx \ + config_graph.cxx nodeTransitionWrapper.h \ + config_graph.h nodeTransitions.I \ + dftraverser.T nodeTransitions.T \ + dftraverser.h nodeTransitions.cxx \ + graphReducer.cxx nodeTransitions.h \ + graphReducer.h nullAttributeWrapper.I \ + immediateAttribute.cxx nullAttributeWrapper.cxx \ + immediateAttribute.h nullAttributeWrapper.h \ + immediateTransition.I nullLevelState.cxx \ + immediateTransition.cxx nullLevelState.h \ + immediateTransition.h nullTransitionWrapper.I \ + lmatrix4fTransition.cxx nullTransitionWrapper.cxx \ + lmatrix4fTransition.h nullTransitionWrapper.h \ + matrixAttribute.T onAttribute.cxx \ + matrixAttribute.h onAttribute.h \ + matrixTransition.T onOffAttribute.I \ + matrixTransition.h onOffAttribute.cxx \ + multiAttribute.T onOffAttribute.h \ + multiAttribute.h onOffTransition.I \ + multiNodeAttribute.cxx onOffTransition.cxx \ + multiNodeAttribute.h onOffTransition.h \ + multiNodeTransition.cxx onTransition.I \ + multiNodeTransition.h onTransition.cxx \ + multiTransition.I onTransition.h \ + multiTransition.T pointerNameClass.h \ + multiTransition.h pt_NamedNode.N \ + multiTransitionHelpers.I pt_NamedNode.cxx \ + multiTransitionHelpers.h pt_NamedNode.h \ + namedNode.I pt_Node.N \ + namedNode.cxx pt_Node.cxx \ + namedNode.h pt_Node.h \ + node.I setTransitionHelpers.T \ + node.cxx setTransitionHelpers.h \ + node.h \ + nodeAttribute.I \ + nodeAttribute.N \ + nodeAttribute.cxx transitionDirection.h \ + nodeAttribute.h traverserVisitor.T \ + nodeAttributeWrapper.I traverserVisitor.h \ + nodeAttributeWrapper.T vector_PT_Node.cxx \ + nodeAttributeWrapper.cxx vector_PT_Node.h \ + nodeAttributeWrapper.h wrt.I \ + nodeAttributes.I wrt.cxx \ + nodeAttributes.N wrt.h + #define INSTALL_HEADERS \ - allAttributesWrapper.I allAttributesWrapper.h \ - allTransitionsWrapper.I allTransitionsWrapper.h \ - arcChain.I arcChain.h \ - bitMask32Transition.h bitMaskAttribute.I bitMaskAttribute.h \ - bitMaskTransition.I bitMaskTransition.h boundedObject.I \ - boundedObject.h config_graph.h dftraverser.I dftraverser.h \ - graphReducer.h immediateAttribute.I immediateAttribute.h \ - immediateTransition.I immediateTransition.h lmatrix4fTransition.h \ - matrixAttribute.I matrixAttribute.h matrixTransition.I \ - matrixTransition.h multiAttribute.I multiAttribute.h \ - multiNodeAttribute.I multiNodeAttribute.h multiNodeTransition.I \ - multiNodeTransition.h multiTransition.I multiTransition.h \ - multiTransitionHelpers.I multiTransitionHelpers.h namedNode.I \ - namedNode.h node.I node.h nodeAttribute.I nodeAttribute.h \ - nodeAttributeWrapper.I nodeAttributeWrapper.h nodeAttributes.I \ - nodeAttributes.h nodeRelation.I nodeRelation.h nodeTransition.I \ - nodeTransition.h nodeTransitionCache.I nodeTransitionCache.h \ - nodeTransitionCacheEntry.I nodeTransitionCacheEntry.h \ - nodeTransitionWrapper.I nodeTransitionWrapper.h nodeTransitions.I \ - nodeTransitions.h nullAttributeWrapper.I nullAttributeWrapper.h \ - nullLevelState.h nullTransitionWrapper.I nullTransitionWrapper.h \ - onAttribute.I onAttribute.h onOffAttribute.I onOffAttribute.h \ - onOffTransition.I onOffTransition.h onTransition.I onTransition.h \ - pointerNameClass.h pt_NamedNode.h pt_Node.h transitionDirection.h \ - traverserVisitor.I traverserVisitor.h vector_PT_Node.h wrt.I wrt.h - + allAttributesWrapper.I nodeAttributeWrapper.T \ + allAttributesWrapper.T nodeAttributeWrapper.h \ + allAttributesWrapper.h nodeAttributes.I \ + allTransitionsWrapper.I nodeAttributes.T \ + allTransitionsWrapper.T nodeAttributes.h \ + allTransitionsWrapper.h nodeRelation.I \ + arcChain.I nodeRelation.T \ + arcChain.h nodeRelation.h \ + bitMask32Transition.h nodeTransition.I \ + bitMaskAttribute.T nodeTransition.h \ + bitMaskAttribute.h nodeTransitionCache.I \ + bitMaskTransition.T nodeTransitionCache.h \ + bitMaskTransition.h nodeTransitionCacheEntry.I \ + boundedObject.I nodeTransitionCacheEntry.h \ + boundedObject.h nodeTransitionWrapper.I \ + config_graph.h nodeTransitionWrapper.T \ + dftraverser.T nodeTransitionWrapper.h \ + dftraverser.h nodeTransitions.I \ + graphReducer.h nodeTransitions.T \ + immediateAttribute.h nodeTransitions.h \ + immediateTransition.I nullAttributeWrapper.I \ + immediateTransition.h nullAttributeWrapper.h \ + lmatrix4fTransition.h nullLevelState.h \ + matrixAttribute.T nullTransitionWrapper.I \ + matrixAttribute.h nullTransitionWrapper.h \ + matrixTransition.T onAttribute.h \ + matrixTransition.h onOffAttribute.I \ + multiAttribute.T onOffAttribute.h \ + multiAttribute.h onOffTransition.I \ + multiNodeAttribute.h onOffTransition.h \ + multiNodeTransition.h onTransition.I \ + multiTransition.I onTransition.h \ + multiTransition.T pointerNameClass.h \ + multiTransition.h pt_NamedNode.h \ + multiTransitionHelpers.I pt_Node.h \ + multiTransitionHelpers.h setTransitionHelpers.T \ + namedNode.I setTransitionHelpers.h \ + namedNode.h transitionDirection.h \ + node.I traverserVisitor.T \ + node.h traverserVisitor.h \ + nodeAttribute.I vector_PT_Node.h \ + nodeAttribute.h wrt.I \ + nodeAttributeWrapper.I wrt.h + #define IGATESCAN all #end lib_target diff --git a/panda/src/graph/allAttributesWrapper.I b/panda/src/graph/allAttributesWrapper.I index bc0a25e482..406fc3227b 100644 --- a/panda/src/graph/allAttributesWrapper.I +++ b/panda/src/graph/allAttributesWrapper.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllAttributesWrapper:: +INLINE_GRAPH AllAttributesWrapper:: AllAttributesWrapper() { } @@ -17,7 +17,7 @@ AllAttributesWrapper() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllAttributesWrapper:: +INLINE_GRAPH AllAttributesWrapper:: AllAttributesWrapper(const NodeAttributes &attrib) : _attrib(attrib) { @@ -28,7 +28,7 @@ AllAttributesWrapper(const NodeAttributes &attrib) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllAttributesWrapper:: +INLINE_GRAPH AllAttributesWrapper:: AllAttributesWrapper(const AllAttributesWrapper ©) : _attrib(copy._attrib) { @@ -39,7 +39,7 @@ AllAttributesWrapper(const AllAttributesWrapper ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void AllAttributesWrapper:: +INLINE_GRAPH void AllAttributesWrapper:: operator = (const AllAttributesWrapper ©) { _attrib = copy._attrib; } @@ -51,7 +51,7 @@ operator = (const AllAttributesWrapper ©) { // AllAttributesWrapper ready to access the same type // of AllAttributes as the other. //////////////////////////////////////////////////////////////////// -INLINE AllAttributesWrapper AllAttributesWrapper:: +INLINE_GRAPH AllAttributesWrapper AllAttributesWrapper:: init_from(const AllTransitionsWrapper &) { return AllAttributesWrapper(); } @@ -61,7 +61,7 @@ init_from(const AllTransitionsWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllAttributesWrapper:: +INLINE_GRAPH AllAttributesWrapper:: ~AllAttributesWrapper() { } @@ -72,7 +72,7 @@ INLINE AllAttributesWrapper:: // the set, or false if there are any (even initial) // Attributes. //////////////////////////////////////////////////////////////////// -INLINE bool AllAttributesWrapper:: +INLINE_GRAPH bool AllAttributesWrapper:: is_empty() const { return _attrib.is_empty(); } @@ -92,7 +92,7 @@ is_empty() const { // attribute in the set, if any, or NULL if there was // none. //////////////////////////////////////////////////////////////////// -INLINE PT(NodeAttribute) AllAttributesWrapper:: +INLINE_GRAPH PT(NodeAttribute) AllAttributesWrapper:: set_attribute(TypeHandle handle, NodeAttribute *trans) { return _attrib.set_attribute(handle, trans); } @@ -107,7 +107,7 @@ set_attribute(TypeHandle handle, NodeAttribute *trans) { // set_attribute; if the pointer might be NULL, use the // above flavor instead (or just call clear_attribute). //////////////////////////////////////////////////////////////////// -INLINE PT(NodeAttribute) AllAttributesWrapper:: +INLINE_GRAPH PT(NodeAttribute) AllAttributesWrapper:: set_attribute(NodeAttribute *trans) { nassertr(trans != (NodeAttribute *)NULL, NULL); nassertr(trans->get_handle() != TypeHandle::none(), NULL); @@ -124,7 +124,7 @@ set_attribute(NodeAttribute *trans) { // attribute in the set, if any, or NULL if there was // none. //////////////////////////////////////////////////////////////////// -INLINE PT(NodeAttribute) AllAttributesWrapper:: +INLINE_GRAPH PT(NodeAttribute) AllAttributesWrapper:: clear_attribute(TypeHandle handle) { return _attrib.clear_attribute(handle); } @@ -136,7 +136,7 @@ clear_attribute(TypeHandle handle) { // indicated handle has been stored in the set (even if // it is the initial attribute), or false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool AllAttributesWrapper:: +INLINE_GRAPH bool AllAttributesWrapper:: has_attribute(TypeHandle handle) const { return _attrib.has_attribute(handle); } @@ -148,7 +148,7 @@ has_attribute(TypeHandle handle) const { // handle, or NULL if no such attribute has been stored // in the set. //////////////////////////////////////////////////////////////////// -INLINE NodeAttribute *AllAttributesWrapper:: +INLINE_GRAPH NodeAttribute *AllAttributesWrapper:: get_attribute(TypeHandle handle) const { return _attrib.get_attribute(handle); } @@ -159,7 +159,7 @@ get_attribute(TypeHandle handle) const { // Description: Returns the entire set of attributes associated with // the wrapper. //////////////////////////////////////////////////////////////////// -INLINE const NodeAttributes &AllAttributesWrapper:: +INLINE_GRAPH const NodeAttributes &AllAttributesWrapper:: get_attributes() const { return _attrib; } @@ -170,7 +170,7 @@ get_attributes() const { // Description: Returns the entire set of attributes associated with // the wrapper. //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes &AllAttributesWrapper:: +INLINE_GRAPH NodeAttributes &AllAttributesWrapper:: get_attributes() { return _attrib; } @@ -181,7 +181,7 @@ get_attributes() { // Description: Returns true if the wrapper represents an initial // attribute. //////////////////////////////////////////////////////////////////// -INLINE bool AllAttributesWrapper:: +INLINE_GRAPH bool AllAttributesWrapper:: is_initial() const { return _attrib.is_initial(); } @@ -191,7 +191,7 @@ is_initial() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int AllAttributesWrapper:: +INLINE_GRAPH int AllAttributesWrapper:: compare_to(const AllAttributesWrapper &other) const { return _attrib.compare_to(other._attrib); } @@ -201,31 +201,12 @@ compare_to(const AllAttributesWrapper &other) const { // Access: Public // Description: Resets the wrapper to the initial attribute. //////////////////////////////////////////////////////////////////// -INLINE void AllAttributesWrapper:: +INLINE_GRAPH void AllAttributesWrapper:: make_initial() { _attrib.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: get_attribute_into -// Description: This external template function is handy for -// extracting a attribute of a particular type from the -// set. If the attribute exists, it is automatically -// downcasted to the correct type and stored in the -// pointer given in the first parameter, and the return -// value is true. If the attribute does not exist, the -// pointer is filled with NULL and the return value is -// false. -//////////////////////////////////////////////////////////////////// -template -INLINE bool -get_attribute_into(Attribute *&ptr, const AllAttributesWrapper &attrib, - TypeHandle transition_type) { - NodeAttribute *nt = attrib.get_attribute(transition_type); - if (nt == (NodeAttribute *)NULL) { - ptr = (Attribute *)NULL; - return false; - } - DCAST_INTO_R(ptr, nt, false); - return true; +INLINE_GRAPH ostream &operator << (ostream &out, const AllAttributesWrapper &a) { + a.output(out); + return out; } diff --git a/panda/src/graph/allAttributesWrapper.T b/panda/src/graph/allAttributesWrapper.T new file mode 100644 index 0000000000..fa82821737 --- /dev/null +++ b/panda/src/graph/allAttributesWrapper.T @@ -0,0 +1,28 @@ +// Filename: allAttributesWrapper.T +// Created by: drose (21Mar00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: get_attribute_into +// Description: This external template function is handy for +// extracting a attribute of a particular type from the +// set. If the attribute exists, it is automatically +// downcasted to the correct type and stored in the +// pointer given in the first parameter, and the return +// value is true. If the attribute does not exist, the +// pointer is filled with NULL and the return value is +// false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_attribute_into(Attribute *&ptr, const AllAttributesWrapper &attrib, + TypeHandle transition_type) { + NodeAttribute *nt = attrib.get_attribute(transition_type); + if (nt == (NodeAttribute *)NULL) { + ptr = (Attribute *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} diff --git a/panda/src/graph/allAttributesWrapper.h b/panda/src/graph/allAttributesWrapper.h index aefbe4bb58..4a5714dff9 100644 --- a/panda/src/graph/allAttributesWrapper.h +++ b/panda/src/graph/allAttributesWrapper.h @@ -24,29 +24,29 @@ public: typedef AllTransitionsWrapper TransitionWrapper; typedef AllAttributesWrapper AttributeWrapper; - INLINE AllAttributesWrapper(); - INLINE AllAttributesWrapper(const NodeAttributes &attrib); - INLINE AllAttributesWrapper(const AllAttributesWrapper ©); - INLINE void operator = (const AllAttributesWrapper ©); - INLINE static AllAttributesWrapper + INLINE_GRAPH AllAttributesWrapper(); + INLINE_GRAPH AllAttributesWrapper(const NodeAttributes &attrib); + INLINE_GRAPH AllAttributesWrapper(const AllAttributesWrapper ©); + INLINE_GRAPH void operator = (const AllAttributesWrapper ©); + INLINE_GRAPH static AllAttributesWrapper init_from(const AllTransitionsWrapper &trans); - INLINE ~AllAttributesWrapper(); + INLINE_GRAPH ~AllAttributesWrapper(); - INLINE bool is_empty() const; - INLINE PT(NodeAttribute) set_attribute(TypeHandle handle, + INLINE_GRAPH bool is_empty() const; + INLINE_GRAPH PT(NodeAttribute) set_attribute(TypeHandle handle, NodeAttribute *trans); - INLINE PT(NodeAttribute) set_attribute(NodeAttribute *trans); - INLINE PT(NodeAttribute) clear_attribute(TypeHandle handle); - INLINE bool has_attribute(TypeHandle handle) const; - INLINE NodeAttribute *get_attribute(TypeHandle handle) const; + INLINE_GRAPH PT(NodeAttribute) set_attribute(NodeAttribute *trans); + INLINE_GRAPH PT(NodeAttribute) clear_attribute(TypeHandle handle); + INLINE_GRAPH bool has_attribute(TypeHandle handle) const; + INLINE_GRAPH NodeAttribute *get_attribute(TypeHandle handle) const; - INLINE const NodeAttributes &get_attributes() const; - INLINE NodeAttributes &get_attributes(); + INLINE_GRAPH const NodeAttributes &get_attributes() const; + INLINE_GRAPH NodeAttributes &get_attributes(); - INLINE bool is_initial() const; - INLINE int compare_to(const AllAttributesWrapper &other) const; + INLINE_GRAPH bool is_initial() const; + INLINE_GRAPH int compare_to(const AllAttributesWrapper &other) const; - INLINE void make_initial(); + INLINE_GRAPH void make_initial(); void apply_in_place(const AllTransitionsWrapper &trans); void apply_from(const AllAttributesWrapper &other, const AllTransitionsWrapper &trans); @@ -59,16 +59,12 @@ private: NodeAttributes _attrib; }; -INLINE ostream &operator << (ostream &out, const AllAttributesWrapper &a) { - a.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const AllAttributesWrapper &a); -template -INLINE bool -get_attribute_into(Attribute *&ptr, const AllAttributesWrapper &attrib, - TypeHandle transition_type); +#include "allAttributesWrapper.T" +#ifdef BUILDING_PANDA #include "allAttributesWrapper.I" +#endif #endif diff --git a/panda/src/graph/allTransitionsWrapper.I b/panda/src/graph/allTransitionsWrapper.I index c6019fd655..0d5de3232c 100644 --- a/panda/src/graph/allTransitionsWrapper.I +++ b/panda/src/graph/allTransitionsWrapper.I @@ -10,7 +10,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper:: AllTransitionsWrapper() { } @@ -19,7 +19,7 @@ AllTransitionsWrapper() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper:: AllTransitionsWrapper(const AllTransitionsWrapper ©) : _cache(copy._cache), _all_verified(copy._all_verified) @@ -31,7 +31,7 @@ AllTransitionsWrapper(const AllTransitionsWrapper ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: operator = (const AllTransitionsWrapper ©) { _cache = copy._cache; _all_verified = copy._all_verified; @@ -42,7 +42,7 @@ operator = (const AllTransitionsWrapper ©) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper:: ~AllTransitionsWrapper() { } @@ -53,7 +53,7 @@ INLINE AllTransitionsWrapper:: // AllTransitionsWrapper ready to access the same type // of NodeTransition as the other. //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper AllTransitionsWrapper:: init_from(const AllTransitionsWrapper &) { return AllTransitionsWrapper(); } @@ -65,7 +65,7 @@ init_from(const AllTransitionsWrapper &) { // AllTransitionsWrapper ready to access the same type // of NodeTransition as the other. //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper AllTransitionsWrapper:: init_from(const AllAttributesWrapper &) { return AllTransitionsWrapper(); } @@ -77,7 +77,7 @@ init_from(const AllAttributesWrapper &) { // the wrapper, or false if there are any (even identity) // Transitions. //////////////////////////////////////////////////////////////////// -INLINE bool AllTransitionsWrapper:: +INLINE_GRAPH bool AllTransitionsWrapper:: is_empty() const { return (_cache == (NodeTransitionCache *)NULL) || @@ -99,7 +99,7 @@ is_empty() const { // transition in the set, if any, or NULL if there was // none. //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) AllTransitionsWrapper:: +INLINE_GRAPH PT(NodeTransition) AllTransitionsWrapper:: set_transition(TypeHandle handle, NodeTransition *trans) { if (_cache == (NodeTransitionCache *)NULL) { _cache = new NodeTransitionCache; @@ -118,7 +118,7 @@ set_transition(TypeHandle handle, NodeTransition *trans) { // set_transition; if the pointer might be NULL, use the // above flavor instead (or just call clear_transition). //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) AllTransitionsWrapper:: +INLINE_GRAPH PT(NodeTransition) AllTransitionsWrapper:: set_transition(NodeTransition *trans) { nassertr(trans != (NodeTransition *)NULL, NULL); nassertr(trans->get_handle() != TypeHandle::none(), NULL); @@ -135,7 +135,7 @@ set_transition(NodeTransition *trans) { // transition in the set, if any, or NULL if there was // none. //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) AllTransitionsWrapper:: +INLINE_GRAPH PT(NodeTransition) AllTransitionsWrapper:: clear_transition(TypeHandle handle) { if (_cache == (NodeTransitionCache *)NULL) { return NULL; @@ -151,7 +151,7 @@ clear_transition(TypeHandle handle) { // indicated handle has been stored in the wrapper, or // false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool AllTransitionsWrapper:: +INLINE_GRAPH bool AllTransitionsWrapper:: has_transition(TypeHandle handle) const { if (_cache == (NodeTransitionCache *)NULL) { return false; @@ -166,7 +166,7 @@ has_transition(TypeHandle handle) const { // handle, or NULL if no such transition has been stored // in the wrapper. //////////////////////////////////////////////////////////////////// -INLINE NodeTransition *AllTransitionsWrapper:: +INLINE_GRAPH NodeTransition *AllTransitionsWrapper:: get_transition(TypeHandle handle) const { if (_cache == (NodeTransitionCache *)NULL) { return NULL; @@ -181,7 +181,7 @@ get_transition(TypeHandle handle) const { // shouldn't modify this, or probably even store it for // any length of time. //////////////////////////////////////////////////////////////////// -INLINE const NodeTransitionCache &AllTransitionsWrapper:: +INLINE_GRAPH const NodeTransitionCache &AllTransitionsWrapper:: get_transitions() const { static NodeTransitionCache empty_transitions; @@ -197,7 +197,7 @@ get_transitions() const { // Description: Returns true if the wrapper represents an identity // transition. //////////////////////////////////////////////////////////////////// -INLINE bool AllTransitionsWrapper:: +INLINE_GRAPH bool AllTransitionsWrapper:: is_identity() const { if (_cache == (NodeTransitionCache *)NULL) { return true; @@ -210,7 +210,7 @@ is_identity() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int AllTransitionsWrapper:: +INLINE_GRAPH int AllTransitionsWrapper:: compare_to(const AllTransitionsWrapper &other) const { if (_cache == other._cache) { return 0; @@ -230,7 +230,7 @@ compare_to(const AllTransitionsWrapper &other) const { // Access: Public // Description: Resets the wrapper to the empty set. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: make_identity() { _cache = (NodeTransitionCache *)NULL; } @@ -241,7 +241,7 @@ make_identity() { // Description: Sets the wrapper to the set of transitions contained // on the arc. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: extract_from(const NodeRelation *arc) { nassertv(arc != (NodeRelation *)NULL); if (arc->_transitions.is_empty()) { @@ -257,7 +257,7 @@ extract_from(const NodeRelation *arc) { // Access: Public // Description: Stores all the transitions in the wrapper to the arc. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: store_to(NodeRelation *arc) const { nassertv(arc != (NodeRelation *)NULL); NodeTransitionCache::store_to(_cache, arc, arc->_transitions); @@ -269,7 +269,7 @@ store_to(NodeRelation *arc) const { // Description: Sets this transition to the composition of this // transition and the following one. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: compose_in_place(const AllTransitionsWrapper &other) { _cache = NodeTransitionCache::compose(_cache, other._cache); _all_verified.clear(); @@ -280,7 +280,7 @@ compose_in_place(const AllTransitionsWrapper &other) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: invert_in_place() { _cache = NodeTransitionCache::invert(_cache); _all_verified.clear(); @@ -292,7 +292,7 @@ invert_in_place() { // Description: Sets this transition to the composition of this // transition and the following one. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: invert_compose_in_place(const AllTransitionsWrapper &other) { _cache = NodeTransitionCache::invert_compose(_cache, other._cache); _all_verified.clear(); @@ -305,7 +305,7 @@ invert_compose_in_place(const AllTransitionsWrapper &other) { // in the cache on the arc. Also returns the arc's // top_subtree indication. //////////////////////////////////////////////////////////////////// -INLINE Node *AllTransitionsWrapper:: +INLINE_GRAPH Node *AllTransitionsWrapper:: extract_from_cache(const NodeRelation *arc) { _cache = arc->_net_transitions; _all_verified = arc->_all_verified; @@ -327,7 +327,7 @@ extract_from_cache(const NodeRelation *arc) { // have computed the complete set of net transitions to // the arc. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: store_to_cache(NodeRelation *arc, Node *top_subtree) { arc->_top_subtree = top_subtree; arc->_net_transitions = _cache; @@ -352,7 +352,7 @@ store_to_cache(NodeRelation *arc, Node *top_subtree) { // net transitions to the arc, but not necessarily all // of them. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: store_to_cache_partial(NodeRelation *arc, Node *top_subtree) { arc->_top_subtree = top_subtree; arc->_net_transitions = @@ -372,7 +372,7 @@ store_to_cache_partial(NodeRelation *arc, Node *top_subtree) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool AllTransitionsWrapper:: +INLINE_GRAPH bool AllTransitionsWrapper:: is_cache_verified(UpdateSeq as_of) const { #ifndef NDEBUG if (wrt_cat.is_spam()) { @@ -390,7 +390,7 @@ is_cache_verified(UpdateSeq as_of) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: set_computed_verified(UpdateSeq now) { _cache = NodeTransitionCache::set_computed_verified(_cache, now); _all_verified = now; @@ -410,7 +410,7 @@ set_computed_verified(UpdateSeq now) { // that indicated by value, using the cache as a helper, // and stores the result in this wrapper. //////////////////////////////////////////////////////////////////// -INLINE void AllTransitionsWrapper:: +INLINE_GRAPH void AllTransitionsWrapper:: cached_compose(const AllTransitionsWrapper &cache, const AllTransitionsWrapper &value, UpdateSeq now) { @@ -424,7 +424,7 @@ cached_compose(const AllTransitionsWrapper &cache, // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper::size_type AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper::size_type AllTransitionsWrapper:: size() const { if (_cache == (NodeTransitionCache *)NULL) { return 0; @@ -437,7 +437,7 @@ size() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper::const_iterator AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper::const_iterator AllTransitionsWrapper:: begin() const { if (_cache == (NodeTransitionCache *)NULL) { return _empty_cache.begin(); @@ -450,7 +450,7 @@ begin() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE AllTransitionsWrapper::const_iterator AllTransitionsWrapper:: +INLINE_GRAPH AllTransitionsWrapper::const_iterator AllTransitionsWrapper:: end() const { if (_cache == (NodeTransitionCache *)NULL) { // We intentionally return begin() instead of end() here, just in @@ -460,32 +460,7 @@ end() const { return _cache->end(); } -//////////////////////////////////////////////////////////////////// -// Function: get_transition_into -// Description: This external template function is handy for -// extracting a transition of a particular type from the -// set. If the transition exists, it is automatically -// downcasted to the correct type and stored in the -// pointer given in the first parameter, and the return -// value is true. If the transition does not exist, the -// pointer is filled with NULL and the return value is -// false. -//////////////////////////////////////////////////////////////////// -template -INLINE bool -get_transition_into(Transition *&ptr, const AllTransitionsWrapper &trans, - TypeHandle transition_type) { - NodeTransition *nt = trans.get_transition(transition_type); - if (nt == (NodeTransition *)NULL) { - ptr = (Transition *)NULL; - return false; - } - DCAST_INTO_R(ptr, nt, false); - return true; -} - -template -INLINE bool -get_transition_into(Transition *&ptr, const AllTransitionsWrapper &trans) { - return get_transition_into(ptr, trans, Transition::get_class_type()); +INLINE_GRAPH ostream &operator << (ostream &out, const AllTransitionsWrapper &ntw) { + ntw.output(out); + return out; } diff --git a/panda/src/graph/allTransitionsWrapper.T b/panda/src/graph/allTransitionsWrapper.T new file mode 100644 index 0000000000..02b1928bd3 --- /dev/null +++ b/panda/src/graph/allTransitionsWrapper.T @@ -0,0 +1,36 @@ +// Filename: allTransitionsWrapper.T +// Created by: drose (21Mar00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: get_transition_into +// Description: This external template function is handy for +// extracting a transition of a particular type from the +// set. If the transition exists, it is automatically +// downcasted to the correct type and stored in the +// pointer given in the first parameter, and the return +// value is true. If the transition does not exist, the +// pointer is filled with NULL and the return value is +// false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const AllTransitionsWrapper &trans, + TypeHandle transition_type) { + NodeTransition *nt = trans.get_transition(transition_type); + if (nt == (NodeTransition *)NULL) { + ptr = (Transition *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} + +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const AllTransitionsWrapper &trans) { + return get_transition_into(ptr, trans, Transition::get_class_type()); +} + + diff --git a/panda/src/graph/allTransitionsWrapper.cxx b/panda/src/graph/allTransitionsWrapper.cxx index a82765920f..8df1852b8d 100644 --- a/panda/src/graph/allTransitionsWrapper.cxx +++ b/panda/src/graph/allTransitionsWrapper.cxx @@ -33,3 +33,4 @@ write(ostream &out, int indent_level) const { _cache->write(out, indent_level); } } + diff --git a/panda/src/graph/allTransitionsWrapper.h b/panda/src/graph/allTransitionsWrapper.h index acb36af168..f909bf7f9a 100644 --- a/panda/src/graph/allTransitionsWrapper.h +++ b/panda/src/graph/allTransitionsWrapper.h @@ -44,44 +44,44 @@ public: typedef AllTransitionsWrapper TransitionWrapper; typedef AllAttributesWrapper AttributeWrapper; - INLINE AllTransitionsWrapper(); - INLINE AllTransitionsWrapper(const AllTransitionsWrapper ©); - INLINE void operator = (const AllTransitionsWrapper ©); - INLINE ~AllTransitionsWrapper(); + INLINE_GRAPH AllTransitionsWrapper(); + INLINE_GRAPH AllTransitionsWrapper(const AllTransitionsWrapper ©); + INLINE_GRAPH void operator = (const AllTransitionsWrapper ©); + INLINE_GRAPH ~AllTransitionsWrapper(); - INLINE static AllTransitionsWrapper + INLINE_GRAPH static AllTransitionsWrapper init_from(const AllTransitionsWrapper &other); - INLINE static AllTransitionsWrapper + INLINE_GRAPH static AllTransitionsWrapper init_from(const AllAttributesWrapper &attrib); - INLINE bool is_empty() const; - INLINE PT(NodeTransition) set_transition(TypeHandle handle, + INLINE_GRAPH bool is_empty() const; + INLINE_GRAPH PT(NodeTransition) set_transition(TypeHandle handle, NodeTransition *trans); - INLINE PT(NodeTransition) set_transition(NodeTransition *trans); - INLINE PT(NodeTransition) clear_transition(TypeHandle handle); - INLINE bool has_transition(TypeHandle handle) const; - INLINE NodeTransition *get_transition(TypeHandle handle) const; + INLINE_GRAPH PT(NodeTransition) set_transition(NodeTransition *trans); + INLINE_GRAPH PT(NodeTransition) clear_transition(TypeHandle handle); + INLINE_GRAPH bool has_transition(TypeHandle handle) const; + INLINE_GRAPH NodeTransition *get_transition(TypeHandle handle) const; - INLINE const NodeTransitionCache &get_transitions() const; + INLINE_GRAPH const NodeTransitionCache &get_transitions() const; - INLINE bool is_identity() const; - INLINE int compare_to(const AllTransitionsWrapper &other) const; + INLINE_GRAPH bool is_identity() const; + INLINE_GRAPH int compare_to(const AllTransitionsWrapper &other) const; - INLINE void make_identity(); - INLINE void extract_from(const NodeRelation *arc); - INLINE void store_to(NodeRelation *arc) const; + INLINE_GRAPH void make_identity(); + INLINE_GRAPH void extract_from(const NodeRelation *arc); + INLINE_GRAPH void store_to(NodeRelation *arc) const; - INLINE void compose_in_place(const AllTransitionsWrapper &other); - INLINE void invert_in_place(); - INLINE void invert_compose_in_place(const AllTransitionsWrapper &other); + INLINE_GRAPH void compose_in_place(const AllTransitionsWrapper &other); + INLINE_GRAPH void invert_in_place(); + INLINE_GRAPH void invert_compose_in_place(const AllTransitionsWrapper &other); - INLINE Node *extract_from_cache(const NodeRelation *arc); - INLINE void store_to_cache(NodeRelation *arc, Node *top_subtree); - INLINE void store_to_cache_partial(NodeRelation *arc, Node *top_subtree); - INLINE bool is_cache_verified(UpdateSeq as_of) const; - INLINE void set_computed_verified(UpdateSeq now); + INLINE_GRAPH Node *extract_from_cache(const NodeRelation *arc); + INLINE_GRAPH void store_to_cache(NodeRelation *arc, Node *top_subtree); + INLINE_GRAPH void store_to_cache_partial(NodeRelation *arc, Node *top_subtree); + INLINE_GRAPH bool is_cache_verified(UpdateSeq as_of) const; + INLINE_GRAPH void set_computed_verified(UpdateSeq now); - INLINE void cached_compose(const AllTransitionsWrapper &cache, + INLINE_GRAPH void cached_compose(const AllTransitionsWrapper &cache, const AllTransitionsWrapper &value, UpdateSeq now); @@ -96,9 +96,9 @@ public: typedef NodeTransitionCache::value_type value_type; typedef NodeTransitionCache::size_type size_type; - INLINE size_type size() const; - INLINE const_iterator begin() const; - INLINE const_iterator end() const; + INLINE_GRAPH size_type size() const; + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; public: void output(ostream &out) const; @@ -112,23 +112,15 @@ private: // empty. It's used just so we can have a sensible return value // from begin() and end() when our pointer is NULL. static NodeTransitionCache _empty_cache; -friend class AllAttributesWrapper; + friend class AllAttributesWrapper; }; -INLINE ostream &operator << (ostream &out, const AllTransitionsWrapper &ntw) { - ntw.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const AllTransitionsWrapper &ntw); -template -INLINE bool -get_transition_into(Transition *&ptr, const AllTransitionsWrapper &trans, - TypeHandle transition_type); - -template -INLINE bool -get_transition_into(Transition *&ptr, const AllTransitionsWrapper &trans); +#include "allTransitionsWrapper.T" +#ifdef BUILDING_PANDA #include "allTransitionsWrapper.I" +#endif #endif diff --git a/panda/src/graph/arcChain.I b/panda/src/graph/arcChain.I index d47939cac1..5fc4f74aae 100644 --- a/panda/src/graph/arcChain.I +++ b/panda/src/graph/arcChain.I @@ -10,7 +10,7 @@ // This kind of ArcComponent may *only* be at the head // of the chain; i.e. _next must always be NULL. //////////////////////////////////////////////////////////////////// -INLINE ArcChain::ArcComponent:: +INLINE_GRAPH ArcChain::ArcComponent:: ArcComponent(Node *node) : _next(NULL) { @@ -27,7 +27,7 @@ ArcComponent(Node *node) : // tail of the chain; it may not be at the head of the // chain; i.e. _next must never be NULL. //////////////////////////////////////////////////////////////////// -INLINE ArcChain::ArcComponent:: +INLINE_GRAPH ArcChain::ArcComponent:: ArcComponent(NodeRelation *arc, ArcComponent *next) : _next(next) { @@ -43,7 +43,7 @@ ArcComponent(NodeRelation *arc, ArcComponent *next) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ArcChain::ArcComponent:: +INLINE_GRAPH ArcChain::ArcComponent:: ArcComponent(const ArcComponent ©) : _next(copy._next) { @@ -63,7 +63,7 @@ ArcComponent(const ArcComponent ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ArcChain::ArcComponent:: +INLINE_GRAPH ArcChain::ArcComponent:: ~ArcComponent() { if (has_arc()) { _p._arc->unref_parent(); @@ -79,7 +79,7 @@ INLINE ArcChain::ArcComponent:: // Description: Returns true if this component stores an arc, false // if it stores a node. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain::ArcComponent:: +INLINE_GRAPH bool ArcChain::ArcComponent:: has_arc() const { return (_next != (ArcComponent *)NULL); } @@ -91,7 +91,7 @@ has_arc() const { // an error to call this unless has_arc() has already // returned true. //////////////////////////////////////////////////////////////////// -INLINE NodeRelation *ArcChain::ArcComponent:: +INLINE_GRAPH NodeRelation *ArcChain::ArcComponent:: get_arc() const { nassertr(has_arc(), (NodeRelation *)NULL); return _p._arc; @@ -106,7 +106,7 @@ get_arc() const { // references an arc (has_arc() is true), this will // return the child node of the arc. //////////////////////////////////////////////////////////////////// -INLINE Node *ArcChain::ArcComponent:: +INLINE_GRAPH Node *ArcChain::ArcComponent:: get_node() const { if (has_arc()) { return _p._arc->get_child(); @@ -123,7 +123,7 @@ get_node() const { // top of the chain that represents a node; the rest of // the chain represents arcs. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain::ArcComponent:: +INLINE_GRAPH bool ArcChain::ArcComponent:: is_top_node() const { return (_next == (ArcComponent *)NULL); } @@ -136,7 +136,7 @@ is_top_node() const { // top of the chain; the highest component in the chain // that still represents an arc. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain::ArcComponent:: +INLINE_GRAPH bool ArcChain::ArcComponent:: is_top_arc() const { return (_next != (ArcComponent *)NULL && _next->is_top_node()); } @@ -146,7 +146,7 @@ is_top_arc() const { // Access: Public // Description: Returns the next component in the chain. //////////////////////////////////////////////////////////////////// -INLINE ArcChain::ArcComponent *ArcChain::ArcComponent:: +INLINE_GRAPH ArcChain::ArcComponent *ArcChain::ArcComponent:: get_next() const { return _next; } @@ -158,7 +158,7 @@ get_next() const { // the chain at this component and relinks it to another // chain. //////////////////////////////////////////////////////////////////// -INLINE void ArcChain::ArcComponent:: +INLINE_GRAPH void ArcChain::ArcComponent:: set_next(ArcComponent *next) { nassertv(next != (ArcComponent *)NULL); nassertv(_next != (ArcComponent *)NULL); @@ -176,7 +176,7 @@ set_next(ArcComponent *next) { // relative wrt to the particular instance we've reached // so far. //////////////////////////////////////////////////////////////////// -INLINE ArcChain::ForwardIterator:: +INLINE_GRAPH ArcChain::ForwardIterator:: ForwardIterator(ArcChain::ArcComponent *comp) : _comp(comp) { } @@ -185,7 +185,7 @@ ForwardIterator(ArcChain::ArcComponent *comp) : _comp(comp) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeRelation *ArcChain::ForwardIterator:: +INLINE_GRAPH NodeRelation *ArcChain::ForwardIterator:: operator * () const { nassertr(_comp != (ArcComponent *)NULL, NULL); return _comp->get_arc(); @@ -196,7 +196,7 @@ operator * () const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void ArcChain::ForwardIterator:: +INLINE_GRAPH void ArcChain::ForwardIterator:: operator ++() { nassertv(_comp != (ArcComponent *)NULL); if (_comp->is_top_arc()) { @@ -213,7 +213,7 @@ operator ++() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain::ForwardIterator:: +INLINE_GRAPH bool ArcChain::ForwardIterator:: operator == (const ArcChain::ForwardIterator &other) const { return _comp == other._comp; } @@ -223,7 +223,7 @@ operator == (const ArcChain::ForwardIterator &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain::ForwardIterator:: +INLINE_GRAPH bool ArcChain::ForwardIterator:: operator != (const ArcChain::ForwardIterator &other) const { return _comp != other._comp; } @@ -237,7 +237,7 @@ operator != (const ArcChain::ForwardIterator &other) const { // that receives a node if you ever want to do anything // with this chain. //////////////////////////////////////////////////////////////////// -INLINE ArcChain:: +INLINE_GRAPH ArcChain:: ArcChain() { } @@ -249,7 +249,7 @@ ArcChain() { // push_back() with each arc below that node in // sequence. //////////////////////////////////////////////////////////////////// -INLINE ArcChain:: +INLINE_GRAPH ArcChain:: ArcChain(Node *top_node) { _head = new ArcComponent(top_node); } @@ -259,7 +259,7 @@ ArcChain(Node *top_node) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ArcChain:: +INLINE_GRAPH ArcChain:: ArcChain(const ArcChain ©) : _head(copy._head) { @@ -270,7 +270,7 @@ ArcChain(const ArcChain ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void ArcChain:: +INLINE_GRAPH void ArcChain:: operator = (const ArcChain ©) { _head = copy._head; } @@ -281,7 +281,7 @@ operator = (const ArcChain ©) { // Description: Returns true if there is at least a top node in the // chain, or false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain:: +INLINE_GRAPH bool ArcChain:: has_node() const { return (_head != (ArcComponent *)NULL); } @@ -292,7 +292,7 @@ has_node() const { // Description: Returns true if there are any arcs in the chain, or // false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain:: +INLINE_GRAPH bool ArcChain:: has_arcs() const { return (_head != (ArcComponent *)NULL && !_head->is_top_node()); } @@ -303,7 +303,7 @@ has_arcs() const { // Description: Returns an iterator that can be used to traverse the // list of arcs. //////////////////////////////////////////////////////////////////// -INLINE ArcChain::const_iterator ArcChain:: +INLINE_GRAPH ArcChain::const_iterator ArcChain:: begin() const { if (empty()) { return ForwardIterator(); @@ -318,7 +318,7 @@ begin() const { // Description: Returns an iterator that can be used to traverse the // list of arcs. //////////////////////////////////////////////////////////////////// -INLINE ArcChain::const_iterator ArcChain:: +INLINE_GRAPH ArcChain::const_iterator ArcChain:: end() const { return ForwardIterator(); } @@ -330,7 +330,7 @@ end() const { // .. end() is empty (i.e. begin() == end()), false // otherwise. This is the same as !has_arcs(). //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain:: +INLINE_GRAPH bool ArcChain:: empty() const { return (_head == (ArcComponent *)NULL || _head->is_top_node()); } @@ -340,7 +340,7 @@ empty() const { // Access: Public // Description: Appends the indicated arc onto the end of the chain. //////////////////////////////////////////////////////////////////// -INLINE void ArcChain:: +INLINE_GRAPH void ArcChain:: push_back(NodeRelation *arc) { // It is invalid to push an arc onto a chain that does not already // have at least a top node. @@ -353,7 +353,7 @@ push_back(NodeRelation *arc) { // Access: Public // Description: Removes the last arc from the end of the chain. //////////////////////////////////////////////////////////////////// -INLINE void ArcChain:: +INLINE_GRAPH void ArcChain:: pop_back() { nassertv(_head != (ArcComponent *)NULL); _head = _head->get_next(); @@ -367,7 +367,7 @@ pop_back() { // Access: Public // Description: Returns the last arc in the chain. //////////////////////////////////////////////////////////////////// -INLINE NodeRelation *ArcChain:: +INLINE_GRAPH NodeRelation *ArcChain:: back() const { nassertr(_head != (ArcComponent *)NULL, (NodeRelation *)NULL); return _head->get_arc(); @@ -380,7 +380,7 @@ back() const { // is, if they contain the same list of arcs in the same // order. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain:: +INLINE_GRAPH bool ArcChain:: operator == (const ArcChain &other) const { return (compare_to(other) == 0); } @@ -390,7 +390,7 @@ operator == (const ArcChain &other) const { // Access: Public // Description: Returns true if the two chains are not equivalent. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain:: +INLINE_GRAPH bool ArcChain:: operator != (const ArcChain &other) const { return !operator == (other); } @@ -404,7 +404,7 @@ operator != (const ArcChain &other) const { // and is useful only for storing ArcChains in a sorted // container like an STL set. //////////////////////////////////////////////////////////////////// -INLINE bool ArcChain:: +INLINE_GRAPH bool ArcChain:: operator < (const ArcChain &other) const { return (compare_to(other) < 0); } @@ -424,7 +424,7 @@ operator < (const ArcChain &other) const { // placing the ArcChains in a sorted container like an // STL set. //////////////////////////////////////////////////////////////////// -INLINE int ArcChain:: +INLINE_GRAPH int ArcChain:: compare_to(const ArcChain &other) const { return r_compare_to(_head, other._head); } @@ -435,7 +435,7 @@ compare_to(const ArcChain &other) const { // Description: Writes a sensible description of the ArcChain to the // indicated output stream. //////////////////////////////////////////////////////////////////// -INLINE void ArcChain:: +INLINE_GRAPH void ArcChain:: output(ostream &out) const { if (_head == (ArcComponent *)NULL) { out << "(empty)"; @@ -443,3 +443,9 @@ output(ostream &out) const { r_output(out, _head); } } + +INLINE_GRAPH ostream &operator << (ostream &out, const ArcChain &arc_chain) { + arc_chain.output(out); + return out; +} + diff --git a/panda/src/graph/arcChain.cxx b/panda/src/graph/arcChain.cxx index 82ec7843d0..a0d62bc8eb 100644 --- a/panda/src/graph/arcChain.cxx +++ b/panda/src/graph/arcChain.cxx @@ -106,3 +106,4 @@ r_compare_to(const ArcComponent *a, const ArcComponent *b) { return r_compare_to(a->get_next(), b->get_next()); } } + diff --git a/panda/src/graph/arcChain.h b/panda/src/graph/arcChain.h index a83bc3388b..bee1a0a83e 100644 --- a/panda/src/graph/arcChain.h +++ b/panda/src/graph/arcChain.h @@ -61,22 +61,22 @@ protected: // in the chain will store a reference-counting pointer to the // chain's top node. - class ArcComponent : public ReferenceCount { + class EXPCL_PANDA ArcComponent : public ReferenceCount { public: - INLINE ArcComponent(Node *node); - INLINE ArcComponent(NodeRelation *arc, ArcComponent *next); - INLINE ArcComponent(const ArcComponent ©); + INLINE_GRAPH ArcComponent(Node *node); + INLINE_GRAPH ArcComponent(NodeRelation *arc, ArcComponent *next); + INLINE_GRAPH ArcComponent(const ArcComponent ©); void operator = (const ArcComponent ©); - INLINE ~ArcComponent(); + INLINE_GRAPH ~ArcComponent(); - INLINE bool has_arc() const; - INLINE NodeRelation *get_arc() const; - INLINE Node *get_node() const; - INLINE bool is_top_node() const; - INLINE bool is_top_arc() const; + INLINE_GRAPH bool has_arc() const; + INLINE_GRAPH NodeRelation *get_arc() const; + INLINE_GRAPH Node *get_node() const; + INLINE_GRAPH bool is_top_node() const; + INLINE_GRAPH bool is_top_arc() const; - INLINE ArcComponent *get_next() const; - INLINE void set_next(ArcComponent *next); + INLINE_GRAPH ArcComponent *get_next() const; + INLINE_GRAPH void set_next(ArcComponent *next); private: union { @@ -95,11 +95,11 @@ protected: // begin() .. end(). class ForwardIterator { public: - INLINE ForwardIterator(ArcComponent *comp = NULL); - INLINE NodeRelation *operator * () const; - INLINE void operator ++(); - INLINE bool operator == (const ForwardIterator &other) const; - INLINE bool operator != (const ForwardIterator &other) const; + INLINE_GRAPH ForwardIterator(ArcComponent *comp = NULL); + INLINE_GRAPH NodeRelation *operator * () const; + INLINE_GRAPH void operator ++(); + INLINE_GRAPH bool operator == (const ForwardIterator &other) const; + INLINE_GRAPH bool operator != (const ForwardIterator &other) const; private: ArcComponent *_comp; @@ -109,39 +109,38 @@ public: typedef ForwardIterator iterator; typedef ForwardIterator const_iterator; - INLINE ArcChain(); - INLINE ArcChain(Node *top_node); - INLINE ArcChain(const ArcChain ©); - INLINE void operator = (const ArcChain ©); + INLINE_GRAPH ArcChain(); + INLINE_GRAPH ArcChain(Node *top_node); + INLINE_GRAPH ArcChain(const ArcChain ©); + INLINE_GRAPH void operator = (const ArcChain ©); - INLINE bool has_node() const; - INLINE bool has_arcs() const; + INLINE_GRAPH bool has_node() const; + INLINE_GRAPH bool has_arcs() const; - INLINE const_iterator begin() const; - INLINE const_iterator end() const; - INLINE bool empty() const; + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; + INLINE_GRAPH bool empty() const; - INLINE void push_back(NodeRelation *arc); - INLINE void pop_back(); - INLINE NodeRelation *back() const; + INLINE_GRAPH void push_back(NodeRelation *arc); + INLINE_GRAPH void pop_back(); + INLINE_GRAPH NodeRelation *back() const; - INLINE bool operator == (const ArcChain &other) const; - INLINE bool operator != (const ArcChain &other) const; - INLINE bool operator < (const ArcChain &other) const; - INLINE int compare_to(const ArcChain &other) const; + INLINE_GRAPH bool operator == (const ArcChain &other) const; + INLINE_GRAPH bool operator != (const ArcChain &other) const; + INLINE_GRAPH bool operator < (const ArcChain &other) const; + INLINE_GRAPH int compare_to(const ArcChain &other) const; - INLINE void output(ostream &out) const; + INLINE_GRAPH void output(ostream &out) const; private: void r_output(ostream &out, ArcComponent *comp) const; static int r_compare_to(const ArcComponent *a, const ArcComponent *v); }; -INLINE ostream &operator << (ostream &out, const ArcChain &arc_chain) { - arc_chain.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const ArcChain &arc_chain); +#ifdef BUILDING_PANDA #include "arcChain.I" +#endif #endif diff --git a/panda/src/graph/bitMaskAttribute.I b/panda/src/graph/bitMaskAttribute.I index 0d2130123a..bfc232ae0b 100644 --- a/panda/src/graph/bitMaskAttribute.I +++ b/panda/src/graph/bitMaskAttribute.I @@ -14,7 +14,7 @@ TypeHandle BitMaskAttribute::_type_handle; // Description: //////////////////////////////////////////////////////////////////// template -INLINE BitMaskAttribute:: +INLINE_GRAPH BitMaskAttribute:: BitMaskAttribute() { } @@ -24,7 +24,7 @@ BitMaskAttribute() { // Description: //////////////////////////////////////////////////////////////////// template -INLINE BitMaskAttribute:: +INLINE_GRAPH BitMaskAttribute:: BitMaskAttribute(const MaskType &mask) : _mask(mask) { @@ -36,7 +36,7 @@ BitMaskAttribute(const MaskType &mask) : // Description: //////////////////////////////////////////////////////////////////// template -INLINE BitMaskAttribute:: +INLINE_GRAPH BitMaskAttribute:: BitMaskAttribute(const BitMaskAttribute ©) : NodeAttribute(copy), _mask(copy._mask) @@ -49,7 +49,7 @@ BitMaskAttribute(const BitMaskAttribute ©) : // Description: //////////////////////////////////////////////////////////////////// template -INLINE void BitMaskAttribute:: +INLINE_GRAPH void BitMaskAttribute:: operator = (const BitMaskAttribute ©) { NodeAttribute::operator = (copy); _mask = copy._mask; @@ -61,7 +61,7 @@ operator = (const BitMaskAttribute ©) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE void BitMaskAttribute:: +INLINE_GRAPH void BitMaskAttribute:: set_mask(const MaskType &mask) { _mask = mask; } @@ -72,7 +72,7 @@ set_mask(const MaskType &mask) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE const MaskType &BitMaskAttribute:: +INLINE_GRAPH const MaskType &BitMaskAttribute:: get_mask() const { return _mask; } diff --git a/panda/src/graph/bitMaskAttribute.T b/panda/src/graph/bitMaskAttribute.T new file mode 100644 index 0000000000..bfc232ae0b --- /dev/null +++ b/panda/src/graph/bitMaskAttribute.T @@ -0,0 +1,103 @@ +// Filename: bitMaskAttribute.I +// Created by: drose (08Jun00) +// +//////////////////////////////////////////////////////////////////// + +#include + +template +TypeHandle BitMaskAttribute::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH BitMaskAttribute:: +BitMaskAttribute() { +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH BitMaskAttribute:: +BitMaskAttribute(const MaskType &mask) : + _mask(mask) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH BitMaskAttribute:: +BitMaskAttribute(const BitMaskAttribute ©) : + NodeAttribute(copy), + _mask(copy._mask) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void BitMaskAttribute:: +operator = (const BitMaskAttribute ©) { + NodeAttribute::operator = (copy); + _mask = copy._mask; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::set_mask +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void BitMaskAttribute:: +set_mask(const MaskType &mask) { + _mask = mask; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::get_maskType +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH const MaskType &BitMaskAttribute:: +get_mask() const { + return _mask; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void BitMaskAttribute:: +output(ostream &out) const { + out << _mask; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskAttribute::internal_compare_to +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +int BitMaskAttribute:: +internal_compare_to(const NodeAttribute *other) const { + const BitMaskAttribute *ot; + DCAST_INTO_R(ot, other, false); + + return _mask.compare_to(ot->_mask); +} diff --git a/panda/src/graph/bitMaskAttribute.h b/panda/src/graph/bitMaskAttribute.h index 31df11689f..4618763eca 100644 --- a/panda/src/graph/bitMaskAttribute.h +++ b/panda/src/graph/bitMaskAttribute.h @@ -20,14 +20,14 @@ class BitMaskTransition; template class BitMaskAttribute : public NodeAttribute { protected: - INLINE BitMaskAttribute(); - INLINE BitMaskAttribute(const MaskType &mask); - INLINE BitMaskAttribute(const BitMaskAttribute ©); - INLINE void operator = (const BitMaskAttribute ©); + INLINE_GRAPH BitMaskAttribute(); + INLINE_GRAPH BitMaskAttribute(const MaskType &mask); + INLINE_GRAPH BitMaskAttribute(const BitMaskAttribute ©); + INLINE_GRAPH void operator = (const BitMaskAttribute ©); public: - INLINE void set_mask(const MaskType &mask); - INLINE const MaskType &get_mask() const; + INLINE_GRAPH void set_mask(const MaskType &mask); + INLINE_GRAPH const MaskType &get_mask() const; virtual void output(ostream &out) const; @@ -59,6 +59,6 @@ private: friend class BitMaskTransition; }; -#include "bitMaskAttribute.I" +#include "bitMaskAttribute.T" #endif diff --git a/panda/src/graph/bitMaskTransition.I b/panda/src/graph/bitMaskTransition.I index 217bf9ffa4..f086bb4fbd 100644 --- a/panda/src/graph/bitMaskTransition.I +++ b/panda/src/graph/bitMaskTransition.I @@ -16,7 +16,7 @@ TypeHandle BitMaskTransition::_type_handle; // Description: //////////////////////////////////////////////////////////////////// template -INLINE BitMaskTransition:: +INLINE_GRAPH BitMaskTransition:: BitMaskTransition() { _and = MaskType::all_on(); _or = MaskType::all_off(); @@ -28,7 +28,7 @@ BitMaskTransition() { // Description: //////////////////////////////////////////////////////////////////// template -INLINE BitMaskTransition:: +INLINE_GRAPH BitMaskTransition:: BitMaskTransition(const MaskType &and, const MaskType &or) { _and = and; _or = or; @@ -40,7 +40,7 @@ BitMaskTransition(const MaskType &and, const MaskType &or) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE BitMaskTransition:: +INLINE_GRAPH BitMaskTransition:: BitMaskTransition(const BitMaskTransition ©) : NodeTransition(copy), _and(copy._and), @@ -54,7 +54,7 @@ BitMaskTransition(const BitMaskTransition ©) : // Description: //////////////////////////////////////////////////////////////////// template -INLINE void BitMaskTransition:: +INLINE_GRAPH void BitMaskTransition:: operator = (const BitMaskTransition ©) { NodeTransition::operator = (copy); _and = copy._and; @@ -67,7 +67,7 @@ operator = (const BitMaskTransition ©) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE void BitMaskTransition:: +INLINE_GRAPH void BitMaskTransition:: set_and(const MaskType &and) { _and = and; state_changed(); @@ -79,7 +79,7 @@ set_and(const MaskType &and) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE const MaskType &BitMaskTransition:: +INLINE_GRAPH const MaskType &BitMaskTransition:: get_and() const { return _and; } @@ -90,7 +90,7 @@ get_and() const { // Description: //////////////////////////////////////////////////////////////////// template -INLINE void BitMaskTransition:: +INLINE_GRAPH void BitMaskTransition:: set_or(const MaskType &or) { _or = or; state_changed(); @@ -102,7 +102,7 @@ set_or(const MaskType &or) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE const MaskType &BitMaskTransition:: +INLINE_GRAPH const MaskType &BitMaskTransition:: get_or() const { return _or; } diff --git a/panda/src/graph/bitMaskTransition.T b/panda/src/graph/bitMaskTransition.T new file mode 100644 index 0000000000..47a1174e55 --- /dev/null +++ b/panda/src/graph/bitMaskTransition.T @@ -0,0 +1,228 @@ +// Filename: bitMaskTransition.I +// Created by: drose (08Jun00) +// +//////////////////////////////////////////////////////////////////// + +#include "bitMaskAttribute.h" + +template +TypeHandle BitMaskTransition::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH BitMaskTransition:: +BitMaskTransition() { + _and = MaskType::all_on(); + _or = MaskType::all_off(); +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH BitMaskTransition:: +BitMaskTransition(const MaskType &and, const MaskType &or) { + _and = and; + _or = or; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH BitMaskTransition:: +BitMaskTransition(const BitMaskTransition ©) : + NodeTransition(copy), + _and(copy._and), + _or(copy._or) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void BitMaskTransition:: +operator = (const BitMaskTransition ©) { + NodeTransition::operator = (copy); + _and = copy._and; + _or = copy._or; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::set_and +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void BitMaskTransition:: +set_and(const MaskType &and) { + _and = and; + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::get_and +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH const MaskType &BitMaskTransition:: +get_and() const { + return _and; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::set_or +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void BitMaskTransition:: +set_or(const MaskType &or) { + _or = or; + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::get_or +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH const MaskType &BitMaskTransition:: +get_or() const { + return _or; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::compose +// Access: Public, Virtual +// Description: Returns a new transition that corresponds to the +// composition of this transition with the second +// transition (which must be of an equivalent type). +// This may return the same pointer as either source +// transition. Applying the transition returned from +// this function to an attribute attribute will produce +// the same effect as applying each transition +// separately. +//////////////////////////////////////////////////////////////////// +template +NodeTransition *BitMaskTransition:: +compose(const NodeTransition *other) const { + const BitMaskTransition *ot; + DCAST_INTO_R(ot, other, NULL); + + if (ot->_priority < _priority) { + // The other transition is too low-priority; the result is + // unchanged. + return (BitMaskTransition *)this; + } + + return make_with_masks(ot->_and & _and, ot->_or | _or); +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::invert +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +NodeTransition *BitMaskTransition:: +invert() const { + return NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::apply +// Access: Public, Virtual +// Description: Returns a new attribute (or possibly the same +// attribute) that represents the effect of applying this +// indicated transition to the indicated attribute. The +// source attribute may be NULL, indicating the initial +// attribute. +//////////////////////////////////////////////////////////////////// +template +NodeAttribute *BitMaskTransition:: +apply(const NodeAttribute *attrib) const { + BitMaskAttribute *result; + DCAST_INTO_R(result, make_attrib(), NULL); + + if (attrib == (const NodeAttribute *)NULL) { + // If there is no root attribute, the default attribute is always + // all bits on. + result->_mask = (MaskType::all_on() & _and) | _or; + return result; + } + + if (_priority < result->_priority) { + // The priority is too low to affect the attribute. + return result; + } + + const BitMaskAttribute *at; + DCAST_INTO_R(at, attrib, NULL); + + result->_mask = (at->_mask & _and) | _or; + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void BitMaskTransition:: +output(ostream &out) const { + out << "&"; + _and.output_hex(out); + out << " |"; + _or.output_hex(out); +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::internal_compare_to +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +int BitMaskTransition:: +internal_compare_to(const NodeTransition *other) const { + const BitMaskTransition *ot; + DCAST_INTO_R(ot, other, false); + + int result = _and.compare_to(ot->_and); + if (result == 0) { + result = _or.compare_to(ot->_or); + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMaskTransition::make_with_masks +// Access: Protected, Virtual +// Description: This function creates a new BitMaskTransition of the +// appropriate type, given the indicated and & or masks. +// +// This is a pure virtual function and normally wouldn't +// require a definition, but for some reason VC++ +// objects to instantiating the template if it's missing +// any function definitions--even those for pure-virtual +// functions. +//////////////////////////////////////////////////////////////////// +template +BitMaskTransition *BitMaskTransition:: +make_with_masks(const MaskType &, const MaskType &) const { + return NULL; +} diff --git a/panda/src/graph/bitMaskTransition.h b/panda/src/graph/bitMaskTransition.h index 9f7b7e92e5..44b0fa151c 100644 --- a/panda/src/graph/bitMaskTransition.h +++ b/panda/src/graph/bitMaskTransition.h @@ -26,16 +26,16 @@ class NodeRelation; template class BitMaskTransition : public NodeTransition { protected: - INLINE BitMaskTransition(); - INLINE BitMaskTransition(const MaskType &and, const MaskType &or); - INLINE BitMaskTransition(const BitMaskTransition ©); - INLINE void operator = (const BitMaskTransition ©); + INLINE_GRAPH BitMaskTransition(); + INLINE_GRAPH BitMaskTransition(const MaskType &and, const MaskType &or); + INLINE_GRAPH BitMaskTransition(const BitMaskTransition ©); + INLINE_GRAPH void operator = (const BitMaskTransition ©); public: - INLINE void set_and(const MaskType &and); - INLINE const MaskType &get_and() const; - INLINE void set_or(const MaskType &or); - INLINE const MaskType &get_or() const; + INLINE_GRAPH void set_and(const MaskType &and); + INLINE_GRAPH const MaskType &get_and() const; + INLINE_GRAPH void set_or(const MaskType &or); + INLINE_GRAPH const MaskType &get_or() const; virtual NodeTransition *compose(const NodeTransition *other) const; virtual NodeTransition *invert() const; @@ -74,6 +74,6 @@ private: static TypeHandle _type_handle; }; -#include "bitMaskTransition.I" +#include "bitMaskTransition.T" #endif diff --git a/panda/src/graph/boundedObject.I b/panda/src/graph/boundedObject.I index bea70d8a63..07672752e4 100644 --- a/panda/src/graph/boundedObject.I +++ b/panda/src/graph/boundedObject.I @@ -10,7 +10,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE BoundedObject:: +INLINE_GRAPH BoundedObject:: BoundedObject() { _bound_type = BVT_dynamic_sphere; _bound_stale = true; @@ -23,7 +23,7 @@ BoundedObject() { // dynamically computed for this particular node. // Presently, this should only be BVT_dynamic_sphere. //////////////////////////////////////////////////////////////////// -INLINE void BoundedObject:: +INLINE_GRAPH void BoundedObject:: set_bound(BoundedObject::BoundingVolumeType type) { nassertv(type != BVT_static); mark_bound_stale(); @@ -37,7 +37,7 @@ set_bound(BoundedObject::BoundingVolumeType type) { // This will be a static bounding volume that will no // longer be recomputed automatically. //////////////////////////////////////////////////////////////////// -INLINE void BoundedObject:: +INLINE_GRAPH void BoundedObject:: set_bound(const BoundingVolume &bound) { mark_bound_stale(); _bound_type = BVT_static; @@ -55,7 +55,7 @@ set_bound(const BoundingVolume &bound) { // different from the bounding volumes on the arcs, // which enclose all geometry below them. //////////////////////////////////////////////////////////////////// -INLINE const BoundingVolume &BoundedObject:: +INLINE_GRAPH const BoundingVolume &BoundedObject:: get_bound() const { if (_bound_type == BVT_static) { ((BoundedObject *)this)->_bound_stale = false; @@ -75,7 +75,7 @@ get_bound() const { // setting was changed, or false if it was already // marked stale (or if it is a static bounding volume). //////////////////////////////////////////////////////////////////// -INLINE bool BoundedObject:: +INLINE_GRAPH bool BoundedObject:: mark_bound_stale() { if (_bound_stale) { return false; @@ -93,7 +93,7 @@ mark_bound_stale() { // effect at least one level, even if it had already // been marked stale. //////////////////////////////////////////////////////////////////// -INLINE void BoundedObject:: +INLINE_GRAPH void BoundedObject:: force_bound_stale() { _bound_stale = true; propagate_stale_bound(); @@ -106,7 +106,8 @@ force_bound_stale() { // and will be recomputed the next time get_bound() is // called. //////////////////////////////////////////////////////////////////// -INLINE bool BoundedObject:: +INLINE_GRAPH bool BoundedObject:: is_bound_stale() const { return _bound_stale; } + diff --git a/panda/src/graph/boundedObject.h b/panda/src/graph/boundedObject.h index 9479d248c8..309d868890 100644 --- a/panda/src/graph/boundedObject.h +++ b/panda/src/graph/boundedObject.h @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA BoundedObject { public: - INLINE BoundedObject(); + INLINE_GRAPH BoundedObject(); virtual ~BoundedObject(); PUBLISHED: @@ -32,13 +32,13 @@ PUBLISHED: BVT_dynamic_sphere, }; - INLINE void set_bound(BoundingVolumeType type); - INLINE void set_bound(const BoundingVolume &volume); - INLINE const BoundingVolume &get_bound() const; + INLINE_GRAPH void set_bound(BoundingVolumeType type); + INLINE_GRAPH void set_bound(const BoundingVolume &volume); + INLINE_GRAPH const BoundingVolume &get_bound() const; - INLINE bool mark_bound_stale(); - INLINE void force_bound_stale(); - INLINE bool is_bound_stale() const; + INLINE_GRAPH bool mark_bound_stale(); + INLINE_GRAPH void force_bound_stale(); + INLINE_GRAPH bool is_bound_stale() const; protected: virtual void propagate_stale_bound(); @@ -63,7 +63,9 @@ private: static TypeHandle _type_handle; }; +#ifdef BUILDING_PANDA #include "boundedObject.I" +#endif #endif diff --git a/panda/src/graph/dftraverser.I b/panda/src/graph/dftraverser.I index d90d573b36..1b866b7cad 100644 --- a/panda/src/graph/dftraverser.I +++ b/panda/src/graph/dftraverser.I @@ -13,7 +13,7 @@ // Description: //////////////////////////////////////////////////////////////////// template -INLINE DFTraverser:: +INLINE_GRAPH DFTraverser:: DFTraverser(Visitor &visitor, const AttributeWrapper &initial_render_state, TypeHandle graph_type) : @@ -29,7 +29,7 @@ DFTraverser(Visitor &visitor, // Description: Starts the traversal from the indicated arc. //////////////////////////////////////////////////////////////////// template -INLINE void DFTraverser:: +INLINE_GRAPH void DFTraverser:: start(NodeRelation *arc, const LevelState &initial_level_state) { traverse(arc, _initial_render_state, initial_level_state); } @@ -40,7 +40,7 @@ start(NodeRelation *arc, const LevelState &initial_level_state) { // Description: Starts the traversal from the indicated node. //////////////////////////////////////////////////////////////////// template -INLINE void DFTraverser:: +INLINE_GRAPH void DFTraverser:: start(Node *root, const LevelState &initial_level_state) { LevelState level_state(initial_level_state); traverse(root, _initial_render_state, level_state); diff --git a/panda/src/graph/dftraverser.T b/panda/src/graph/dftraverser.T new file mode 100644 index 0000000000..aa17eba5c9 --- /dev/null +++ b/panda/src/graph/dftraverser.T @@ -0,0 +1,124 @@ +// Filename: dftraverser.T +// Created by: drose (26Oct98) +// +//////////////////////////////////////////////////////////////////// + +#include "dftraverser.h" + +#include + +//////////////////////////////////////////////////////////////////// +// Function: DFTraverser::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH DFTraverser:: +DFTraverser(Visitor &visitor, + const AttributeWrapper &initial_render_state, + TypeHandle graph_type) : + _visitor(visitor), + _initial_render_state(initial_render_state), + _graph_type(graph_type) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: DFTraverser::start +// Access: Public +// Description: Starts the traversal from the indicated arc. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void DFTraverser:: +start(NodeRelation *arc, const LevelState &initial_level_state) { + traverse(arc, _initial_render_state, initial_level_state); +} + +//////////////////////////////////////////////////////////////////// +// Function: DFTraverser::start +// Access: Public +// Description: Starts the traversal from the indicated node. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void DFTraverser:: +start(Node *root, const LevelState &initial_level_state) { + LevelState level_state(initial_level_state); + traverse(root, _initial_render_state, level_state); +} + +//////////////////////////////////////////////////////////////////// +// Function: DFTraverser::Traverse +// Access: Public +// Description: Walks to the next arc of the graph. +//////////////////////////////////////////////////////////////////// +template +void DFTraverser:: +traverse(NodeRelation *arc, AttributeWrapper state, LevelState level_state) { + nassertv(arc->get_child() != (Node *)NULL); + + // Give the visitor a chance to veto this arc. + TransitionWrapper trans = + TransitionWrapper::init_from(_initial_render_state); + trans.extract_from(arc); + + AttributeWrapper post_state(state); + post_state.apply_in_place(trans); + if (_visitor.forward_arc(arc, trans, state, post_state, level_state)) { + traverse(arc->get_child(), post_state, level_state); + _visitor.backward_arc(arc, trans, state, post_state, level_state); + } +} + + + +//////////////////////////////////////////////////////////////////// +// Function: DFTraverser::Traverse +// Access: Public +// Description: Walks to the next node of the graph. +//////////////////////////////////////////////////////////////////// +template +void DFTraverser:: +traverse(Node *node, AttributeWrapper &state, LevelState &level_state) { + // Tell the visitor we reached the node, and give it a chance to + // veto our further progress. + if (_visitor.reached_node(node, state, level_state)) { + + // Look for further children of the given NodeRelation. + DownRelations::const_iterator dri; + dri = node->_children.find(_graph_type); + if (dri != node->_children.end()) { + // Here are some! + const DownRelationPointers &drp = (*dri).second; + + // Now visit each of the children in turn. + DownRelationPointers::const_iterator drpi; + for (drpi = drp.begin(); drpi != drp.end(); ++drpi) { + traverse(*drpi, state, level_state); + } + } + } +} + +// Convenience functions. +template +INLINE void +df_traverse(NodeRelation *arc, Visitor &visitor, + const AttributeWrapper &initial_render_state, + const LevelState &initial_level_state, + TypeHandle graph_type) { + DFTraverser + dft(visitor, initial_render_state, graph_type); + dft.start(arc, initial_level_state); +} + +template +INLINE void +df_traverse(Node *root, Visitor &visitor, + const AttributeWrapper &initial_render_state, + const LevelState &initial_level_state, + TypeHandle graph_type) { + DFTraverser + dft(visitor, initial_render_state, graph_type); + dft.start(root, initial_level_state); +} + diff --git a/panda/src/graph/dftraverser.h b/panda/src/graph/dftraverser.h index df55c3a8a0..44ec50d816 100644 --- a/panda/src/graph/dftraverser.h +++ b/panda/src/graph/dftraverser.h @@ -26,12 +26,12 @@ public: typedef TYPENAME Visitor::TransitionWrapper TransitionWrapper; typedef TYPENAME Visitor::AttributeWrapper AttributeWrapper; - INLINE DFTraverser(Visitor &visitor, + INLINE_GRAPH DFTraverser(Visitor &visitor, const AttributeWrapper &initial_render_state, TypeHandle graph_type); - INLINE void start(NodeRelation *arc, const LevelState &initial_level_state); - INLINE void start(Node *root, const LevelState &initial_level_state); + INLINE_GRAPH void start(NodeRelation *arc, const LevelState &initial_level_state); + INLINE_GRAPH void start(Node *root, const LevelState &initial_level_state); protected: void traverse(NodeRelation *arc, @@ -46,29 +46,6 @@ protected: TypeHandle _graph_type; }; -// Convenience functions. -template -INLINE void -df_traverse(NodeRelation *arc, Visitor &visitor, - const AttributeWrapper &initial_render_state, - const LevelState &initial_level_state, - TypeHandle graph_type) { - DFTraverser - dft(visitor, initial_render_state, graph_type); - dft.start(arc, initial_level_state); -} - -template -INLINE void -df_traverse(Node *root, Visitor &visitor, - const AttributeWrapper &initial_render_state, - const LevelState &initial_level_state, - TypeHandle graph_type) { - DFTraverser - dft(visitor, initial_render_state, graph_type); - dft.start(root, initial_level_state); -} - -#include "dftraverser.I" +#include "dftraverser.T" #endif diff --git a/panda/src/graph/immediateAttribute.I b/panda/src/graph/immediateAttribute.I index 5d760c405c..f996a06d98 100644 --- a/panda/src/graph/immediateAttribute.I +++ b/panda/src/graph/immediateAttribute.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ImmediateAttribute:: +INLINE_GRAPH ImmediateAttribute:: ImmediateAttribute() { } @@ -17,7 +17,7 @@ ImmediateAttribute() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ImmediateAttribute:: +INLINE_GRAPH ImmediateAttribute:: ImmediateAttribute(const ImmediateAttribute ©) : NodeAttribute(copy) { @@ -28,7 +28,7 @@ ImmediateAttribute(const ImmediateAttribute ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void ImmediateAttribute:: +INLINE_GRAPH void ImmediateAttribute:: operator = (const ImmediateAttribute ©) { NodeAttribute::operator = (copy); } diff --git a/panda/src/graph/immediateAttribute.h b/panda/src/graph/immediateAttribute.h index f6af4ec77b..d88ff86b60 100644 --- a/panda/src/graph/immediateAttribute.h +++ b/panda/src/graph/immediateAttribute.h @@ -18,10 +18,12 @@ class ImmediateTransition; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA ImmediateAttribute : public NodeAttribute { public: - INLINE ImmediateAttribute(); - INLINE ImmediateAttribute(const ImmediateAttribute ©); - INLINE void operator = (const ImmediateAttribute ©); + INLINE_GRAPH ImmediateAttribute() {}; + INLINE_GRAPH ImmediateAttribute(const ImmediateAttribute ©) : + NodeAttribute(copy){}; + INLINE_GRAPH void operator = (const ImmediateAttribute ©) + {NodeAttribute::operator = (copy);} public: virtual NodeAttribute *make_copy() const; virtual NodeAttribute *make_initial() const; @@ -48,6 +50,4 @@ private: static TypeHandle _type_handle; }; -#include "immediateAttribute.I" - #endif diff --git a/panda/src/graph/immediateTransition.I b/panda/src/graph/immediateTransition.I index 11c110e3b1..144daf2267 100644 --- a/panda/src/graph/immediateTransition.I +++ b/panda/src/graph/immediateTransition.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ImmediateTransition:: +INLINE_GRAPH ImmediateTransition:: ImmediateTransition() { } @@ -17,7 +17,7 @@ ImmediateTransition() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE ImmediateTransition:: +INLINE_GRAPH ImmediateTransition:: ImmediateTransition(const ImmediateTransition ©) : NodeTransition(copy) { @@ -28,7 +28,7 @@ ImmediateTransition(const ImmediateTransition ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void ImmediateTransition:: +INLINE_GRAPH void ImmediateTransition:: operator = (const ImmediateTransition ©) { NodeTransition::operator = (copy); } diff --git a/panda/src/graph/immediateTransition.h b/panda/src/graph/immediateTransition.h index 2c22676d16..80a830e46c 100644 --- a/panda/src/graph/immediateTransition.h +++ b/panda/src/graph/immediateTransition.h @@ -36,9 +36,9 @@ class NodeRelation; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA ImmediateTransition : public NodeTransition { protected: - INLINE ImmediateTransition(); - INLINE ImmediateTransition(const ImmediateTransition ©); - INLINE void operator = (const ImmediateTransition ©); + INLINE_GRAPH ImmediateTransition(); + INLINE_GRAPH ImmediateTransition(const ImmediateTransition ©); + INLINE_GRAPH void operator = (const ImmediateTransition ©); public: virtual NodeAttribute *make_attrib() const; @@ -75,7 +75,9 @@ private: static TypeHandle _type_handle; }; +#ifdef BUILDING_PANDA #include "immediateTransition.I" +#endif #endif diff --git a/panda/src/graph/matrixAttribute.I b/panda/src/graph/matrixAttribute.I index 4e6ef12a8b..820f2804de 100644 --- a/panda/src/graph/matrixAttribute.I +++ b/panda/src/graph/matrixAttribute.I @@ -14,7 +14,7 @@ TypeHandle MatrixAttribute::_type_handle; // Description: //////////////////////////////////////////////////////////////////// template -INLINE MatrixAttribute:: +INLINE_GRAPH MatrixAttribute:: MatrixAttribute() { _matrix = Matrix::ident_mat(); } @@ -25,7 +25,7 @@ MatrixAttribute() { // Description: //////////////////////////////////////////////////////////////////// template -INLINE MatrixAttribute:: +INLINE_GRAPH MatrixAttribute:: MatrixAttribute(const MatrixAttribute ©) : NodeAttribute(copy), _matrix(copy._matrix) @@ -38,7 +38,7 @@ MatrixAttribute(const MatrixAttribute ©) : // Description: //////////////////////////////////////////////////////////////////// template -INLINE void MatrixAttribute:: +INLINE_GRAPH void MatrixAttribute:: operator = (const MatrixAttribute ©) { NodeAttribute::operator = (copy); _matrix = copy._matrix; @@ -50,7 +50,7 @@ operator = (const MatrixAttribute ©) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE void MatrixAttribute:: +INLINE_GRAPH void MatrixAttribute:: set_matrix(const Matrix &mat) { _matrix = mat; } @@ -61,7 +61,7 @@ set_matrix(const Matrix &mat) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE const Matrix &MatrixAttribute:: +INLINE_GRAPH const Matrix &MatrixAttribute:: get_matrix() const { return _matrix; } diff --git a/panda/src/graph/matrixAttribute.T b/panda/src/graph/matrixAttribute.T new file mode 100644 index 0000000000..820f2804de --- /dev/null +++ b/panda/src/graph/matrixAttribute.T @@ -0,0 +1,103 @@ +// Filename: matrixAttribute.I +// Created by: drose (24Mar00) +// +//////////////////////////////////////////////////////////////////// + +#include + +template +TypeHandle MatrixAttribute::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MatrixAttribute:: +MatrixAttribute() { + _matrix = Matrix::ident_mat(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MatrixAttribute:: +MatrixAttribute(const MatrixAttribute ©) : + NodeAttribute(copy), + _matrix(copy._matrix) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MatrixAttribute:: +operator = (const MatrixAttribute ©) { + NodeAttribute::operator = (copy); + _matrix = copy._matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::set_matrix +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MatrixAttribute:: +set_matrix(const Matrix &mat) { + _matrix = mat; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::get_matrix +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH const Matrix &MatrixAttribute:: +get_matrix() const { + return _matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MatrixAttribute:: +output(ostream &out) const { + out << _matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MatrixAttribute:: +write(ostream &out, int indent_level) const { + _matrix.write(out, indent_level); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixAttribute::internal_compare_to +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +int MatrixAttribute:: +internal_compare_to(const NodeAttribute *other) const { + const MatrixAttribute *ot; + DCAST_INTO_R(ot, other, false); + + return _matrix.compare_to(ot->_matrix); +} diff --git a/panda/src/graph/matrixAttribute.h b/panda/src/graph/matrixAttribute.h index 177308c6cc..0761bd0386 100644 --- a/panda/src/graph/matrixAttribute.h +++ b/panda/src/graph/matrixAttribute.h @@ -20,13 +20,13 @@ class MatrixTransition; template class MatrixAttribute : public NodeAttribute { protected: - INLINE MatrixAttribute(); - INLINE MatrixAttribute(const MatrixAttribute ©); - INLINE void operator = (const MatrixAttribute ©); + INLINE_GRAPH MatrixAttribute(); + INLINE_GRAPH MatrixAttribute(const MatrixAttribute ©); + INLINE_GRAPH void operator = (const MatrixAttribute ©); public: - INLINE void set_matrix(const Matrix &mat); - INLINE const Matrix &get_matrix() const; + INLINE_GRAPH void set_matrix(const Matrix &mat); + INLINE_GRAPH const Matrix &get_matrix() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; @@ -56,9 +56,9 @@ public: private: static TypeHandle _type_handle; -friend class MatrixTransition; + friend class MatrixTransition; }; -#include "matrixAttribute.I" +#include "matrixAttribute.T" #endif diff --git a/panda/src/graph/matrixTransition.I b/panda/src/graph/matrixTransition.I index 542f23ddb9..dcb9daa0e9 100644 --- a/panda/src/graph/matrixTransition.I +++ b/panda/src/graph/matrixTransition.I @@ -16,7 +16,7 @@ TypeHandle MatrixTransition::_type_handle; // Description: //////////////////////////////////////////////////////////////////// template -INLINE MatrixTransition:: +INLINE_GRAPH MatrixTransition:: MatrixTransition() { _matrix = Matrix::ident_mat(); } @@ -27,7 +27,7 @@ MatrixTransition() { // Description: //////////////////////////////////////////////////////////////////// template -INLINE MatrixTransition:: +INLINE_GRAPH MatrixTransition:: MatrixTransition(const Matrix &matrix) { _matrix = matrix; } @@ -38,7 +38,7 @@ MatrixTransition(const Matrix &matrix) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE MatrixTransition:: +INLINE_GRAPH MatrixTransition:: MatrixTransition(const MatrixTransition ©) : NodeTransition(copy), _matrix(copy._matrix) @@ -51,7 +51,7 @@ MatrixTransition(const MatrixTransition ©) : // Description: //////////////////////////////////////////////////////////////////// template -INLINE void MatrixTransition:: +INLINE_GRAPH void MatrixTransition:: operator = (const MatrixTransition ©) { NodeTransition::operator = (copy); _matrix = copy._matrix; @@ -63,7 +63,7 @@ operator = (const MatrixTransition ©) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE void MatrixTransition:: +INLINE_GRAPH void MatrixTransition:: set_matrix(const Matrix &mat) { _matrix = mat; state_changed(); @@ -75,7 +75,7 @@ set_matrix(const Matrix &mat) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE const Matrix &MatrixTransition:: +INLINE_GRAPH const Matrix &MatrixTransition:: get_matrix() const { return _matrix; } diff --git a/panda/src/graph/matrixTransition.T b/panda/src/graph/matrixTransition.T new file mode 100644 index 0000000000..dcb9daa0e9 --- /dev/null +++ b/panda/src/graph/matrixTransition.T @@ -0,0 +1,240 @@ +// Filename: matrixTransition.I +// Created by: drose (24Mar00) +// +//////////////////////////////////////////////////////////////////// + +#include "matrixAttribute.h" + +#include + +template +TypeHandle MatrixTransition::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MatrixTransition:: +MatrixTransition() { + _matrix = Matrix::ident_mat(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MatrixTransition:: +MatrixTransition(const Matrix &matrix) { + _matrix = matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MatrixTransition:: +MatrixTransition(const MatrixTransition ©) : + NodeTransition(copy), + _matrix(copy._matrix) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MatrixTransition:: +operator = (const MatrixTransition ©) { + NodeTransition::operator = (copy); + _matrix = copy._matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::set_matrix +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MatrixTransition:: +set_matrix(const Matrix &mat) { + _matrix = mat; + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::get_matrix +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH const Matrix &MatrixTransition:: +get_matrix() const { + return _matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::compose +// Access: Public, Virtual +// Description: Returns a new transition that corresponds to the +// composition of this transition with the second +// transition (which must be of an equivalent type). +// This may return the same pointer as either source +// transition. Applying the transition returned from +// this function to an attribute attribute will produce +// the same effect as applying each transition +// separately. +//////////////////////////////////////////////////////////////////// +template +NodeTransition *MatrixTransition:: +compose(const NodeTransition *other) const { + const MatrixTransition *ot; + DCAST_INTO_R(ot, other, NULL); + + return make_with_matrix(ot->_matrix * _matrix); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::invert +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +NodeTransition *MatrixTransition:: +invert() const { + if (_matrix.almost_equal(Matrix::ident_mat())) { + return (MatrixTransition *)this; + } + Matrix inverted; + inverted.invert_from(_matrix); + return make_with_matrix(inverted); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::apply +// Access: Public, Virtual +// Description: Returns a new attribute (or possibly the same +// attribute) that represents the effect of applying this +// indicated transition to the indicated attribute. The +// source attribute may be NULL, indicating the initial +// attribute. +//////////////////////////////////////////////////////////////////// +template +NodeAttribute *MatrixTransition:: +apply(const NodeAttribute *attrib) const { + + MatrixAttribute *result; + DCAST_INTO_R(result, make_attrib(), NULL); + + if (attrib == (const NodeAttribute *)NULL) { + result->_matrix = _matrix; + return result; + } + + const MatrixAttribute *at; + DCAST_INTO_R(at, attrib, NULL); + + result->_matrix = _matrix * at->_matrix; + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MatrixTransition:: +output(ostream &out) const { + out << _matrix; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MatrixTransition:: +write(ostream &out, int indent_level) const { + _matrix.write(out, indent_level); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::internal_compare_to +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +int MatrixTransition:: +internal_compare_to(const NodeTransition *other) const { + const MatrixTransition *ot; + DCAST_INTO_R(ot, other, false); + + // Should we bother comparing matrices componentwise, or should we + // just assume that any two different Matrix pointers are probably + // different matrices? + + // For now, we compare componentwise. It makes paranoid_wrt more + // sensible, and it doesn't seem to make a big different to + // performance. + return _matrix.compare_to(ot->_matrix, 0.00001); + + // Uncomment this line instead to compare matrices pointerwise. + // return this - other; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::make_with_matrix +// Access: Protected, Virtual +// Description: This function creates a new MatrixTransition of the +// appropriate type, given the indicated matrix. +// +// This is a pure virtual function and normally wouldn't +// require a definition, but for some reason VC++ +// objects to instantiating the template if it's missing +// any function definitions--even those for pure-virtual +// functions. +//////////////////////////////////////////////////////////////////// +template +MatrixTransition *MatrixTransition:: +make_with_matrix(const Matrix &) const { + return NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::write_datagram +// Access: Public +// Description: Function to write the important information in +// the particular object to a Datagram +//////////////////////////////////////////////////////////////////// +template +void MatrixTransition:: +write_datagram(BamWriter *manager, Datagram &me) +{ + NodeTransition::write_datagram(manager, me); + _matrix.write_datagram(me); +} + +//////////////////////////////////////////////////////////////////// +// Function: MatrixTransition::fillin +// Access: Protected +// Description: Function that reads out of the datagram (or asks +// manager to read) all of the data that is needed to +// re-create this object and stores it in the appropiate +// place +//////////////////////////////////////////////////////////////////// +template +void MatrixTransition:: +fillin(DatagramIterator& scan, BamReader* manager) +{ + NodeTransition::fillin(scan, manager); + _matrix.read_datagram(scan); +} diff --git a/panda/src/graph/matrixTransition.h b/panda/src/graph/matrixTransition.h index e808d94d41..9d2ce898cf 100644 --- a/panda/src/graph/matrixTransition.h +++ b/panda/src/graph/matrixTransition.h @@ -27,14 +27,14 @@ class NodeRelation; template class MatrixTransition : public NodeTransition { protected: - INLINE MatrixTransition(); - INLINE MatrixTransition(const Matrix &matrix); - INLINE MatrixTransition(const MatrixTransition ©); - INLINE void operator = (const MatrixTransition ©); + INLINE_GRAPH MatrixTransition(); + INLINE_GRAPH MatrixTransition(const Matrix &matrix); + INLINE_GRAPH MatrixTransition(const MatrixTransition ©); + INLINE_GRAPH void operator = (const MatrixTransition ©); public: - INLINE void set_matrix(const Matrix &mat); - INLINE const Matrix &get_matrix() const; + INLINE_GRAPH void set_matrix(const Matrix &mat); + INLINE_GRAPH const Matrix &get_matrix() const; virtual NodeTransition *compose(const NodeTransition *other) const; virtual NodeTransition *invert() const; @@ -82,6 +82,6 @@ private: static TypeHandle _type_handle; }; -#include "matrixTransition.I" +#include "matrixTransition.T" #endif diff --git a/panda/src/graph/multiAttribute.I b/panda/src/graph/multiAttribute.I index 6b168689d4..1a998c5a14 100644 --- a/panda/src/graph/multiAttribute.I +++ b/panda/src/graph/multiAttribute.I @@ -118,7 +118,7 @@ is_off(const Property &property) const { // set indicates that the given property is off. //////////////////////////////////////////////////////////////////// template -INLINE bool MultiAttribute:: +INLINE_GRAPH bool MultiAttribute:: get_properties_is_on() const { return _properties_is_on; } @@ -204,7 +204,7 @@ write_property(ostream &, const Property &, int) const { // to the sorted vector, if it is not already there. //////////////////////////////////////////////////////////////////// template -INLINE void MultiAttribute:: +INLINE_GRAPH void MultiAttribute:: set_property(const Property &prop) { bool found_flag = false; Properties::iterator pi = find_property(prop, found_flag); @@ -221,7 +221,7 @@ set_property(const Property &prop) { // false if not. //////////////////////////////////////////////////////////////////// template -INLINE bool MultiAttribute:: +INLINE_GRAPH bool MultiAttribute:: has_property(const Property &prop) const { bool found_flag = false; ((MultiAttribute *)this)->find_property(prop, found_flag); @@ -235,7 +235,7 @@ has_property(const Property &prop) const { // property from the sorted vector. //////////////////////////////////////////////////////////////////// template -INLINE void MultiAttribute:: +INLINE_GRAPH void MultiAttribute:: clear_property(const Property &prop) { bool found_flag = false; Properties::iterator pi = find_property(prop, found_flag); @@ -255,7 +255,7 @@ clear_property(const Property &prop) { // returned. //////////////////////////////////////////////////////////////////// template -INLINE MultiAttribute::Properties::iterator MultiAttribute:: +INLINE_GRAPH MultiAttribute::Properties::iterator MultiAttribute:: find_property(const Property &prop, bool &found_flag) { return binary_search_property(_properties.begin(), _properties.end(), prop, found_flag); @@ -297,7 +297,7 @@ binary_search_property(Properties::iterator begin, Properties::iterator end, // Description: //////////////////////////////////////////////////////////////////// template -INLINE MultiAttribute::size_type MultiAttribute:: +INLINE_GRAPH MultiAttribute::size_type MultiAttribute:: size() const { return _properties.size(); } @@ -309,7 +309,7 @@ size() const { // properties in the attribute. //////////////////////////////////////////////////////////////////// template -INLINE MultiAttribute::const_iterator MultiAttribute:: +INLINE_GRAPH MultiAttribute::const_iterator MultiAttribute:: begin() const { return _properties.begin(); } @@ -321,7 +321,7 @@ begin() const { // sequence of properties in the attribute. //////////////////////////////////////////////////////////////////// template -INLINE MultiAttribute::const_iterator MultiAttribute:: +INLINE_GRAPH MultiAttribute::const_iterator MultiAttribute:: end() const { return _properties.end(); } diff --git a/panda/src/graph/multiAttribute.T b/panda/src/graph/multiAttribute.T new file mode 100644 index 0000000000..af65d42ca0 --- /dev/null +++ b/panda/src/graph/multiAttribute.T @@ -0,0 +1,324 @@ +// Filename: multiAttribute.T +// Created by: drose (23Mar00) +// +//////////////////////////////////////////////////////////////////// + +template +TypeHandle MultiAttribute::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +MultiAttribute:: +MultiAttribute() { + _properties_is_on = true; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +MultiAttribute:: +MultiAttribute(const MultiAttribute ©) : + NodeAttribute(copy), + _properties(copy._properties), + _properties_is_on(copy._properties_is_on) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +operator = (const MultiAttribute ©) { + NodeAttribute::operator = (copy); + _properties = copy._properties; + _properties_is_on = copy._properties_is_on; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::set_on +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +set_on(const Property &property) { + if (_properties_is_on) { + set_property(property); + } else { + clear_property(property); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::set_off +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +set_off(const Property &property) { + if (_properties_is_on) { + clear_property(property); + } else { + set_property(property); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::is_on +// Access: Public +// Description: Returns true if the particular properties member is +// on, false if it is not. +//////////////////////////////////////////////////////////////////// +template +bool MultiAttribute:: +is_on(const Property &property) const { + if (_properties_is_on) { + return has_property(property); + } else { + return !has_property(property); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::is_off +// Access: Public +// Description: Returns true if the particular properties member is +// off, false if it is not. +//////////////////////////////////////////////////////////////////// +template +bool MultiAttribute:: +is_off(const Property &property) const { + if (_properties_is_on) { + return !has_property(property); + } else { + return has_property(property); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::properties_is_on +// Access: Public +// Description: Returns true if inclusion in the set traversible via +// begin()/end() indicates that the given property is +// on, the default. Returns false if inclusion in the +// set indicates that the given property is off. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool MultiAttribute:: +get_properties_is_on() const { + return _properties_is_on; +} + + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +output(ostream &out) const { + if (!_properties.empty()) { + Properties::const_iterator pi = _properties.begin(); + output_property(out, *pi); + ++pi; + while (pi != _properties.end()) { + out << " "; + output_property(out, *pi); + ++pi; + } + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +write(ostream &out, int indent_level) const { + Properties::const_iterator pi; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + write_property(out, *pi, indent_level); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::internal_compare_to +// Access: Protected, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +int MultiAttribute:: +internal_compare_to(const NodeAttribute *other) const { + const MultiAttribute *ot; + DCAST_INTO_R(ot, other, false); + + return bmap_compare(_properties.begin(), _properties.end(), + ot->_properties.begin(), ot->_properties.end()); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::output_property +// Access: Public, Virtual +// Description: This is a pure virtual function and normally would +// not need a body, except that VC++ doesn't seem happy +// about instantiating the template otherwise. +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +output_property(ostream &, const Property &) const { +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::write_property +// Access: Public, Virtual +// Description: This is a pure virtual function and normally would +// not need a body, except that VC++ doesn't seem happy +// about instantiating the template otherwise. +//////////////////////////////////////////////////////////////////// +template +void MultiAttribute:: +write_property(ostream &, const Property &, int) const { +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::set_property +// Access: Private +// Description: An internal function that adds the indicated property +// to the sorted vector, if it is not already there. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MultiAttribute:: +set_property(const Property &prop) { + bool found_flag = false; + Properties::iterator pi = find_property(prop, found_flag); + if (!found_flag) { + _properties.insert(pi, prop); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::set_property +// Access: Private +// Description: An internal function that returns true if the +// indicated property is a member of the sorted vector, +// false if not. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool MultiAttribute:: +has_property(const Property &prop) const { + bool found_flag = false; + ((MultiAttribute *)this)->find_property(prop, found_flag); + return found_flag; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::clear_property +// Access: Private +// Description: An internal function that removes the indicated +// property from the sorted vector. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MultiAttribute:: +clear_property(const Property &prop) { + bool found_flag = false; + Properties::iterator pi = find_property(prop, found_flag); + if (found_flag) { + _properties.erase(pi); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::find_property +// Access: Private +// Description: An internal function that searches for the indicated +// property within the sorted vector. If the property +// is found, found_flag is set true, and its iterator is +// returned; otherwise, found_flag is unchanged, and the +// iterator at which the property should be inserted is +// returned. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiAttribute::Properties::iterator MultiAttribute:: +find_property(const Property &prop, bool &found_flag) { + return binary_search_property(_properties.begin(), _properties.end(), + prop, found_flag); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::binary_search_property +// Access: Private +// Description: An internal function that implements a binary search +// for a particular property on the sorted vector. If +// the property is found, found_flag is set true, and +// its iterator is returned; otherwise, found_flag is +// unchanged, and the iterator at which the property +// should be inserted is returned. +//////////////////////////////////////////////////////////////////// +template +MultiAttribute::Properties::iterator MultiAttribute:: +binary_search_property(Properties::iterator begin, Properties::iterator end, + const Property &prop, bool &found_flag) { + if (begin == end) { + return begin; + } + Properties::iterator mid = begin + (end - begin) / 2; + if (prop < *mid) { + return binary_search_property(begin, mid, prop, found_flag); + + } else if (*mid < prop) { + return binary_search_property(mid + 1, end, prop, found_flag); + + } else { // *mid == prop + found_flag = true; + return mid; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::size +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiAttribute::size_type MultiAttribute:: +size() const { + return _properties.size(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::begin +// Access: Public +// Description: Returns an iterator that begins the sequence of +// properties in the attribute. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiAttribute::const_iterator MultiAttribute:: +begin() const { + return _properties.begin(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiAttribute::end +// Access: Public +// Description: Returns an iterator that marks the end of the +// sequence of properties in the attribute. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiAttribute::const_iterator MultiAttribute:: +end() const { + return _properties.end(); +} diff --git a/panda/src/graph/multiAttribute.h b/panda/src/graph/multiAttribute.h index 2a99989f93..0837154fcb 100644 --- a/panda/src/graph/multiAttribute.h +++ b/panda/src/graph/multiAttribute.h @@ -38,7 +38,7 @@ PUBLISHED: bool is_on(const Property &prop) const; bool is_off(const Property &prop) const; - INLINE bool get_properties_is_on() const; + INLINE_GRAPH bool get_properties_is_on() const; public: virtual void output(ostream &out) const; @@ -52,11 +52,11 @@ protected: int indent_level) const=0; private: - INLINE void set_property(const Property &prop); - INLINE bool has_property(const Property &prop) const; - INLINE void clear_property(const Property &prop); + INLINE_GRAPH void set_property(const Property &prop); + INLINE_GRAPH bool has_property(const Property &prop) const; + INLINE_GRAPH void clear_property(const Property &prop); - INLINE Properties::iterator + INLINE_GRAPH Properties::iterator find_property(const Property &prop, bool &found_flag); Properties::iterator @@ -73,9 +73,9 @@ public: typedef Properties::value_type value_type; typedef Properties::size_type size_type; - INLINE size_type size() const; - INLINE const_iterator begin() const; - INLINE const_iterator end() const; + INLINE_GRAPH size_type size() const; + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; private: // The following is a set of properties listed in the attribute. If @@ -102,9 +102,9 @@ public: private: static TypeHandle _type_handle; -friend class MultiTransition; + friend class MultiTransition; }; -#include "multiAttribute.I" +#include "multiAttribute.T" #endif diff --git a/panda/src/graph/multiNodeAttribute.I b/panda/src/graph/multiNodeAttribute.I index b8620eeb77..537c3fa864 100644 --- a/panda/src/graph/multiNodeAttribute.I +++ b/panda/src/graph/multiNodeAttribute.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE MultiNodeAttribute:: +INLINE_GRAPH MultiNodeAttribute:: MultiNodeAttribute() { } @@ -17,7 +17,7 @@ MultiNodeAttribute() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE MultiNodeAttribute:: +INLINE_GRAPH MultiNodeAttribute:: MultiNodeAttribute(const MultiNodeAttribute ©) : MultiAttribute(copy) { @@ -28,7 +28,7 @@ MultiNodeAttribute(const MultiNodeAttribute ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void MultiNodeAttribute:: +INLINE_GRAPH void MultiNodeAttribute:: operator = (const MultiNodeAttribute ©) { MultiAttribute::operator = (copy); } diff --git a/panda/src/graph/multiNodeAttribute.h b/panda/src/graph/multiNodeAttribute.h index d17775a0fe..43aaa50b18 100644 --- a/panda/src/graph/multiNodeAttribute.h +++ b/panda/src/graph/multiNodeAttribute.h @@ -30,9 +30,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, MULTIATTRIBUTE_NODE); class EXPCL_PANDA MultiNodeAttribute : public MultiAttribute { protected: - INLINE MultiNodeAttribute(); - INLINE MultiNodeAttribute(const MultiNodeAttribute ©); - INLINE void operator = (const MultiNodeAttribute ©); + INLINE_GRAPH MultiNodeAttribute() {}; + INLINE_GRAPH MultiNodeAttribute(const MultiNodeAttribute ©) : + MultiAttribute(copy) {}; + + INLINE_GRAPH void operator = (const MultiNodeAttribute ©) + {MultiAttribute::operator = (copy);} public: virtual TypeHandle get_type() const { @@ -53,6 +56,4 @@ private: static TypeHandle _type_handle; }; -#include "multiNodeAttribute.I" - #endif diff --git a/panda/src/graph/multiNodeTransition.I b/panda/src/graph/multiNodeTransition.I index 543c749bd3..5c8c82a021 100644 --- a/panda/src/graph/multiNodeTransition.I +++ b/panda/src/graph/multiNodeTransition.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE MultiNodeTransition:: +INLINE_GRAPH MultiNodeTransition:: MultiNodeTransition() { } @@ -17,7 +17,7 @@ MultiNodeTransition() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE MultiNodeTransition:: +INLINE_GRAPH MultiNodeTransition:: MultiNodeTransition(const MultiNodeTransition ©) : MultiTransition(copy) { @@ -28,7 +28,7 @@ MultiNodeTransition(const MultiNodeTransition ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void MultiNodeTransition:: +INLINE_GRAPH void MultiNodeTransition:: operator = (const MultiNodeTransition ©) { MultiTransition::operator = (copy); } diff --git a/panda/src/graph/multiNodeTransition.h b/panda/src/graph/multiNodeTransition.h index 11c7c5be1a..4209253bc7 100644 --- a/panda/src/graph/multiNodeTransition.h +++ b/panda/src/graph/multiNodeTransition.h @@ -36,11 +36,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, MULTITRANSITION_NODE); class EXPCL_PANDA MultiNodeTransition : public MultiTransition { protected: - INLINE MultiNodeTransition(); - INLINE MultiNodeTransition(const MultiNodeTransition ©); - INLINE void operator = (const MultiNodeTransition ©); + INLINE_GRAPH MultiNodeTransition() {}; + INLINE_GRAPH MultiNodeTransition(const MultiNodeTransition ©) : + MultiTransition(copy) {}; -public: + INLINE_GRAPH void operator = (const MultiNodeTransition ©) + {MultiTransition::operator = (copy);}; public: virtual TypeHandle get_type() const { @@ -61,6 +62,4 @@ private: static TypeHandle _type_handle; }; -#include "multiNodeTransition.I" - #endif diff --git a/panda/src/graph/multiTransition.I b/panda/src/graph/multiTransition.I index acc8dd0ca2..623139bdab 100644 --- a/panda/src/graph/multiTransition.I +++ b/panda/src/graph/multiTransition.I @@ -101,7 +101,7 @@ is_identity() const { // are left unchanged. //////////////////////////////////////////////////////////////////// template -INLINE void MultiTransition:: +INLINE_GRAPH void MultiTransition:: set_default_dir(TransitionDirection dir) { _default_dir = dir; } @@ -112,7 +112,7 @@ set_default_dir(TransitionDirection dir) { // Description: //////////////////////////////////////////////////////////////////// template -INLINE TransitionDirection MultiTransition:: +INLINE_GRAPH TransitionDirection MultiTransition:: get_default_dir() const { return _default_dir; } @@ -529,7 +529,7 @@ write_property(ostream &, const Property &, int) const { // Description: //////////////////////////////////////////////////////////////////// template -INLINE MultiTransition::size_type MultiTransition:: +INLINE_GRAPH MultiTransition::size_type MultiTransition:: size() const { return _properties.size(); } @@ -541,7 +541,7 @@ size() const { // properties in the transition. //////////////////////////////////////////////////////////////////// template -INLINE MultiTransition::const_iterator MultiTransition:: +INLINE_GRAPH MultiTransition::const_iterator MultiTransition:: begin() const { return _properties.begin(); } @@ -553,7 +553,7 @@ begin() const { // sequence of properties in the transition. //////////////////////////////////////////////////////////////////// template -INLINE MultiTransition::const_iterator MultiTransition:: +INLINE_GRAPH MultiTransition::const_iterator MultiTransition:: end() const { return _properties.end(); } diff --git a/panda/src/graph/multiTransition.T b/panda/src/graph/multiTransition.T new file mode 100644 index 0000000000..61f439a3ff --- /dev/null +++ b/panda/src/graph/multiTransition.T @@ -0,0 +1,559 @@ +// Filename: multiTransition.I +// Created by: drose (23Mar00) +// +//////////////////////////////////////////////////////////////////// + +/* okcircular */ +#include "multiAttribute.h" + +template +TypeHandle MultiTransition::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +MultiTransition:: +MultiTransition() { + _default_dir = TD_identity; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +MultiTransition:: +MultiTransition(const MultiTransition ©) : + NodeTransition(copy), + _properties(copy._properties), + _default_dir(copy._default_dir) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +operator = (const MultiTransition ©) { + NodeTransition::operator = (copy); + _properties = copy._properties; + _default_dir = copy._default_dir; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::clear +// Access: Public +// Description: Removes all properties from the set, and resets it to +// its initial state. +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +clear() { + _properties.clear(); + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::is_identity +// Access: Public +// Description: Returns true if this transition does not have any +// effect. +//////////////////////////////////////////////////////////////////// +template +bool MultiTransition:: +is_identity() const { + if (_default_dir != TD_identity) { + return false; + } + + Properties::const_iterator pi; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second != TD_identity) { + return false; + } + } + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::set_default_dir +// Access: Public +// Description: Sets the default direction on the MultiTransition. +// This controls whether the MultiTransition applies +// itself by completely replacing everything that went +// before, or by adding to whatever has gone before. +// +// When this is set to either TD_on or TD_off, all +// properties which are not explicitly mentioned are +// assumed to be 'on' or 'off' transitions, +// respectively; when it is set to TD_identity, the +// default, all properties which are not explicitly +// mentions are assumed to be identity transitions and +// are left unchanged. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void MultiTransition:: +set_default_dir(TransitionDirection dir) { + _default_dir = dir; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::get_default_dir +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH TransitionDirection MultiTransition:: +get_default_dir() const { + return _default_dir; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::set_identity +// Access: Public +// Description: Changes the indicated property to an identity +// transition: this property will not be changed by the +// application of the MultiTransition. +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +set_identity(const Property &property) { + _properties[property] = TD_identity; + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::set_on +// Access: Public +// Description: Changes the indicated property to an 'on' transition: +// this property will be explicitly turned on by the +// application of the MultiTransition. +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +set_on(const Property &property) { + _properties[property] = TD_on; + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::set_off +// Access: Public +// Description: Changes the indicated property to an 'off' transition: +// this property will be explicitly turned off by the +// application of the MultiTransition. +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +set_off(const Property &property) { + _properties[property] = TD_off; + state_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::is_identity +// Access: Public +// Description: Returns true if this property has been indicated as +// an identity transition, false otherwise. +//////////////////////////////////////////////////////////////////// +template +bool MultiTransition:: +is_identity(const Property &property) const { + Properties::const_iterator pi; + pi = _properties.find(property); + if (pi != _properties.end()) { + return (*pi).second == TD_identity; + } + + // The property is not mentioned. It's implicitly identity only if + // the default_dir flag is identity. + return (_default_dir == TD_identity); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::is_on +// Access: Public +// Description: Returns true if this property has been indicated as +// an 'on' transition, false otherwise. +//////////////////////////////////////////////////////////////////// +template +bool MultiTransition:: +is_on(const Property &property) const { + Properties::const_iterator pi; + pi = _properties.find(property); + if (pi != _properties.end()) { + return (*pi).second == TD_on; + } + + // The property is not mentioned. It's implicitly 'on' only if the + // default_dir flag is TD_on. + return (_default_dir == TD_on); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::is_on +// Access: Public +// Description: Returns true if this property has been indicated as +// an 'off' transition, false otherwise. +//////////////////////////////////////////////////////////////////// +template +bool MultiTransition:: +is_off(const Property &property) const { + Properties::const_iterator pi; + pi = _properties.find(property); + if (pi != _properties.end()) { + return (*pi).second == TD_off; + } + + // The property is not mentioned. It's implicitly 'off' only if the + // default_dir flag is TD_off. + return (_default_dir == TD_off); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::make_identity +// Access: Public, Virtual +// Description: This is a pure virtual function and normally would +// not need a body, except that VC++ doesn't seem happy +// about instantiating the template otherwise. +//////////////////////////////////////////////////////////////////// +template +NodeTransition *MultiTransition:: +make_identity() const { + return NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::compose +// Access: Public, Virtual +// Description: Returns a new transition that corresponds to the +// composition of this transition with the second +// transition (which must be of an equivalent type). +// This may return the same pointer as either source +// transition. Applying the transition returned from +// this function to an attribute attribute will produce +// the same effect as applying each transition +// separately. +//////////////////////////////////////////////////////////////////// +template +NodeTransition *MultiTransition:: +compose(const NodeTransition *other) const { + const MultiTransition *ot; + DCAST_INTO_R(ot, other, NULL); + + if (ot->_priority < _priority) { + // The other transition too low-priority; the result is unchanged. + return (MultiTransition *)this; + + } else if (ot->_priority > _priority) { + // The other priority is higher: the result is the same as the other. + return (MultiTransition *)ot; + + } else if (ot->_default_dir != TD_identity) { + // The other transition is a complete-world transition: the result + // is the same as other. + return (MultiTransition *)ot; + + } else if (is_identity()) { + // We're identity: the result is the same as other. + return (MultiTransition *)ot; + + } else if (ot->is_identity()) { + // The other transition is identity: it has no effect. + return (MultiTransition *)this; + + } else { + // Neither of us is identity. Build and return a new list. + MultiTransition *result; + DCAST_INTO_R(result, make_identity(), NULL); + result->_default_dir = _default_dir; + + dmap_compose(_properties.begin(), _properties.end(), + ot->_properties.begin(), ot->_properties.end(), + inserter(result->_properties, result->_properties.begin())); + + return result; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::invert +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +NodeTransition *MultiTransition:: +invert() const { + if (is_identity()) { + return (MultiTransition *)this; + } + + MultiTransition *result; + DCAST_INTO_R(result, make_identity(), NULL); + + result->_default_dir = TD_identity; + + dmap_invert(_properties.begin(), _properties.end(), + inserter(result->_properties, result->_properties.begin())); + + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::apply +// Access: Public, Virtual +// Description: Returns a new attribute (or possibly the same +// attribute) that represents the effect of applying this +// indicated transition to the indicated attribute. The +// source attribute may be NULL, indicating the initial +// attribute. +//////////////////////////////////////////////////////////////////// +template +NodeAttribute *MultiTransition:: +apply(const NodeAttribute *attrib) const { + + MultiAttribute *result; + if (attrib == (const NodeAttribute *)NULL) { + DCAST_INTO_R(result, make_attrib(), NULL); + } else { + DCAST_INTO_R(result, (NodeAttribute *)attrib, NULL); + } + + if (_priority < result->_priority || is_identity()) { + // The priority is too low to affect the attribute, or we're + // identity. + return result; + } + + if (result->get_ref_count() > 1) { + // Copy on write. + DCAST_INTO_R(result, result->make_copy(), NULL); + } + + result->_priority = _priority; + + MultiAttribute::Properties temp; + if (_default_dir == TD_identity) { + // In this case, the normal case, the transition does not specify + // completely what the attributes should be. + bmap_apply(result->_properties.begin(), result->_properties.end(), + _properties.begin(), _properties.end(), + false, TD_on, + inserter(temp, temp.begin())); + result->_properties_is_on = true; + + } else if (_default_dir == TD_off) { + // In this case, the transition completely specifies what the + // attributes should be; any property not explicitly mentioned by + // the transition should be turned off. + bmap_apply(result->_properties.begin(), result->_properties.end(), + _properties.begin(), _properties.end(), + true, TD_on, + inserter(temp, temp.begin())); + result->_properties_is_on = true; + + } else { // _default_dir == TD_on + // In this case, the transition completely specifies what the + // attributes should be; any property not explicitly mentioned by + // the transition should be turned on. + bmap_apply(result->_properties.begin(), result->_properties.end(), + _properties.begin(), _properties.end(), + true, TD_off, + inserter(temp, temp.begin())); + result->_properties_is_on = false; + } + + result->_properties.swap(temp); + + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +output(ostream &out) const { + Properties::const_iterator pi; + + bool any_identity = false; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second == TD_identity) { + if (!any_identity) { + out << " identity("; + any_identity = true; + } else { + out << ", "; + } + output_property(out, (*pi).first); + } + } + if (any_identity) { + out << ")"; + } + + bool any_on = false; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second == TD_on) { + if (!any_on) { + out << " on("; + any_on = true; + } else { + out << ", "; + } + output_property(out, (*pi).first); + } + } + if (any_on) { + out << ")"; + } + + bool any_off = false; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second == TD_off) { + if (!any_off) { + out << " off("; + any_off = true; + } else { + out << ", "; + } + output_property(out, (*pi).first); + } + } + if (any_off) { + out << ")"; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +write(ostream &out, int indent_level) const { + Properties::const_iterator pi; + + bool any_identity = false; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second == TD_identity) { + if (!any_identity) { + indent(out, indent_level) << "identity:\n"; + any_identity = true; + } + write_property(out, (*pi).first, indent_level + 2); + } + } + + bool any_on = false; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second == TD_on) { + if (!any_on) { + indent(out, indent_level) << "on:\n"; + any_on = true; + } + write_property(out, (*pi).first, indent_level + 2); + } + } + + bool any_off = false; + for (pi = _properties.begin(); pi != _properties.end(); ++pi) { + if ((*pi).second == TD_off) { + if (!any_off) { + indent(out, indent_level) << "off:\n"; + any_off = true; + } + write_property(out, (*pi).first, indent_level + 2); + } + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::internal_compare_to +// Access: Protected, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +int MultiTransition:: +internal_compare_to(const NodeTransition *other) const { + const MultiTransition *ot; + DCAST_INTO_R(ot, other, false); + + if (_default_dir != ot->_default_dir) { + return (int)_default_dir - (int)ot->_default_dir; + } + + return dmap_compare(_properties.begin(), _properties.end(), + ot->_properties.begin(), ot->_properties.end()); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::output_property +// Access: Public, Virtual +// Description: This is a pure virtual function and normally would +// not need a body, except that VC++ doesn't seem happy +// about instantiating the template otherwise. +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +output_property(ostream &, const Property &) const { +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::write_property +// Access: Public, Virtual +// Description: This is a pure virtual function and normally would +// not need a body, except that VC++ doesn't seem happy +// about instantiating the template otherwise. +//////////////////////////////////////////////////////////////////// +template +void MultiTransition:: +write_property(ostream &, const Property &, int) const { +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::size +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiTransition::size_type MultiTransition:: +size() const { + return _properties.size(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::begin +// Access: Public +// Description: Returns an iterator that begins the sequence of +// properties in the transition. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiTransition::const_iterator MultiTransition:: +begin() const { + return _properties.begin(); +} + +//////////////////////////////////////////////////////////////////// +// Function: MultiTransition::end +// Access: Public +// Description: Returns an iterator that marks the end of the +// sequence of properties in the transition. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH MultiTransition::const_iterator MultiTransition:: +end() const { + return _properties.end(); +} + diff --git a/panda/src/graph/multiTransition.h b/panda/src/graph/multiTransition.h index bf3bbcad32..9159826a69 100644 --- a/panda/src/graph/multiTransition.h +++ b/panda/src/graph/multiTransition.h @@ -63,8 +63,8 @@ PUBLISHED: // set the default direction, which indicates whether to implicitly // turn on or off (or leave alone) any property not explicitly // mentioned in the transition. - INLINE void set_default_dir(TransitionDirection dir); - INLINE TransitionDirection get_default_dir() const; + INLINE_GRAPH void set_default_dir(TransitionDirection dir); + INLINE_GRAPH TransitionDirection get_default_dir() const; void set_identity(const Property &prop); void set_on(const Property &prop); @@ -100,9 +100,9 @@ public: typedef Properties::value_type value_type; typedef Properties::size_type size_type; - INLINE size_type size() const; - INLINE const_iterator begin() const; - INLINE const_iterator end() const; + INLINE_GRAPH size_type size() const; + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; private: Properties _properties; @@ -127,6 +127,6 @@ private: static TypeHandle _type_handle; }; -#include "multiTransition.I" +#include "multiTransition.T" #endif diff --git a/panda/src/graph/multiTransitionHelpers.h b/panda/src/graph/multiTransitionHelpers.h index d699511643..ce65d965fb 100644 --- a/panda/src/graph/multiTransitionHelpers.h +++ b/panda/src/graph/multiTransitionHelpers.h @@ -124,6 +124,8 @@ bmap_apply(InputIterator1 first1, InputIterator1 last1, bool complete_transition, TransitionDirection want_dirs, OutputIterator result); +#ifdef BUILDING_PANDA #include "multiTransitionHelpers.I" +#endif #endif diff --git a/panda/src/graph/namedNode.I b/panda/src/graph/namedNode.I index 66732d3fd3..d825b031d7 100644 --- a/panda/src/graph/namedNode.I +++ b/panda/src/graph/namedNode.I @@ -9,7 +9,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NamedNode:: +INLINE_GRAPH NamedNode:: NamedNode(const string &initial_name) : Namable(initial_name) { @@ -20,7 +20,7 @@ NamedNode(const string &initial_name) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NamedNode:: +INLINE_GRAPH NamedNode:: NamedNode(const NamedNode ©) : Node(copy), Namable(copy) { @@ -31,8 +31,13 @@ NamedNode(const NamedNode ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NamedNode:: +INLINE_GRAPH void NamedNode:: operator = (const NamedNode ©) { Node::operator = (copy); Namable::operator = (copy); } + +EXPCL_PANDA INLINE_GRAPH ostream & operator << (ostream &out, const NamedNode &nod) { + nod.output(out); + return out; +} diff --git a/panda/src/graph/namedNode.cxx b/panda/src/graph/namedNode.cxx index ccc011b7f4..3d599a6e70 100644 --- a/panda/src/graph/namedNode.cxx +++ b/panda/src/graph/namedNode.cxx @@ -2,11 +2,11 @@ // Created by: drose (15Jan99) // -#include "namedNode.h" #include #include #include #include +#include "namedNode.h" TypeHandle NamedNode::_type_handle; diff --git a/panda/src/graph/namedNode.h b/panda/src/graph/namedNode.h index cff3d5e3cf..7f5e6efbb4 100644 --- a/panda/src/graph/namedNode.h +++ b/panda/src/graph/namedNode.h @@ -17,22 +17,20 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA NamedNode : public Node, public Namable { PUBLISHED: - INLINE NamedNode(const string &initial_name = ""); + INLINE_GRAPH NamedNode(const string &initial_name = ""); public: - INLINE NamedNode(const NamedNode ©); - INLINE void operator = (const NamedNode ©); + INLINE_GRAPH NamedNode(const NamedNode ©); + INLINE_GRAPH void operator = (const NamedNode ©); virtual Node *make_copy() const; virtual void output(ostream &out) const; -public: static void register_with_read_factory(void); virtual void write_datagram(BamWriter* manager, Datagram &me); static TypedWriteable *make_NamedNode(const FactoryParams ¶ms); - protected: void fillin(DatagramIterator& scan, BamReader* manager); @@ -58,13 +56,11 @@ private: // We need this operator to specify which output operator (from Node // or Namable) that NamedNode uses. -INLINE ostream & -operator << (ostream &out, const NamedNode &node) { - node.output(out); - return out; -} +EXPCL_PANDA INLINE_GRAPH ostream & operator << (ostream &out, const NamedNode &nod); +#ifdef BUILDING_PANDA #include "namedNode.I" +#endif #endif diff --git a/panda/src/graph/node.I b/panda/src/graph/node.I index b8ca0fd9c8..d2db10fa70 100644 --- a/panda/src/graph/node.I +++ b/panda/src/graph/node.I @@ -12,7 +12,7 @@ // removes it. Returns true if the arc was found and // removed, false if it did not exist. //////////////////////////////////////////////////////////////////// -INLINE bool +EXPCL_PANDA INLINE_GRAPH bool remove_child(Node *parent, Node *child, TypeHandle graph_type) { NodeRelation *arc = find_arc(parent, child, graph_type); if (arc != (NodeRelation *)NULL) { @@ -21,3 +21,9 @@ remove_child(Node *parent, Node *child, TypeHandle graph_type) { } return false; } + +INLINE_GRAPH ostream & +operator << (ostream &out, const Node &node) { + node.output(out); + return out; +} diff --git a/panda/src/graph/node.h b/panda/src/graph/node.h index c9a829da29..ef9594e096 100644 --- a/panda/src/graph/node.h +++ b/panda/src/graph/node.h @@ -141,43 +141,17 @@ private: static TypeHandle _type_handle; }; -INLINE ostream & -operator << (ostream &out, const Node &node) { - node.output(out); - return out; -} +INLINE_GRAPH ostream & operator << (ostream &out, const Node &node); EXPCL_PANDA NodeRelation * find_arc(Node *parent, Node *child, TypeHandle graph_type); -INLINE bool +EXPCL_PANDA INLINE_GRAPH bool remove_child(Node *parent, Node *child, TypeHandle graph_type); - +#ifdef BUILDING_PANDA #include "node.I" +#endif #endif - - - - - - - - - - - - - - - - - - - - - - - diff --git a/panda/src/graph/nodeAttribute.I b/panda/src/graph/nodeAttribute.I index 4fae565881..d8e1dddb1d 100644 --- a/panda/src/graph/nodeAttribute.I +++ b/panda/src/graph/nodeAttribute.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttribute:: +INLINE_GRAPH NodeAttribute:: NodeAttribute() { _priority = 0; } @@ -18,7 +18,7 @@ NodeAttribute() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttribute:: +INLINE_GRAPH NodeAttribute:: NodeAttribute(const NodeAttribute ©) : TypedReferenceCount(copy), _priority(copy._priority) @@ -30,7 +30,7 @@ NodeAttribute(const NodeAttribute ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeAttribute:: +INLINE_GRAPH void NodeAttribute:: operator = (const NodeAttribute ©) { TypedReferenceCount::operator = (copy); _priority = copy._priority; @@ -41,7 +41,7 @@ operator = (const NodeAttribute ©) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttribute:: +INLINE_GRAPH bool NodeAttribute:: operator == (const NodeAttribute &other) const { return compare_to(other) == 0; } @@ -51,7 +51,7 @@ operator == (const NodeAttribute &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttribute:: +INLINE_GRAPH bool NodeAttribute:: operator != (const NodeAttribute &other) const { return compare_to(other) != 0; } @@ -61,7 +61,7 @@ operator != (const NodeAttribute &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttribute:: +INLINE_GRAPH bool NodeAttribute:: operator < (const NodeAttribute &other) const { return compare_to(other) < 0; } @@ -71,7 +71,7 @@ operator < (const NodeAttribute &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttribute:: +INLINE_GRAPH bool NodeAttribute:: operator <= (const NodeAttribute &other) const { return compare_to(other) <= 0; } @@ -81,7 +81,7 @@ operator <= (const NodeAttribute &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttribute:: +INLINE_GRAPH bool NodeAttribute:: operator > (const NodeAttribute &other) const { return compare_to(other) > 0; } @@ -91,7 +91,7 @@ operator > (const NodeAttribute &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttribute:: +INLINE_GRAPH bool NodeAttribute:: operator >= (const NodeAttribute &other) const { return compare_to(other) >= 0; } @@ -110,7 +110,7 @@ operator >= (const NodeAttribute &other) const { // of equivalent attributes together in STL structures // like maps and sets. //////////////////////////////////////////////////////////////////// -INLINE int NodeAttribute:: +INLINE_GRAPH int NodeAttribute:: compare_to(const NodeAttribute &other) const { TypeHandle my_handle = get_handle(); TypeHandle other_handle = other.get_handle(); @@ -131,7 +131,7 @@ compare_to(const NodeAttribute &other) const { // The attribute will not be affected by transitions // with a lower priority. //////////////////////////////////////////////////////////////////// -INLINE void NodeAttribute:: +INLINE_GRAPH void NodeAttribute:: set_priority(int priority) { _priority = priority; } @@ -143,7 +143,12 @@ set_priority(int priority) { // Normally this is of limited value; the priority is // meaningful primarily on the transitions. //////////////////////////////////////////////////////////////////// -INLINE int NodeAttribute:: +INLINE_GRAPH int NodeAttribute:: get_priority() const { return _priority; } + +INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttribute &nab) { + nab.output(out); + return out; +} diff --git a/panda/src/graph/nodeAttribute.h b/panda/src/graph/nodeAttribute.h index 14961859ff..9f95127000 100644 --- a/panda/src/graph/nodeAttribute.h +++ b/panda/src/graph/nodeAttribute.h @@ -42,23 +42,23 @@ class GraphicsStateGuardianBase; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA NodeAttribute : public TypedReferenceCount { protected: - INLINE NodeAttribute(); - INLINE NodeAttribute(const NodeAttribute ©); - INLINE void operator = (const NodeAttribute ©); + INLINE_GRAPH NodeAttribute(); + INLINE_GRAPH NodeAttribute(const NodeAttribute ©); + INLINE_GRAPH void operator = (const NodeAttribute ©); public: - INLINE bool operator == (const NodeAttribute &other) const; - INLINE bool operator != (const NodeAttribute &other) const; - INLINE bool operator < (const NodeAttribute &other) const; - INLINE bool operator <= (const NodeAttribute &other) const; - INLINE bool operator > (const NodeAttribute &other) const; - INLINE bool operator >= (const NodeAttribute &other) const; + INLINE_GRAPH bool operator == (const NodeAttribute &other) const; + INLINE_GRAPH bool operator != (const NodeAttribute &other) const; + INLINE_GRAPH bool operator < (const NodeAttribute &other) const; + INLINE_GRAPH bool operator <= (const NodeAttribute &other) const; + INLINE_GRAPH bool operator > (const NodeAttribute &other) const; + INLINE_GRAPH bool operator >= (const NodeAttribute &other) const; - INLINE int compare_to(const NodeAttribute &other) const; + INLINE_GRAPH int compare_to(const NodeAttribute &other) const; PUBLISHED: - INLINE void set_priority(int priority); - INLINE int get_priority() const; + INLINE_GRAPH void set_priority(int priority); + INLINE_GRAPH int get_priority() const; public: virtual NodeAttribute *make_copy() const=0; @@ -99,11 +99,10 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const NodeAttribute &nab) { - nab.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttribute &nab); +#ifdef BUILDING_PANDA #include "nodeAttribute.I" +#endif #endif diff --git a/panda/src/graph/nodeAttributeWrapper.I b/panda/src/graph/nodeAttributeWrapper.I index 01774acee8..20f6ca7043 100644 --- a/panda/src/graph/nodeAttributeWrapper.I +++ b/panda/src/graph/nodeAttributeWrapper.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributeWrapper:: +INLINE_GRAPH NodeAttributeWrapper:: NodeAttributeWrapper(TypeHandle handle) : _handle(handle) { nassertv(_handle != TypeHandle::none()); } @@ -18,7 +18,7 @@ NodeAttributeWrapper(TypeHandle handle) : _handle(handle) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributeWrapper:: +INLINE_GRAPH NodeAttributeWrapper:: NodeAttributeWrapper(const NodeAttributeWrapper ©) : _handle(copy._handle), _attrib(copy._attrib) @@ -30,7 +30,7 @@ NodeAttributeWrapper(const NodeAttributeWrapper ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeAttributeWrapper:: +INLINE_GRAPH void NodeAttributeWrapper:: operator = (const NodeAttributeWrapper ©) { _handle = copy._handle; _attrib = copy._attrib; @@ -41,7 +41,7 @@ operator = (const NodeAttributeWrapper ©) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE TypeHandle NodeAttributeWrapper:: +INLINE_GRAPH TypeHandle NodeAttributeWrapper:: get_handle() const { return _handle; } @@ -51,7 +51,7 @@ get_handle() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttribute *NodeAttributeWrapper:: +INLINE_GRAPH NodeAttribute *NodeAttributeWrapper:: get_attrib() const { return _attrib; } @@ -61,7 +61,7 @@ get_attrib() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeAttributeWrapper:: +INLINE_GRAPH void NodeAttributeWrapper:: set_attrib(NodeAttribute *attrib) { _attrib = attrib; } @@ -72,7 +72,7 @@ set_attrib(NodeAttribute *attrib) { // Description: Returns true if the wrapper represents an initial // attribute. //////////////////////////////////////////////////////////////////// -INLINE bool NodeAttributeWrapper:: +INLINE_GRAPH bool NodeAttributeWrapper:: is_initial() const { return (_attrib == (NodeAttribute *)NULL); // || _attrib->is_initial() @@ -83,7 +83,7 @@ is_initial() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int NodeAttributeWrapper:: +INLINE_GRAPH int NodeAttributeWrapper:: compare_to(const NodeAttributeWrapper &other) const { nassertr(_handle == other._handle, false); if (_attrib == other._attrib) { @@ -103,30 +103,12 @@ compare_to(const NodeAttributeWrapper &other) const { // Access: Public // Description: Resets the wrapper to the initial attribute. //////////////////////////////////////////////////////////////////// -INLINE void NodeAttributeWrapper:: +INLINE_GRAPH void NodeAttributeWrapper:: make_initial() { _attrib.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: get_attribute_into -// Description: This external template function is handy for -// extracting the attribute (of a known type) from the -// wrapper. If the attribute exists, it is -// automatically downcasted to the correct type and -// stored in the pointer given in the first parameter, -// and the return value is true. If the attribute does -// not exist, the pointer is filled with NULL and the -// return value is false. -//////////////////////////////////////////////////////////////////// -template -INLINE bool -get_attribute_into(Attribute *&ptr, const NodeAttributeWrapper &attrib) { - NodeAttribute *nt = attrib.get_attrib(); - if (nt == (NodeAttribute *)NULL) { - ptr = (Attribute *)NULL; - return false; - } - DCAST_INTO_R(ptr, nt, false); - return true; +INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttributeWrapper &naw) { + naw.output(out); + return out; } diff --git a/panda/src/graph/nodeAttributeWrapper.T b/panda/src/graph/nodeAttributeWrapper.T new file mode 100644 index 0000000000..ad9837aef1 --- /dev/null +++ b/panda/src/graph/nodeAttributeWrapper.T @@ -0,0 +1,28 @@ +// Filename: nodeAttributeWrapper.T +// Created by: drose (20Mar00) +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: get_attribute_into +// Description: This external template function is handy for +// extracting the attribute (of a known type) from the +// wrapper. If the attribute exists, it is +// automatically downcasted to the correct type and +// stored in the pointer given in the first parameter, +// and the return value is true. If the attribute does +// not exist, the pointer is filled with NULL and the +// return value is false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_attribute_into(Attribute *&ptr, const NodeAttributeWrapper &attrib) { + NodeAttribute *nt = attrib.get_attrib(); + if (nt == (NodeAttribute *)NULL) { + ptr = (Attribute *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} diff --git a/panda/src/graph/nodeAttributeWrapper.h b/panda/src/graph/nodeAttributeWrapper.h index 5e53448adf..e0091bd22d 100644 --- a/panda/src/graph/nodeAttributeWrapper.h +++ b/panda/src/graph/nodeAttributeWrapper.h @@ -24,19 +24,19 @@ public: typedef NodeTransitionWrapper TransitionWrapper; typedef NodeAttributeWrapper AttributeWrapper; - INLINE NodeAttributeWrapper(TypeHandle handle); - INLINE NodeAttributeWrapper(const NodeAttributeWrapper ©); - INLINE void operator = (const NodeAttributeWrapper ©); + INLINE_GRAPH NodeAttributeWrapper(TypeHandle handle); + INLINE_GRAPH NodeAttributeWrapper(const NodeAttributeWrapper ©); + INLINE_GRAPH void operator = (const NodeAttributeWrapper ©); static NodeAttributeWrapper init_from(const NodeTransitionWrapper &trans); - INLINE TypeHandle get_handle() const; - INLINE NodeAttribute *get_attrib() const; - INLINE void set_attrib(NodeAttribute *attrib); + INLINE_GRAPH TypeHandle get_handle() const; + INLINE_GRAPH NodeAttribute *get_attrib() const; + INLINE_GRAPH void set_attrib(NodeAttribute *attrib); - INLINE bool is_initial() const; - INLINE int compare_to(const NodeAttributeWrapper &other) const; + INLINE_GRAPH bool is_initial() const; + INLINE_GRAPH int compare_to(const NodeAttributeWrapper &other) const; - INLINE void make_initial(); + INLINE_GRAPH void make_initial(); void apply_in_place(const NodeTransitionWrapper &trans); void output(ostream &out) const; @@ -47,15 +47,12 @@ private: PT(NodeAttribute) _attrib; }; -INLINE ostream &operator << (ostream &out, const NodeAttributeWrapper &naw) { - naw.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttributeWrapper &naw); +#include "nodeAttributeWrapper.T" + +#ifdef BUILDING_PANDA #include "nodeAttributeWrapper.I" - -template -INLINE bool -get_attribute_into(Attribute *&ptr, const NodeAttributeWrapper &trans); +#endif #endif diff --git a/panda/src/graph/nodeAttributes.I b/panda/src/graph/nodeAttributes.I index 05053e5b0a..48b0ede98d 100644 --- a/panda/src/graph/nodeAttributes.I +++ b/panda/src/graph/nodeAttributes.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes::size_type NodeAttributes:: +INLINE_GRAPH NodeAttributes::size_type NodeAttributes:: size() const { return _attributes.size(); } @@ -18,7 +18,7 @@ size() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes::iterator NodeAttributes:: +INLINE_GRAPH NodeAttributes::iterator NodeAttributes:: begin() { return _attributes.begin(); } @@ -28,7 +28,7 @@ begin() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes::iterator NodeAttributes:: +INLINE_GRAPH NodeAttributes::iterator NodeAttributes:: end() { return _attributes.end(); } @@ -38,7 +38,7 @@ end() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes::const_iterator NodeAttributes:: +INLINE_GRAPH NodeAttributes::const_iterator NodeAttributes:: begin() const { return _attributes.begin(); } @@ -48,7 +48,7 @@ begin() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes::const_iterator NodeAttributes:: +INLINE_GRAPH NodeAttributes::const_iterator NodeAttributes:: end() const { return _attributes.end(); } @@ -58,7 +58,7 @@ end() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes::iterator NodeAttributes:: +INLINE_GRAPH NodeAttributes::iterator NodeAttributes:: insert(NodeAttributes::iterator position, const NodeAttributes::value_type &x) { return _attributes.insert(position, x); @@ -69,7 +69,7 @@ insert(NodeAttributes::iterator position, // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeAttributes:: +INLINE_GRAPH void NodeAttributes:: erase(NodeAttributes::iterator position) { _attributes.erase(position); } @@ -80,7 +80,7 @@ erase(NodeAttributes::iterator position) { // Description: Modifies the current NodeAttributes object to reflect // the application of the indicated transitions. //////////////////////////////////////////////////////////////////// -INLINE void NodeAttributes:: +INLINE_GRAPH void NodeAttributes:: apply_in_place(const NodeTransitionCache &trans) { apply_from(*this, trans); } @@ -93,33 +93,15 @@ apply_in_place(const NodeTransitionCache &trans) { // NodeAttributes to the indicated transition cache. // This NodeAttributes object is not changed. //////////////////////////////////////////////////////////////////// -INLINE NodeAttributes *NodeAttributes:: +INLINE_GRAPH NodeAttributes *NodeAttributes:: apply(const NodeTransitionCache &trans) const { NodeAttributes *na = new NodeAttributes; na->apply_from(*this, trans); return na; } -//////////////////////////////////////////////////////////////////// -// Function: get_attribute_into -// Description: This external template function is handy for -// extracting a attribute of a particular type from the -// set. If the attribute exists, it is automatically -// downcasted to the correct type and stored in the -// pointer given in the first parameter, and the return -// value is true. If the attribute does not exist, the -// pointer is filled with NULL and the return value is -// false. -//////////////////////////////////////////////////////////////////// -template -INLINE bool -get_attribute_into(Attribute *&ptr, const NodeAttributes &attrib, - TypeHandle transition_type) { - NodeAttribute *nt = attrib.get_attribute(transition_type); - if (nt == (NodeAttribute *)NULL) { - ptr = (Attribute *)NULL; - return false; - } - DCAST_INTO_R(ptr, nt, false); - return true; +INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttributes &nas) { + nas.output(out); + return out; } + diff --git a/panda/src/graph/nodeAttributes.T b/panda/src/graph/nodeAttributes.T new file mode 100644 index 0000000000..d104e9390c --- /dev/null +++ b/panda/src/graph/nodeAttributes.T @@ -0,0 +1,28 @@ +// Filename: nodeAttributes.T +// Created by: drose (21Mar00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: get_attribute_into +// Description: This external template function is handy for +// extracting a attribute of a particular type from the +// set. If the attribute exists, it is automatically +// downcasted to the correct type and stored in the +// pointer given in the first parameter, and the return +// value is true. If the attribute does not exist, the +// pointer is filled with NULL and the return value is +// false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_attribute_into(Attribute *&ptr, const NodeAttributes &attrib, + TypeHandle transition_type) { + NodeAttribute *nt = attrib.get_attribute(transition_type); + if (nt == (NodeAttribute *)NULL) { + ptr = (Attribute *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} diff --git a/panda/src/graph/nodeAttributes.h b/panda/src/graph/nodeAttributes.h index 94dd3b3f94..f249270dbc 100644 --- a/panda/src/graph/nodeAttributes.h +++ b/panda/src/graph/nodeAttributes.h @@ -54,17 +54,17 @@ public: typedef Attributes::value_type value_type; typedef Attributes::size_type size_type; - INLINE size_type size() const; - INLINE iterator begin(); - INLINE iterator end(); - INLINE const_iterator begin() const; - INLINE const_iterator end() const; - INLINE iterator insert(iterator position, const value_type &x); - INLINE void erase(iterator position); + INLINE_GRAPH size_type size() const; + INLINE_GRAPH iterator begin(); + INLINE_GRAPH iterator end(); + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; + INLINE_GRAPH iterator insert(iterator position, const value_type &x); + INLINE_GRAPH void erase(iterator position); public: - INLINE void apply_in_place(const NodeTransitionCache &trans); - INLINE NodeAttributes *apply(const NodeTransitionCache &trans) const; + INLINE_GRAPH void apply_in_place(const NodeTransitionCache &trans); + INLINE_GRAPH NodeAttributes *apply(const NodeTransitionCache &trans) const; void apply_from(const NodeAttributes &other, const NodeTransitionCache &trans); @@ -76,19 +76,16 @@ PUBLISHED: private: Attributes _attributes; -friend class NodeAttributeCache; + friend class NodeAttributeCache; }; -INLINE ostream &operator << (ostream &out, const NodeAttributes &nas) { - nas.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttributes &nas); -template -INLINE bool -get_attribute_into(Attribute *&ptr, const NodeAttributes &attrib, - TypeHandle transition_type); +#include "nodeAttributes.T" +#ifdef BUILDING_PANDA #include "nodeAttributes.I" +#endif #endif + diff --git a/panda/src/graph/nodeRelation.I b/panda/src/graph/nodeRelation.I index ec14e3542a..c40cdb828d 100644 --- a/panda/src/graph/nodeRelation.I +++ b/panda/src/graph/nodeRelation.I @@ -9,7 +9,7 @@ // will also delete the arc unless there are some // additional outstanding pointers to it. //////////////////////////////////////////////////////////////////// -INLINE void +EXPCL_PANDA INLINE_GRAPH void remove_arc(NodeRelation *arc) { PT(NodeRelation) hold_arc = arc->detach(); arc->_parent = NULL; @@ -21,7 +21,7 @@ remove_arc(NodeRelation *arc) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: output_transitions(ostream &out) const { out << _transitions; } @@ -31,7 +31,7 @@ output_transitions(ostream &out) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: write_transitions(ostream &out, int indent_level) const { _transitions.write(out, indent_level); } @@ -41,7 +41,7 @@ write_transitions(ostream &out, int indent_level) const { // Access: Public // Description: Returns the node above the arc in the scene graph. //////////////////////////////////////////////////////////////////// -INLINE Node *NodeRelation:: +INLINE_GRAPH Node *NodeRelation:: get_parent() const { return _parent; } @@ -51,7 +51,7 @@ get_parent() const { // Access: Public // Description: Returns the node below the arc in the scene graph. //////////////////////////////////////////////////////////////////// -INLINE Node *NodeRelation:: +INLINE_GRAPH Node *NodeRelation:: get_child() const { return _child; } @@ -62,7 +62,7 @@ get_child() const { // Description: Returns the sorting index of the arc. This affects // its apparent position among its list of siblings. //////////////////////////////////////////////////////////////////// -INLINE int NodeRelation:: +INLINE_GRAPH int NodeRelation:: get_sort() const { return _sort; } @@ -76,7 +76,7 @@ get_sort() const { // A node may simultaneously have many arcs of different // types. //////////////////////////////////////////////////////////////////// -INLINE TypeHandle NodeRelation:: +INLINE_GRAPH TypeHandle NodeRelation:: get_graph_type() const { return _graph_type; } @@ -86,7 +86,7 @@ get_graph_type() const { // Access: Public // Description: Changes the parent of the arc to a different node. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: change_parent(Node *parent) { PT(NodeRelation) hold_arc = detach(); _parent = parent; @@ -99,7 +99,7 @@ change_parent(Node *parent) { // Description: Changes the parent of the arc to a different node, // simultaneously changing the sort index. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: change_parent(Node *parent, int sort) { PT(NodeRelation) hold_arc = detach(); _parent = parent; @@ -112,7 +112,7 @@ change_parent(Node *parent, int sort) { // Access: Public // Description: Changes the child of the arc to a different node. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: change_child(Node *child) { PT(NodeRelation) hold_arc = detach(); _child = child; @@ -125,7 +125,7 @@ change_child(Node *child) { // Description: Simultaneously moves both the parent and child of the // arc to different nodes. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: change_parent_and_child(Node *parent, Node *child) { PT(NodeRelation) hold_arc = detach(); _parent = parent; @@ -139,7 +139,7 @@ change_parent_and_child(Node *parent, Node *child) { // Description: Changes the sorting index of the arc. This affects // its apparent position among its list of siblings. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: set_sort(int sort) { PT(NodeRelation) hold_arc = detach(); _sort = sort; @@ -153,7 +153,7 @@ set_sort(int sort) { // arc into a totally different graph; it may now be // detected only by a special traversal. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: set_graph_type(TypeHandle graph_type) { PT(NodeRelation) hold_arc = detach(); _graph_type = graph_type; @@ -174,7 +174,7 @@ set_graph_type(TypeHandle graph_type) { // transition in the set, if any, or NULL if there was // none. //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) NodeRelation:: +INLINE_GRAPH PT(NodeTransition) NodeRelation:: set_transition(NodeTransition *trans) { nassertr(trans != (NodeTransition *)NULL, NULL); nassertr(trans->get_handle() != TypeHandle::none(), NULL); @@ -190,7 +190,7 @@ set_transition(NodeTransition *trans) { // this will be used for creating override transitions // on-the-fly. //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) NodeRelation:: +INLINE_GRAPH PT(NodeTransition) NodeRelation:: set_transition(NodeTransition *trans, int priority) { nassertr(trans != (NodeTransition *)NULL, NULL); nassertr(trans->get_handle() != TypeHandle::none(), NULL); @@ -205,7 +205,7 @@ set_transition(NodeTransition *trans, int priority) { // indicated handle has been stored on the arc (even if // it is the identity transition), or false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool NodeRelation:: +INLINE_GRAPH bool NodeRelation:: has_transition(TypeHandle handle) const { return _transitions.has_transition(handle); } @@ -217,7 +217,7 @@ has_transition(TypeHandle handle) const { // the arc (even if it is the identity transition), or // false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool NodeRelation:: +INLINE_GRAPH bool NodeRelation:: has_any_transition() const { return !_transitions.is_empty(); } @@ -229,7 +229,7 @@ has_any_transition() const { // handle, or NULL if no such transition has been stored // on the arc. //////////////////////////////////////////////////////////////////// -INLINE NodeTransition *NodeRelation:: +INLINE_GRAPH NodeTransition *NodeRelation:: get_transition(TypeHandle handle) const { return _transitions.get_transition(handle); } @@ -242,7 +242,7 @@ get_transition(TypeHandle handle) const { // they sort after, or zero if the sets of transitions // are equivalent. //////////////////////////////////////////////////////////////////// -INLINE int NodeRelation:: +INLINE_GRAPH int NodeRelation:: compare_transitions_to(const NodeRelation *arc) const { return _transitions.compare_to(arc->_transitions); } @@ -256,7 +256,7 @@ compare_transitions_to(const NodeRelation *arc) const { // can do with this is store it and note whether it // increases. //////////////////////////////////////////////////////////////////// -INLINE UpdateSeq NodeRelation:: +INLINE_GRAPH UpdateSeq NodeRelation:: get_last_update() const { return _last_update; } @@ -268,7 +268,7 @@ get_last_update() const { // type, and immediately attaches it. Returns NULL if // the type is unknown. //////////////////////////////////////////////////////////////////// -INLINE NodeRelation *NodeRelation:: +INLINE_GRAPH NodeRelation *NodeRelation:: create_typed_arc(TypeHandle type, Node *parent, Node *child, int sort) { NodeRelation *arc = get_factory().make_instance(type); if (arc != (NodeRelation *)NULL) { @@ -287,7 +287,7 @@ create_typed_arc(TypeHandle type, Node *parent, Node *child, int sort) { // This is only intended to be called at initialization // time; don't call it directly. //////////////////////////////////////////////////////////////////// -INLINE void NodeRelation:: +INLINE_GRAPH void NodeRelation:: register_with_factory() { get_factory().register_factory(get_class_type(), make_arc); } @@ -300,7 +300,7 @@ register_with_factory() { // has been called. This is necessary to guarantee // ordering at static init time. //////////////////////////////////////////////////////////////////// -INLINE Factory &NodeRelation:: +INLINE_GRAPH Factory &NodeRelation:: get_factory() { if (_factory == (Factory *)NULL) { _factory = new Factory; @@ -313,7 +313,7 @@ get_factory() { // Access: Public, Static // Description: Returns the TypeHandle associated with this type. //////////////////////////////////////////////////////////////////// -INLINE TypeHandle NodeRelation:: +INLINE_GRAPH TypeHandle NodeRelation:: get_class_type() { return _type_handle; } @@ -328,37 +328,14 @@ get_class_type() { // removing themselves from the bounding volumes of // their parents, should set their graph_type to. //////////////////////////////////////////////////////////////////// -INLINE TypeHandle NodeRelation:: +INLINE_GRAPH TypeHandle NodeRelation:: get_stashed_type() { return _stashed_type_handle; } -//////////////////////////////////////////////////////////////////// -// Function: get_transition_into -// Description: This external template function is handy for -// extracting a transition of a particular type from the -// arc. If the transition exists, it is automatically -// downcasted to the correct type and stored in the -// pointer given in the first parameter, and the return -// value is true. If the transition does not exist, the -// pointer is filled with NULL and the return value is -// false. -//////////////////////////////////////////////////////////////////// -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeRelation *arc, - TypeHandle transition_type) { - NodeTransition *nt = arc->get_transition(transition_type); - if (nt == (NodeTransition *)NULL) { - ptr = (Transition *)NULL; - return false; - } - DCAST_INTO_R(ptr, nt, false); - return true; +EXPCL_PANDA INLINE_GRAPH ostream & +operator << (ostream &out, const NodeRelation &arc) { + arc.output(out); + return out; } -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeRelation *arc) { - return get_transition_into(ptr, arc, Transition::get_class_type()); -} diff --git a/panda/src/graph/nodeRelation.T b/panda/src/graph/nodeRelation.T new file mode 100644 index 0000000000..acb64a44b4 --- /dev/null +++ b/panda/src/graph/nodeRelation.T @@ -0,0 +1,34 @@ +// Filename: nodeRelation.T +// Created by: drose (30Sep99) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: get_transition_into +// Description: This external template function is handy for +// extracting a transition of a particular type from the +// arc. If the transition exists, it is automatically +// downcasted to the correct type and stored in the +// pointer given in the first parameter, and the return +// value is true. If the transition does not exist, the +// pointer is filled with NULL and the return value is +// false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const NodeRelation *arc, + TypeHandle transition_type) { + NodeTransition *nt = arc->get_transition(transition_type); + if (nt == (NodeTransition *)NULL) { + ptr = (Transition *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} + +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const NodeRelation *arc) { + return get_transition_into(ptr, arc, Transition::get_class_type()); +} diff --git a/panda/src/graph/nodeRelation.cxx b/panda/src/graph/nodeRelation.cxx index 1402ffaf66..c0d52b1707 100644 --- a/panda/src/graph/nodeRelation.cxx +++ b/panda/src/graph/nodeRelation.cxx @@ -62,7 +62,7 @@ init_last_graph_update() { //////////////////////////////////////////////////////////////////// #ifdef NDEBUG template -INLINE void +INLINE_GRAPH void verify_arc_list(Iterator, Iterator) { } #else // NDEBUG diff --git a/panda/src/graph/nodeRelation.h b/panda/src/graph/nodeRelation.h index c5cfa7feb0..cdc3bd3ba2 100644 --- a/panda/src/graph/nodeRelation.h +++ b/panda/src/graph/nodeRelation.h @@ -32,6 +32,8 @@ class Node; // type of graph, hence the parameter. extern EXPCL_PANDA UpdateSeq &last_graph_update(TypeHandle graph_type); +extern EXPCL_PANDA INLINE_GRAPH void remove_arc(NodeRelation *arc); + /////////////////////////////////////////////////////////////////// // Class : NodeRelation // Description : The base class for all scene graph arcs. This is the @@ -70,41 +72,41 @@ public: PUBLISHED: void output(ostream &out) const; - INLINE void output_transitions(ostream &out) const; - INLINE void write_transitions(ostream &out, int indent = 0) const; + INLINE_GRAPH void output_transitions(ostream &out) const; + INLINE_GRAPH void write_transitions(ostream &out, int indent = 0) const; - INLINE Node *get_parent() const; - INLINE Node *get_child() const; - INLINE int get_sort() const; - INLINE TypeHandle get_graph_type() const; + INLINE_GRAPH Node *get_parent() const; + INLINE_GRAPH Node *get_child() const; + INLINE_GRAPH int get_sort() const; + INLINE_GRAPH TypeHandle get_graph_type() const; void ref_parent(); void unref_parent(); - INLINE void change_parent(Node *parent); - INLINE void change_parent(Node *parent, int sort); - INLINE void change_child(Node *child); - INLINE void change_parent_and_child(Node *parent, Node *child); - INLINE void set_sort(int sort); - INLINE void set_graph_type(TypeHandle graph_type); + INLINE_GRAPH void change_parent(Node *parent); + INLINE_GRAPH void change_parent(Node *parent, int sort); + INLINE_GRAPH void change_child(Node *child); + INLINE_GRAPH void change_parent_and_child(Node *parent, Node *child); + INLINE_GRAPH void set_sort(int sort); + INLINE_GRAPH void set_graph_type(TypeHandle graph_type); - PT(NodeTransition) set_transition(TypeHandle handle, NodeTransition *trans); /*DONT INLINE THIS*/ - INLINE PT(NodeTransition) set_transition(NodeTransition *trans); - INLINE PT(NodeTransition) set_transition(NodeTransition *trans, int priority); - PT(NodeTransition) clear_transition(TypeHandle handle); /*DONT INLINE THIS*/ + PT(NodeTransition) set_transition(TypeHandle handle, NodeTransition *trans); /*DONT INLINE_GRAPH THIS*/ + INLINE_GRAPH PT(NodeTransition) set_transition(NodeTransition *trans); + INLINE_GRAPH PT(NodeTransition) set_transition(NodeTransition *trans, int priority); + PT(NodeTransition) clear_transition(TypeHandle handle); /*DONT INLINE_GRAPH THIS*/ - INLINE bool has_transition(TypeHandle handle) const; - INLINE bool has_any_transition() const; - INLINE NodeTransition *get_transition(TypeHandle handle) const; + INLINE_GRAPH bool has_transition(TypeHandle handle) const; + INLINE_GRAPH bool has_any_transition() const; + INLINE_GRAPH NodeTransition *get_transition(TypeHandle handle) const; void copy_transitions_from(const NodeRelation *arc); void compose_transitions_from(const NodeRelation *arc); void copy_transitions_from(const NodeTransitions &trans); void compose_transitions_from(const NodeTransitions &trans); void adjust_all_priorities(int adjustment); - INLINE int compare_transitions_to(const NodeRelation *arc) const; + INLINE_GRAPH int compare_transitions_to(const NodeRelation *arc) const; - INLINE UpdateSeq get_last_update() const; + INLINE_GRAPH UpdateSeq get_last_update() const; public: bool sub_render_trans(const AllAttributesWrapper &attrib, @@ -116,15 +118,15 @@ public: public: // Factory stuff: to create a new NodeRelation based on its // TypeHandle. - INLINE static NodeRelation * + INLINE_GRAPH static NodeRelation * create_typed_arc(TypeHandle type, Node *parent, Node *child, int sort = 0); // This is just to be called at initialization time; don't try to // call this directly. - INLINE static void register_with_factory(); + INLINE_GRAPH static void register_with_factory(); protected: - INLINE static Factory &get_factory(); + INLINE_GRAPH static Factory &get_factory(); private: static NodeRelation *make_arc(const FactoryParams ¶ms); @@ -196,8 +198,8 @@ protected: virtual void recompute_bound(); PUBLISHED: - INLINE static TypeHandle get_class_type(); - INLINE static TypeHandle get_stashed_type(); + INLINE_GRAPH static TypeHandle get_class_type(); + INLINE_GRAPH static TypeHandle get_stashed_type(); public: static void init_type(); @@ -208,29 +210,15 @@ private: static TypeHandle _type_handle; static TypeHandle _stashed_type_handle; - friend INLINE void remove_arc(NodeRelation *arc); + friend extern EXPCL_PANDA INLINE_GRAPH void remove_arc(NodeRelation *arc); friend class Node; friend class NodeTransitionWrapper; friend class AllTransitionsWrapper; friend class GraphPriorityAdjuster; }; -INLINE ostream & -operator << (ostream &out, const NodeRelation &arc) { - arc.output(out); - return out; -} - -INLINE void remove_arc(NodeRelation *arc); - -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeRelation *arc, - TypeHandle transition_type); - -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeRelation *arc); +EXPCL_PANDA INLINE_GRAPH ostream & +operator << (ostream &out, const NodeRelation &arc); typedef vector< PT(NodeRelation) > DownRelationPointers; typedef map DownRelations; @@ -238,7 +226,11 @@ typedef map DownRelations; typedef vector UpRelationPointers; typedef map UpRelations; +#include "nodeRelation.T" + +#ifdef BUILDING_PANDA #include "nodeRelation.I" +#endif // We include node.h here at the end, so we'll know that nodes are of // type ReferenceCount and will be able to compile anything that uses diff --git a/panda/src/graph/nodeTransition.I b/panda/src/graph/nodeTransition.I index 2c1607ab9e..45e509be0b 100644 --- a/panda/src/graph/nodeTransition.I +++ b/panda/src/graph/nodeTransition.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransition:: +INLINE_GRAPH NodeTransition:: NodeTransition() { _priority = 0; } @@ -18,7 +18,7 @@ NodeTransition() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransition:: +INLINE_GRAPH NodeTransition:: NodeTransition(const NodeTransition ©) : TypedWriteableReferenceCount(copy), _priority(copy._priority) @@ -31,7 +31,7 @@ NodeTransition(const NodeTransition ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeTransition:: +INLINE_GRAPH void NodeTransition:: operator = (const NodeTransition ©) { TypedWriteableReferenceCount::operator = (copy); _priority = copy._priority; @@ -43,7 +43,7 @@ operator = (const NodeTransition ©) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransition:: +INLINE_GRAPH bool NodeTransition:: operator == (const NodeTransition &other) const { return compare_to(other) == 0; } @@ -53,7 +53,7 @@ operator == (const NodeTransition &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransition:: +INLINE_GRAPH bool NodeTransition:: operator != (const NodeTransition &other) const { return compare_to(other) != 0; } @@ -63,7 +63,7 @@ operator != (const NodeTransition &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransition:: +INLINE_GRAPH bool NodeTransition:: operator < (const NodeTransition &other) const { return compare_to(other) < 0; } @@ -73,7 +73,7 @@ operator < (const NodeTransition &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransition:: +INLINE_GRAPH bool NodeTransition:: operator <= (const NodeTransition &other) const { return compare_to(other) <= 0; } @@ -83,7 +83,7 @@ operator <= (const NodeTransition &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransition:: +INLINE_GRAPH bool NodeTransition:: operator > (const NodeTransition &other) const { return compare_to(other) > 0; } @@ -93,7 +93,7 @@ operator > (const NodeTransition &other) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransition:: +INLINE_GRAPH bool NodeTransition:: operator >= (const NodeTransition &other) const { return compare_to(other) >= 0; } @@ -112,7 +112,7 @@ operator >= (const NodeTransition &other) const { // of equivalent transitions together in STL structures // like maps and sets. //////////////////////////////////////////////////////////////////// -INLINE int NodeTransition:: +INLINE_GRAPH int NodeTransition:: compare_to(const NodeTransition &other) const { TypeHandle my_handle = get_handle(); TypeHandle other_handle = other.get_handle(); @@ -136,7 +136,7 @@ compare_to(const NodeTransition &other) const { // The transition will always override transitions with // a lower priority. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransition:: +INLINE_GRAPH void NodeTransition:: set_priority(int priority) { _priority = priority; state_changed(); @@ -147,7 +147,7 @@ set_priority(int priority) { // Access: Public // Description: Returns the priority associated with this transition. //////////////////////////////////////////////////////////////////// -INLINE int NodeTransition:: +INLINE_GRAPH int NodeTransition:: get_priority() const { return _priority; } @@ -161,7 +161,7 @@ get_priority() const { // state changes on the transition will now notify the // arc. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransition:: +INLINE_GRAPH void NodeTransition:: added_to_arc(NodeRelation *arc) { bool inserted = _arcs.insert(arc).second; nassertv(inserted); @@ -176,8 +176,13 @@ added_to_arc(NodeRelation *arc) { // is no longer assigned to the arc. Further state // changes on the transition will *not* notify the arc. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransition:: +INLINE_GRAPH void NodeTransition:: removed_from_arc(NodeRelation *arc) { size_t num_erased = _arcs.erase(arc); nassertv(num_erased == 1); } + +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransition &ntb) { + ntb.output(out); + return out; +} diff --git a/panda/src/graph/nodeTransition.cxx b/panda/src/graph/nodeTransition.cxx index 0364f37510..0e59b034db 100644 --- a/panda/src/graph/nodeTransition.cxx +++ b/panda/src/graph/nodeTransition.cxx @@ -117,4 +117,3 @@ fillin(DatagramIterator& scan, BamReader*) _priority = scan.get_uint16(); } - diff --git a/panda/src/graph/nodeTransition.h b/panda/src/graph/nodeTransition.h index c26afceac1..6d7ad7e344 100644 --- a/panda/src/graph/nodeTransition.h +++ b/panda/src/graph/nodeTransition.h @@ -36,23 +36,23 @@ class DatagramIterator; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA NodeTransition : public TypedWriteableReferenceCount { protected: - INLINE NodeTransition(); - INLINE NodeTransition(const NodeTransition ©); - INLINE void operator = (const NodeTransition ©); + INLINE_GRAPH NodeTransition(); + INLINE_GRAPH NodeTransition(const NodeTransition ©); + INLINE_GRAPH void operator = (const NodeTransition ©); public: - INLINE bool operator == (const NodeTransition &other) const; - INLINE bool operator != (const NodeTransition &other) const; - INLINE bool operator < (const NodeTransition &other) const; - INLINE bool operator <= (const NodeTransition &other) const; - INLINE bool operator > (const NodeTransition &other) const; - INLINE bool operator >= (const NodeTransition &other) const; + INLINE_GRAPH bool operator == (const NodeTransition &other) const; + INLINE_GRAPH bool operator != (const NodeTransition &other) const; + INLINE_GRAPH bool operator < (const NodeTransition &other) const; + INLINE_GRAPH bool operator <= (const NodeTransition &other) const; + INLINE_GRAPH bool operator > (const NodeTransition &other) const; + INLINE_GRAPH bool operator >= (const NodeTransition &other) const; - INLINE int compare_to(const NodeTransition &other) const; + INLINE_GRAPH int compare_to(const NodeTransition &other) const; PUBLISHED: - INLINE void set_priority(int priority); - INLINE int get_priority() const; + INLINE_GRAPH void set_priority(int priority); + INLINE_GRAPH int get_priority() const; public: virtual NodeTransition *make_copy() const=0; @@ -86,8 +86,8 @@ public: // These functions will be called by the arcs when appropriate. // Don't attempt to call them directly; they're public only to make // it convenient to call them from non-class template functions. - INLINE void added_to_arc(NodeRelation *arc); - INLINE void removed_from_arc(NodeRelation *arc); + INLINE_GRAPH void added_to_arc(NodeRelation *arc); + INLINE_GRAPH void removed_from_arc(NodeRelation *arc); protected: int _priority; @@ -124,11 +124,10 @@ private: friend class NodeTransitionCache; }; -INLINE ostream &operator << (ostream &out, const NodeTransition &ntb) { - ntb.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransition &ntb); +#ifdef BUILDING_PANDA #include "nodeTransition.I" +#endif #endif diff --git a/panda/src/graph/nodeTransitionCache.I b/panda/src/graph/nodeTransitionCache.I index 2aff26660a..d0fcc55c9b 100644 --- a/panda/src/graph/nodeTransitionCache.I +++ b/panda/src/graph/nodeTransitionCache.I @@ -14,7 +14,7 @@ // set_transition; if the pointer might be NULL, use the // above flavor instead (or just call clear_transition). //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) NodeTransitionCache:: +INLINE_GRAPH PT(NodeTransition) NodeTransitionCache:: set_transition(NodeTransition *trans) { nassertr(trans != (NodeTransition *)NULL, NULL); nassertr(trans->get_handle() != TypeHandle::none(), NULL); @@ -26,7 +26,7 @@ set_transition(NodeTransition *trans) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCache::size_type NodeTransitionCache:: +INLINE_GRAPH NodeTransitionCache::size_type NodeTransitionCache:: size() const { return _cache.size(); } @@ -36,7 +36,7 @@ size() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCache::const_iterator NodeTransitionCache:: +INLINE_GRAPH NodeTransitionCache::const_iterator NodeTransitionCache:: begin() const { return _cache.begin(); } @@ -46,7 +46,12 @@ begin() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCache::const_iterator NodeTransitionCache:: +INLINE_GRAPH NodeTransitionCache::const_iterator NodeTransitionCache:: end() const { return _cache.end(); } + +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionCache &ntc) { + ntc.output(out); + return out; +} diff --git a/panda/src/graph/nodeTransitionCache.h b/panda/src/graph/nodeTransitionCache.h index 8cb22b5336..5660ef5e29 100644 --- a/panda/src/graph/nodeTransitionCache.h +++ b/panda/src/graph/nodeTransitionCache.h @@ -31,7 +31,7 @@ public: bool is_empty() const; PT(NodeTransition) set_transition(TypeHandle handle, NodeTransition *trans); - INLINE PT(NodeTransition) set_transition(NodeTransition *trans); + INLINE_GRAPH PT(NodeTransition) set_transition(NodeTransition *trans); PT(NodeTransition) clear_transition(TypeHandle handle); bool has_transition(TypeHandle handle) const; NodeTransition *get_transition(TypeHandle handle) const; @@ -56,9 +56,9 @@ public: typedef Cache::value_type value_type; typedef Cache::size_type size_type; - INLINE size_type size() const; - INLINE const_iterator begin() const; - INLINE const_iterator end() const; + INLINE_GRAPH size_type size() const; + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; public: @@ -100,11 +100,10 @@ private: friend class NodeAttributes; }; -INLINE ostream &operator << (ostream &out, const NodeTransitionCache &ntc) { - ntc.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionCache &ntc); +#ifdef BUILDING_PANDA #include "nodeTransitionCache.I" +#endif #endif diff --git a/panda/src/graph/nodeTransitionCacheEntry.I b/panda/src/graph/nodeTransitionCacheEntry.I index 45d256d710..75feb73d1c 100644 --- a/panda/src/graph/nodeTransitionCacheEntry.I +++ b/panda/src/graph/nodeTransitionCacheEntry.I @@ -10,7 +10,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry:: NodeTransitionCacheEntry(NodeTransition *trans) : _trans(trans) { } @@ -19,7 +19,7 @@ NodeTransitionCacheEntry(NodeTransition *trans) : _trans(trans) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry:: NodeTransitionCacheEntry(const NodeTransitionCacheEntry ©) : _trans(copy._trans), _computed(copy._computed), @@ -32,7 +32,7 @@ NodeTransitionCacheEntry(const NodeTransitionCacheEntry ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionCacheEntry:: +INLINE_GRAPH void NodeTransitionCacheEntry:: operator = (const NodeTransitionCacheEntry ©) { _trans = copy._trans; _computed = copy._computed; @@ -44,7 +44,7 @@ operator = (const NodeTransitionCacheEntry ©) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionCacheEntry:: +INLINE_GRAPH bool NodeTransitionCacheEntry:: is_identity() const { return (_trans == (NodeTransition *)NULL); // || _trans->is_identity(); @@ -55,7 +55,7 @@ is_identity() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int NodeTransitionCacheEntry:: +INLINE_GRAPH int NodeTransitionCacheEntry:: compare_to(const NodeTransitionCacheEntry &other) const { bool this_ident = is_identity(); bool other_ident = other.is_identity(); @@ -81,7 +81,7 @@ compare_to(const NodeTransitionCacheEntry &other) const { // Access: Public // Description: Reinitializes the cache entry to its original state. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionCacheEntry:: +INLINE_GRAPH void NodeTransitionCacheEntry:: clear() { _trans.clear(); _computed.clear(); @@ -94,7 +94,7 @@ clear() { // Description: Changes the transition associated with the cache // entry without changing the associated time stamps. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionCacheEntry:: +INLINE_GRAPH void NodeTransitionCacheEntry:: set_trans(NodeTransition *trans) { _trans = trans; } @@ -106,7 +106,7 @@ set_trans(NodeTransition *trans) { // entry without changing the associated time stamps. // This is of limited usefulness. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionCacheEntry:: +INLINE_GRAPH void NodeTransitionCacheEntry:: clear_trans() { _trans.clear(); } @@ -118,7 +118,7 @@ clear_trans() { // NodeTransition, false if it doesn't (and the // transition should be assumed to be identity). //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionCacheEntry:: +INLINE_GRAPH bool NodeTransitionCacheEntry:: has_trans() const { return _trans != (NodeTransition *)NULL; } @@ -131,7 +131,7 @@ has_trans() const { // NodeTransition (in which case it should be assumed to // be identity). //////////////////////////////////////////////////////////////////// -INLINE NodeTransition *NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransition *NodeTransitionCacheEntry:: get_trans() const { return _trans; } @@ -141,7 +141,7 @@ get_trans() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionCacheEntry:: +INLINE_GRAPH bool NodeTransitionCacheEntry:: is_cache_verified(UpdateSeq as_of) const { #ifndef NDEBUG if (wrt_cat.is_spam()) { @@ -159,7 +159,7 @@ is_cache_verified(UpdateSeq as_of) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionCacheEntry:: +INLINE_GRAPH bool NodeTransitionCacheEntry:: is_freshly_computed(UpdateSeq changed) const { return changed < _computed; } @@ -169,7 +169,7 @@ is_freshly_computed(UpdateSeq changed) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionCacheEntry:: +INLINE_GRAPH void NodeTransitionCacheEntry:: set_computed_verified(UpdateSeq now) { _computed = now; _verified = now; @@ -184,7 +184,7 @@ set_computed_verified(UpdateSeq now) { // setTransitionHelpers.h interchangeably between // NodeTransitions and NodeTransitionCaches. //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry:: operator const PT(NodeTransition) &() const { return _trans; } @@ -195,7 +195,7 @@ operator const PT(NodeTransition) &() const { // Description: Returns the timestamp at which this cache entry was // computed. //////////////////////////////////////////////////////////////////// -INLINE UpdateSeq NodeTransitionCacheEntry:: +INLINE_GRAPH UpdateSeq NodeTransitionCacheEntry:: get_computed() const { return _computed; } @@ -207,7 +207,7 @@ get_computed() const { // was verified; i.e. when the graph was last walked up // to the root to ensure the cache entry is still valid. //////////////////////////////////////////////////////////////////// -INLINE UpdateSeq NodeTransitionCacheEntry:: +INLINE_GRAPH UpdateSeq NodeTransitionCacheEntry:: get_verified() const { return _verified; } @@ -218,7 +218,7 @@ get_verified() const { // Description: Returns a new cache entry that represents the inverse // of a. //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry NodeTransitionCacheEntry:: invert(const NodeTransitionCacheEntry &a) { if (a.is_identity()) { return a; @@ -232,7 +232,7 @@ invert(const NodeTransitionCacheEntry &a) { // Description: Returns a new cache entry that represents the // composition of a and b. //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry NodeTransitionCacheEntry:: compose(const NodeTransitionCacheEntry &a, const NodeTransitionCacheEntry &b) { if (a.is_identity()) { @@ -250,7 +250,7 @@ compose(const NodeTransitionCacheEntry &a, // Description: Returns a new cache entry that represents the // composition of invert(a) and b. //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry NodeTransitionCacheEntry:: invert_compose(const NodeTransitionCacheEntry &a, const NodeTransitionCacheEntry &b) { if (a.is_identity()) { @@ -286,7 +286,7 @@ invert_compose(const NodeTransitionCacheEntry &a, // as computed using the cache value as a hint. Mark // the result as computed at time 'now'. //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionCacheEntry NodeTransitionCacheEntry:: +INLINE_GRAPH NodeTransitionCacheEntry NodeTransitionCacheEntry:: cached_compose(const NodeTransitionCacheEntry &a, const NodeTransitionCacheEntry &cache, const NodeTransitionCacheEntry &b, @@ -339,7 +339,7 @@ cached_compose(const NodeTransitionCacheEntry &a, // NodeAttribute) that represents the indicated // transition applied to the attribute. //////////////////////////////////////////////////////////////////// -INLINE NodeAttribute *NodeTransitionCacheEntry:: +INLINE_GRAPH NodeAttribute *NodeTransitionCacheEntry:: apply(const NodeAttribute *a, const NodeTransitionCacheEntry &b) { if (b.is_identity()) { return (NodeAttribute *)a; @@ -353,10 +353,15 @@ apply(const NodeAttribute *a, const NodeTransitionCacheEntry &b) { // Access: Public, Static // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeAttribute *NodeTransitionCacheEntry:: +INLINE_GRAPH NodeAttribute *NodeTransitionCacheEntry:: make_attrib() const { if (_trans == (NodeTransition *)NULL) { return NULL; } return _trans->make_attrib(); } + +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionCacheEntry &e) { + e.output(out); + return out; +} diff --git a/panda/src/graph/nodeTransitionCacheEntry.h b/panda/src/graph/nodeTransitionCacheEntry.h index dea7b7a8fe..bd8f1e2771 100644 --- a/panda/src/graph/nodeTransitionCacheEntry.h +++ b/panda/src/graph/nodeTransitionCacheEntry.h @@ -22,28 +22,28 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA NodeTransitionCacheEntry { public: - INLINE NodeTransitionCacheEntry(NodeTransition *trans = NULL); - INLINE NodeTransitionCacheEntry(const NodeTransitionCacheEntry ©); - INLINE void operator = (const NodeTransitionCacheEntry ©); + INLINE_GRAPH NodeTransitionCacheEntry(NodeTransition *trans = NULL); + INLINE_GRAPH NodeTransitionCacheEntry(const NodeTransitionCacheEntry ©); + INLINE_GRAPH void operator = (const NodeTransitionCacheEntry ©); - INLINE bool is_identity() const; - INLINE int compare_to(const NodeTransitionCacheEntry &other) const; + INLINE_GRAPH bool is_identity() const; + INLINE_GRAPH int compare_to(const NodeTransitionCacheEntry &other) const; - INLINE void clear(); + INLINE_GRAPH void clear(); - INLINE void set_trans(NodeTransition *trans); - INLINE void clear_trans(); - INLINE bool has_trans() const; - INLINE NodeTransition *get_trans() const; + INLINE_GRAPH void set_trans(NodeTransition *trans); + INLINE_GRAPH void clear_trans(); + INLINE_GRAPH bool has_trans() const; + INLINE_GRAPH NodeTransition *get_trans() const; - INLINE bool is_cache_verified(UpdateSeq as_of) const; - INLINE bool is_freshly_computed(UpdateSeq changed) const; - INLINE void set_computed_verified(UpdateSeq now); + INLINE_GRAPH bool is_cache_verified(UpdateSeq as_of) const; + INLINE_GRAPH bool is_freshly_computed(UpdateSeq changed) const; + INLINE_GRAPH void set_computed_verified(UpdateSeq now); - INLINE operator const PT(NodeTransition) &() const; + INLINE_GRAPH operator const PT(NodeTransition) &() const; - INLINE UpdateSeq get_computed() const; - INLINE UpdateSeq get_verified() const; + INLINE_GRAPH UpdateSeq get_computed() const; + INLINE_GRAPH UpdateSeq get_verified() const; public: // The following functions perform the basic transition operations @@ -51,27 +51,27 @@ public: // keep the _computed and _verified members consistent across these // operations. - INLINE static NodeTransitionCacheEntry + INLINE_GRAPH static NodeTransitionCacheEntry invert(const NodeTransitionCacheEntry &a); - INLINE static NodeTransitionCacheEntry + INLINE_GRAPH static NodeTransitionCacheEntry compose(const NodeTransitionCacheEntry &a, const NodeTransitionCacheEntry &b); - INLINE static NodeTransitionCacheEntry + INLINE_GRAPH static NodeTransitionCacheEntry invert_compose(const NodeTransitionCacheEntry &a, const NodeTransitionCacheEntry &b); - INLINE static NodeTransitionCacheEntry + INLINE_GRAPH static NodeTransitionCacheEntry cached_compose(const NodeTransitionCacheEntry &a, const NodeTransitionCacheEntry &cache, const NodeTransitionCacheEntry &b, UpdateSeq now); - INLINE static NodeAttribute * + INLINE_GRAPH static NodeAttribute * apply(const NodeAttribute *a, const NodeTransitionCacheEntry &b); - INLINE NodeAttribute *make_attrib() const; + INLINE_GRAPH NodeAttribute *make_attrib() const; public: void output(ostream &out) const; @@ -83,11 +83,10 @@ private: UpdateSeq _verified; }; -INLINE ostream &operator << (ostream &out, const NodeTransitionCacheEntry &e) { - e.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionCacheEntry &e); +#ifdef BUILDING_PANDA #include "nodeTransitionCacheEntry.I" +#endif #endif diff --git a/panda/src/graph/nodeTransitionWrapper.I b/panda/src/graph/nodeTransitionWrapper.I index f449cd42ac..685644ada0 100644 --- a/panda/src/graph/nodeTransitionWrapper.I +++ b/panda/src/graph/nodeTransitionWrapper.I @@ -11,7 +11,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionWrapper:: +INLINE_GRAPH NodeTransitionWrapper:: NodeTransitionWrapper(TypeHandle handle) : _handle(handle) { nassertv(_handle != TypeHandle::none()); } @@ -21,7 +21,7 @@ NodeTransitionWrapper(TypeHandle handle) : _handle(handle) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionWrapper:: +INLINE_GRAPH NodeTransitionWrapper:: NodeTransitionWrapper(const NodeTransitionWrapper ©) : _handle(copy._handle), _entry(copy._entry) @@ -33,7 +33,7 @@ NodeTransitionWrapper(const NodeTransitionWrapper ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: operator = (const NodeTransitionWrapper ©) { _handle = copy._handle; _entry = copy._entry; @@ -46,7 +46,7 @@ operator = (const NodeTransitionWrapper ©) { // NodeTransitionWrapper ready to access the same type // of NodeTransition as the other. //////////////////////////////////////////////////////////////////// -INLINE NodeTransitionWrapper NodeTransitionWrapper:: +INLINE_GRAPH NodeTransitionWrapper NodeTransitionWrapper:: init_from(const NodeTransitionWrapper &other) { return NodeTransitionWrapper(other._handle); } @@ -56,7 +56,7 @@ init_from(const NodeTransitionWrapper &other) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE TypeHandle NodeTransitionWrapper:: +INLINE_GRAPH TypeHandle NodeTransitionWrapper:: get_handle() const { return _handle; } @@ -66,7 +66,7 @@ get_handle() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionWrapper:: +INLINE_GRAPH bool NodeTransitionWrapper:: has_trans() const { return _entry.has_trans(); } @@ -76,7 +76,7 @@ has_trans() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransition *NodeTransitionWrapper:: +INLINE_GRAPH NodeTransition *NodeTransitionWrapper:: get_trans() const { return _entry.get_trans(); } @@ -87,7 +87,7 @@ get_trans() const { // Description: Returns true if the wrapper represents an identity // transition. //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionWrapper:: +INLINE_GRAPH bool NodeTransitionWrapper:: is_identity() const { return _entry.is_identity(); } @@ -97,7 +97,7 @@ is_identity() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int NodeTransitionWrapper:: +INLINE_GRAPH int NodeTransitionWrapper:: compare_to(const NodeTransitionWrapper &other) const { return _entry.compare_to(other._entry); } @@ -107,7 +107,7 @@ compare_to(const NodeTransitionWrapper &other) const { // Access: Public // Description: Resets the wrapper to the identity transition. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: make_identity() { _entry.clear_trans(); } @@ -118,7 +118,7 @@ make_identity() { // Description: Sets the wrapper to the transition contained on the // arc. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: extract_from(const NodeRelation *arc) { nassertv(arc != (NodeRelation *)NULL); nassertv(_handle != TypeHandle::none()); @@ -130,7 +130,7 @@ extract_from(const NodeRelation *arc) { // Access: Public // Description: Stores the transition in the wrapper to the arc. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: store_to(NodeRelation *arc) const { nassertv(arc != (NodeRelation *)NULL); arc->set_transition(_handle, _entry.get_trans()); @@ -142,7 +142,7 @@ store_to(NodeRelation *arc) const { // Description: Sets this transition to the composition of this // transition and the following one. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: compose_in_place(const NodeTransitionWrapper &other) { nassertv(_handle == other._handle); _entry = NodeTransitionCacheEntry::compose(_entry, other._entry); @@ -153,7 +153,7 @@ compose_in_place(const NodeTransitionWrapper &other) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: invert_in_place() { _entry = NodeTransitionCacheEntry::invert(_entry); } @@ -164,7 +164,7 @@ invert_in_place() { // Description: Sets this transition to the composition of this // transition and the following one. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: invert_compose_in_place(const NodeTransitionWrapper &other) { _entry = NodeTransitionCacheEntry::invert_compose(_entry, other._entry); } @@ -176,7 +176,7 @@ invert_compose_in_place(const NodeTransitionWrapper &other) { // cache on the arc. Also returns the arc's top_subtree // indication. //////////////////////////////////////////////////////////////////// -INLINE Node *NodeTransitionWrapper:: +INLINE_GRAPH Node *NodeTransitionWrapper:: extract_from_cache(const NodeRelation *arc) { nassertr(_handle != TypeHandle::none(), NULL); @@ -194,7 +194,7 @@ extract_from_cache(const NodeRelation *arc) { // Description: Stores this transition into the arc's cache, and // updates the arc's top_subtree. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: store_to_cache(NodeRelation *arc, Node *top_subtree) { arc->_top_subtree = top_subtree; if (arc->_net_transitions == (NodeTransitionCache *)NULL) { @@ -213,7 +213,7 @@ store_to_cache(NodeRelation *arc, Node *top_subtree) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NodeTransitionWrapper:: +INLINE_GRAPH bool NodeTransitionWrapper:: is_cache_verified(UpdateSeq as_of) const { return _entry.is_cache_verified(as_of); } @@ -223,7 +223,7 @@ is_cache_verified(UpdateSeq as_of) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: set_computed_verified(UpdateSeq now) { _entry.set_computed_verified(now); } @@ -235,7 +235,7 @@ set_computed_verified(UpdateSeq now) { // that indicated by value, using the cache as a helper, // and stores the result in this wrapper. //////////////////////////////////////////////////////////////////// -INLINE void NodeTransitionWrapper:: +INLINE_GRAPH void NodeTransitionWrapper:: cached_compose(const NodeTransitionWrapper &cache, const NodeTransitionWrapper &value, UpdateSeq now) { @@ -244,25 +244,7 @@ cached_compose(const NodeTransitionWrapper &cache, value._entry, now); } -//////////////////////////////////////////////////////////////////// -// Function: get_transition_into -// Description: This external template function is handy for -// extracting the transition (of a known type) from the -// wrapper. If the transition exists, it is -// automatically downcasted to the correct type and -// stored in the pointer given in the first parameter, -// and the return value is true. If the transition does -// not exist, the pointer is filled with NULL and the -// return value is false. -//////////////////////////////////////////////////////////////////// -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeTransitionWrapper &trans) { - NodeTransition *nt = trans.get_trans(); - if (nt == (NodeTransition *)NULL) { - ptr = (Transition *)NULL; - return false; - } - DCAST_INTO_R(ptr, nt, false); - return true; +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionWrapper &ntw) { + ntw.output(out); + return out; } diff --git a/panda/src/graph/nodeTransitionWrapper.T b/panda/src/graph/nodeTransitionWrapper.T new file mode 100644 index 0000000000..28074673b3 --- /dev/null +++ b/panda/src/graph/nodeTransitionWrapper.T @@ -0,0 +1,27 @@ +// Filename: nodeTransitionWrapper.T +// Created by: drose (20Mar00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: get_transition_into +// Description: This external template function is handy for +// extracting the transition (of a known type) from the +// wrapper. If the transition exists, it is +// automatically downcasted to the correct type and +// stored in the pointer given in the first parameter, +// and the return value is true. If the transition does +// not exist, the pointer is filled with NULL and the +// return value is false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const NodeTransitionWrapper &trans) { + NodeTransition *nt = trans.get_trans(); + if (nt == (NodeTransition *)NULL) { + ptr = (Transition *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} diff --git a/panda/src/graph/nodeTransitionWrapper.h b/panda/src/graph/nodeTransitionWrapper.h index 8f10da51c7..135f0d54b0 100644 --- a/panda/src/graph/nodeTransitionWrapper.h +++ b/panda/src/graph/nodeTransitionWrapper.h @@ -41,35 +41,35 @@ public: typedef NodeTransitionWrapper TransitionWrapper; typedef NodeAttributeWrapper AttributeWrapper; - INLINE NodeTransitionWrapper(TypeHandle handle); - INLINE NodeTransitionWrapper(const NodeTransitionWrapper ©); - INLINE void operator = (const NodeTransitionWrapper ©); + INLINE_GRAPH NodeTransitionWrapper(TypeHandle handle); + INLINE_GRAPH NodeTransitionWrapper(const NodeTransitionWrapper ©); + INLINE_GRAPH void operator = (const NodeTransitionWrapper ©); - INLINE static NodeTransitionWrapper + INLINE_GRAPH static NodeTransitionWrapper init_from(const NodeTransitionWrapper &other); static NodeTransitionWrapper init_from(const NodeAttributeWrapper &attrib); - INLINE TypeHandle get_handle() const; - INLINE bool has_trans() const; - INLINE NodeTransition *get_trans() const; + INLINE_GRAPH TypeHandle get_handle() const; + INLINE_GRAPH bool has_trans() const; + INLINE_GRAPH NodeTransition *get_trans() const; - INLINE bool is_identity() const; - INLINE int compare_to(const NodeTransitionWrapper &other) const; + INLINE_GRAPH bool is_identity() const; + INLINE_GRAPH int compare_to(const NodeTransitionWrapper &other) const; - INLINE void make_identity(); - INLINE void extract_from(const NodeRelation *arc); - INLINE void store_to(NodeRelation *arc) const; + INLINE_GRAPH void make_identity(); + INLINE_GRAPH void extract_from(const NodeRelation *arc); + INLINE_GRAPH void store_to(NodeRelation *arc) const; - INLINE void compose_in_place(const NodeTransitionWrapper &other); - INLINE void invert_in_place(); - INLINE void invert_compose_in_place(const NodeTransitionWrapper &other); + INLINE_GRAPH void compose_in_place(const NodeTransitionWrapper &other); + INLINE_GRAPH void invert_in_place(); + INLINE_GRAPH void invert_compose_in_place(const NodeTransitionWrapper &other); - INLINE Node *extract_from_cache(const NodeRelation *arc); - INLINE void store_to_cache(NodeRelation *arc, Node *top_subtree); - INLINE bool is_cache_verified(UpdateSeq as_of) const; - INLINE void set_computed_verified(UpdateSeq now); + INLINE_GRAPH Node *extract_from_cache(const NodeRelation *arc); + INLINE_GRAPH void store_to_cache(NodeRelation *arc, Node *top_subtree); + INLINE_GRAPH bool is_cache_verified(UpdateSeq as_of) const; + INLINE_GRAPH void set_computed_verified(UpdateSeq now); - INLINE void cached_compose(const NodeTransitionWrapper &cache, + INLINE_GRAPH void cached_compose(const NodeTransitionWrapper &cache, const NodeTransitionWrapper &value, UpdateSeq now); @@ -79,18 +79,15 @@ public: private: TypeHandle _handle; NodeTransitionCacheEntry _entry; -friend class NodeAttributeWrapper; + friend class NodeAttributeWrapper; }; -INLINE ostream &operator << (ostream &out, const NodeTransitionWrapper &ntw) { - ntw.output(out); - return out; -} - -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeTransitionWrapper &trans); +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitionWrapper &ntw); +#ifdef BUILDING_PANDA #include "nodeTransitionWrapper.I" +#endif + +#include "nodeTransitionWrapper.T" #endif diff --git a/panda/src/graph/nodeTransitions.I b/panda/src/graph/nodeTransitions.I index ba0721cabd..5e3048e011 100644 --- a/panda/src/graph/nodeTransitions.I +++ b/panda/src/graph/nodeTransitions.I @@ -13,7 +13,7 @@ // set_transition; if the pointer might be NULL, use the // above flavor instead (or just call clear_transition). //////////////////////////////////////////////////////////////////// -INLINE PT(NodeTransition) NodeTransitions:: +INLINE_GRAPH PT(NodeTransition) NodeTransitions:: set_transition(NodeTransition *trans) { nassertr(trans != (NodeTransition *)NULL, NULL); nassertr(trans->get_handle() != TypeHandle::none(), NULL); @@ -25,7 +25,7 @@ set_transition(NodeTransition *trans) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitions::size_type NodeTransitions:: +INLINE_GRAPH NodeTransitions::size_type NodeTransitions:: size() const { return _transitions.size(); } @@ -35,7 +35,7 @@ size() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitions::const_iterator NodeTransitions:: +INLINE_GRAPH NodeTransitions::const_iterator NodeTransitions:: begin() const { return _transitions.begin(); } @@ -45,7 +45,7 @@ begin() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NodeTransitions::const_iterator NodeTransitions:: +INLINE_GRAPH NodeTransitions::const_iterator NodeTransitions:: end() const { return _transitions.end(); } @@ -62,7 +62,7 @@ end() const { // false. //////////////////////////////////////////////////////////////////// template -INLINE bool +INLINE_GRAPH bool get_transition_into(Transition *&ptr, const NodeTransitions &trans, TypeHandle transition_type) { NodeTransition *nt = trans.get_transition(transition_type); @@ -75,7 +75,12 @@ get_transition_into(Transition *&ptr, const NodeTransitions &trans, } template -INLINE bool +INLINE_GRAPH bool get_transition_into(Transition *&ptr, const NodeTransitions &trans) { return get_transition_into(ptr, trans, Transition::get_class_type()); } + +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitions &nts) { + nts.output(out); + return out; +} diff --git a/panda/src/graph/nodeTransitions.T b/panda/src/graph/nodeTransitions.T new file mode 100644 index 0000000000..fe45a25dae --- /dev/null +++ b/panda/src/graph/nodeTransitions.T @@ -0,0 +1,34 @@ +// Filename: nodeTransitions.I +// Created by: drose (20Mar00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: get_transition_into +// Description: This external template function is handy for +// extracting a transition of a particular type from the +// set. If the transition exists, it is automatically +// downcasted to the correct type and stored in the +// pointer given in the first parameter, and the return +// value is true. If the transition does not exist, the +// pointer is filled with NULL and the return value is +// false. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const NodeTransitions &trans, + TypeHandle transition_type) { + NodeTransition *nt = trans.get_transition(transition_type); + if (nt == (NodeTransition *)NULL) { + ptr = (Transition *)NULL; + return false; + } + DCAST_INTO_R(ptr, nt, false); + return true; +} + +template +INLINE_GRAPH bool +get_transition_into(Transition *&ptr, const NodeTransitions &trans) { + return get_transition_into(ptr, trans, Transition::get_class_type()); +} diff --git a/panda/src/graph/nodeTransitions.h b/panda/src/graph/nodeTransitions.h index d6812b0126..c514abfb81 100644 --- a/panda/src/graph/nodeTransitions.h +++ b/panda/src/graph/nodeTransitions.h @@ -31,7 +31,7 @@ public: bool is_empty() const; PT(NodeTransition) set_transition(TypeHandle handle, NodeTransition *trans); - INLINE PT(NodeTransition) set_transition(NodeTransition *trans); + INLINE_GRAPH PT(NodeTransition) set_transition(NodeTransition *trans); PT(NodeTransition) clear_transition(TypeHandle handle); bool has_transition(TypeHandle handle) const; NodeTransition *get_transition(TypeHandle handle) const; @@ -60,9 +60,9 @@ public: typedef Transitions::value_type value_type; typedef Transitions::size_type size_type; - INLINE size_type size() const; - INLINE const_iterator begin() const; - INLINE const_iterator end() const; + INLINE_GRAPH size_type size() const; + INLINE_GRAPH const_iterator begin() const; + INLINE_GRAPH const_iterator end() const; public: void output(ostream &out) const; @@ -73,20 +73,10 @@ private: friend class NodeTransitionCache; }; -INLINE ostream &operator << (ostream &out, const NodeTransitions &nts) { - nts.output(out); - return out; -} - -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeTransitions &trans, - TypeHandle transition_type); - -template -INLINE bool -get_transition_into(Transition *&ptr, const NodeTransitions &trans); +INLINE_GRAPH ostream &operator << (ostream &out, const NodeTransitions &nts); +#ifdef BUILDING_PANDA #include "nodeTransitions.I" +#endif #endif diff --git a/panda/src/graph/nullAttributeWrapper.I b/panda/src/graph/nullAttributeWrapper.I index a2b448ecd7..972fe8109c 100644 --- a/panda/src/graph/nullAttributeWrapper.I +++ b/panda/src/graph/nullAttributeWrapper.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NullAttributeWrapper:: +INLINE_GRAPH NullAttributeWrapper:: NullAttributeWrapper() { } @@ -17,7 +17,7 @@ NullAttributeWrapper() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NullAttributeWrapper:: +INLINE_GRAPH NullAttributeWrapper:: NullAttributeWrapper(const NullAttributeWrapper &) { } @@ -26,7 +26,7 @@ NullAttributeWrapper(const NullAttributeWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullAttributeWrapper:: +INLINE_GRAPH void NullAttributeWrapper:: operator = (const NullAttributeWrapper &) { } @@ -35,7 +35,7 @@ operator = (const NullAttributeWrapper &) { // Access: Public, Static // Description: //////////////////////////////////////////////////////////////////// -INLINE NullAttributeWrapper NullAttributeWrapper:: +INLINE_GRAPH NullAttributeWrapper NullAttributeWrapper:: init_from(const NullTransitionWrapper &) { return NullAttributeWrapper(); } @@ -45,7 +45,7 @@ init_from(const NullTransitionWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NullAttributeWrapper:: +INLINE_GRAPH bool NullAttributeWrapper:: is_initial() const { return true; } @@ -55,7 +55,7 @@ is_initial() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int NullAttributeWrapper:: +INLINE_GRAPH int NullAttributeWrapper:: compare_to(const NullAttributeWrapper &) const { return 0; } @@ -65,7 +65,7 @@ compare_to(const NullAttributeWrapper &) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullAttributeWrapper:: +INLINE_GRAPH void NullAttributeWrapper:: make_initial() { } @@ -74,7 +74,7 @@ make_initial() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullAttributeWrapper:: +INLINE_GRAPH void NullAttributeWrapper:: apply_in_place(const NullTransitionWrapper &) { } @@ -83,7 +83,7 @@ apply_in_place(const NullTransitionWrapper &) { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullAttributeWrapper:: +INLINE_GRAPH void NullAttributeWrapper:: output(ostream &) const { } @@ -92,6 +92,12 @@ output(ostream &) const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullAttributeWrapper:: +INLINE_GRAPH void NullAttributeWrapper:: write(ostream &, int) const { } + +INLINE_GRAPH ostream &operator << (ostream &out, const NullAttributeWrapper &naw) { + naw.output(out); + return out; +} + diff --git a/panda/src/graph/nullAttributeWrapper.h b/panda/src/graph/nullAttributeWrapper.h index 19b2d8eb51..837955b4f5 100644 --- a/panda/src/graph/nullAttributeWrapper.h +++ b/panda/src/graph/nullAttributeWrapper.h @@ -24,27 +24,26 @@ public: typedef NullTransitionWrapper TransitionWrapper; typedef NullAttributeWrapper AttributeWrapper; - INLINE NullAttributeWrapper(); - INLINE NullAttributeWrapper(const NullAttributeWrapper ©); - INLINE void operator = (const NullAttributeWrapper ©); - INLINE static NullAttributeWrapper + INLINE_GRAPH NullAttributeWrapper(); + INLINE_GRAPH NullAttributeWrapper(const NullAttributeWrapper ©); + INLINE_GRAPH void operator = (const NullAttributeWrapper ©); + INLINE_GRAPH static NullAttributeWrapper init_from(const NullTransitionWrapper &trans); - INLINE bool is_initial() const; - INLINE int compare_to(const NullAttributeWrapper &other) const; + INLINE_GRAPH bool is_initial() const; + INLINE_GRAPH int compare_to(const NullAttributeWrapper &other) const; - INLINE void make_initial(); - INLINE void apply_in_place(const NullTransitionWrapper &trans); + INLINE_GRAPH void make_initial(); + INLINE_GRAPH void apply_in_place(const NullTransitionWrapper &trans); - INLINE void output(ostream &out) const; - INLINE void write(ostream &out, int indent_level = 0) const; + INLINE_GRAPH void output(ostream &out) const; + INLINE_GRAPH void write(ostream &out, int indent_level = 0) const; }; -INLINE ostream &operator << (ostream &out, const NullAttributeWrapper &naw) { - naw.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NullAttributeWrapper &naw); +#ifdef BUILDING_PANDA #include "nullAttributeWrapper.I" +#endif #endif diff --git a/panda/src/graph/nullLevelState.h b/panda/src/graph/nullLevelState.h index 8d71a3524c..01e63ba372 100644 --- a/panda/src/graph/nullLevelState.h +++ b/panda/src/graph/nullLevelState.h @@ -16,9 +16,9 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA NullLevelState { public: - INLINE NullLevelState() { } - INLINE NullLevelState(const NullLevelState &) { } - INLINE void operator = (const NullLevelState &) { } + INLINE_GRAPH NullLevelState() { } + INLINE_GRAPH NullLevelState(const NullLevelState &) { } + INLINE_GRAPH void operator = (const NullLevelState &) { } }; #endif diff --git a/panda/src/graph/nullTransitionWrapper.I b/panda/src/graph/nullTransitionWrapper.I index 283cedc4b1..83a39e7f1b 100644 --- a/panda/src/graph/nullTransitionWrapper.I +++ b/panda/src/graph/nullTransitionWrapper.I @@ -11,7 +11,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NullTransitionWrapper:: +INLINE_GRAPH NullTransitionWrapper:: NullTransitionWrapper() { } @@ -20,7 +20,7 @@ NullTransitionWrapper() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE NullTransitionWrapper:: +INLINE_GRAPH NullTransitionWrapper:: NullTransitionWrapper(const NullTransitionWrapper &) { } @@ -29,7 +29,7 @@ NullTransitionWrapper(const NullTransitionWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: operator = (const NullTransitionWrapper &) { } @@ -38,7 +38,7 @@ operator = (const NullTransitionWrapper &) { // Access: Public, Static // Description: //////////////////////////////////////////////////////////////////// -INLINE NullTransitionWrapper NullTransitionWrapper:: +INLINE_GRAPH NullTransitionWrapper NullTransitionWrapper:: init_from(const NullTransitionWrapper &) { return NullTransitionWrapper(); } @@ -48,7 +48,7 @@ init_from(const NullTransitionWrapper &) { // Access: Public, Static // Description: //////////////////////////////////////////////////////////////////// -INLINE NullTransitionWrapper NullTransitionWrapper:: +INLINE_GRAPH NullTransitionWrapper NullTransitionWrapper:: init_from(const NullAttributeWrapper &) { return NullTransitionWrapper(); } @@ -58,7 +58,7 @@ init_from(const NullAttributeWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NullTransitionWrapper:: +INLINE_GRAPH bool NullTransitionWrapper:: is_identity() const { return true; } @@ -68,7 +68,7 @@ is_identity() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE int NullTransitionWrapper:: +INLINE_GRAPH int NullTransitionWrapper:: compare_to(const NullTransitionWrapper &) const { return 0; } @@ -78,7 +78,7 @@ compare_to(const NullTransitionWrapper &) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: make_identity() { } @@ -87,7 +87,7 @@ make_identity() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: extract_from(const NodeRelation *) { } @@ -96,7 +96,7 @@ extract_from(const NodeRelation *) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: store_to(NodeRelation *) const { } @@ -105,7 +105,7 @@ store_to(NodeRelation *) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: compose_in_place(const NullTransitionWrapper &) { } @@ -114,7 +114,7 @@ compose_in_place(const NullTransitionWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: invert_in_place() { } @@ -123,7 +123,7 @@ invert_in_place() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: invert_compose_in_place(const NullTransitionWrapper &) { } @@ -132,7 +132,7 @@ invert_compose_in_place(const NullTransitionWrapper &) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE Node *NullTransitionWrapper:: +INLINE_GRAPH Node *NullTransitionWrapper:: extract_from_cache(const NodeRelation *) { return NULL; } @@ -143,7 +143,7 @@ extract_from_cache(const NodeRelation *) { // Description: Stores this transition into the arc's cache, and // updates the arc's top_subtree. //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: store_to_cache(NodeRelation *, Node *) { } @@ -152,7 +152,7 @@ store_to_cache(NodeRelation *, Node *) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE bool NullTransitionWrapper:: +INLINE_GRAPH bool NullTransitionWrapper:: is_cache_verified(UpdateSeq) const { return true; } @@ -162,7 +162,7 @@ is_cache_verified(UpdateSeq) const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: set_computed_verified(UpdateSeq) { } @@ -173,7 +173,7 @@ set_computed_verified(UpdateSeq) { // that indicated by value, using the cache as a helper, // and stores the result in this wrapper. //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: cached_compose(const NullTransitionWrapper &, const NullTransitionWrapper &, UpdateSeq) { @@ -184,7 +184,7 @@ cached_compose(const NullTransitionWrapper &, // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: output(ostream &) const { } @@ -193,6 +193,11 @@ output(ostream &) const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -INLINE void NullTransitionWrapper:: +INLINE_GRAPH void NullTransitionWrapper:: write(ostream &, int) const { } + +INLINE_GRAPH ostream &operator << (ostream &out, const NullTransitionWrapper &ntw) { + ntw.output(out); + return out; +} diff --git a/panda/src/graph/nullTransitionWrapper.h b/panda/src/graph/nullTransitionWrapper.h index 83781925c1..759a5ad84c 100644 --- a/panda/src/graph/nullTransitionWrapper.h +++ b/panda/src/graph/nullTransitionWrapper.h @@ -42,45 +42,44 @@ public: typedef NullTransitionWrapper TransitionWrapper; typedef NullAttributeWrapper AttributeWrapper; - INLINE NullTransitionWrapper(); - INLINE NullTransitionWrapper(const NullTransitionWrapper ©); - INLINE void operator = (const NullTransitionWrapper ©); + INLINE_GRAPH NullTransitionWrapper(); + INLINE_GRAPH NullTransitionWrapper(const NullTransitionWrapper ©); + INLINE_GRAPH void operator = (const NullTransitionWrapper ©); - INLINE static NullTransitionWrapper + INLINE_GRAPH static NullTransitionWrapper init_from(const NullTransitionWrapper &other); - INLINE static NullTransitionWrapper + INLINE_GRAPH static NullTransitionWrapper init_from(const NullAttributeWrapper &attrib); - INLINE bool is_identity() const; - INLINE int compare_to(const NullTransitionWrapper &other) const; + INLINE_GRAPH bool is_identity() const; + INLINE_GRAPH int compare_to(const NullTransitionWrapper &other) const; - INLINE void make_identity(); - INLINE void extract_from(const NodeRelation *arc); - INLINE void store_to(NodeRelation *arc) const; + INLINE_GRAPH void make_identity(); + INLINE_GRAPH void extract_from(const NodeRelation *arc); + INLINE_GRAPH void store_to(NodeRelation *arc) const; - INLINE void compose_in_place(const NullTransitionWrapper &other); - INLINE void invert_in_place(); - INLINE void invert_compose_in_place(const NullTransitionWrapper &other); + INLINE_GRAPH void compose_in_place(const NullTransitionWrapper &other); + INLINE_GRAPH void invert_in_place(); + INLINE_GRAPH void invert_compose_in_place(const NullTransitionWrapper &other); - INLINE Node *extract_from_cache(const NodeRelation *arc); - INLINE void store_to_cache(NodeRelation *arc, Node *top_subtree); - INLINE bool is_cache_verified(UpdateSeq now) const; - INLINE void set_computed_verified(UpdateSeq now); + INLINE_GRAPH Node *extract_from_cache(const NodeRelation *arc); + INLINE_GRAPH void store_to_cache(NodeRelation *arc, Node *top_subtree); + INLINE_GRAPH bool is_cache_verified(UpdateSeq now) const; + INLINE_GRAPH void set_computed_verified(UpdateSeq now); - INLINE void cached_compose(const NullTransitionWrapper &cache, + INLINE_GRAPH void cached_compose(const NullTransitionWrapper &cache, const NullTransitionWrapper &value, UpdateSeq now); - INLINE void output(ostream &out) const; - INLINE void write(ostream &out, int indent_level = 0) const; + INLINE_GRAPH void output(ostream &out) const; + INLINE_GRAPH void write(ostream &out, int indent_level = 0) const; }; -INLINE ostream &operator << (ostream &out, const NullTransitionWrapper &ntw) { - ntw.output(out); - return out; -} +INLINE_GRAPH ostream &operator << (ostream &out, const NullTransitionWrapper &ntw); +#ifdef BUILDING_PANDA #include "nullTransitionWrapper.I" +#endif #endif diff --git a/panda/src/graph/onAttribute.I b/panda/src/graph/onAttribute.I index 140cad5d66..78c5a8d09f 100644 --- a/panda/src/graph/onAttribute.I +++ b/panda/src/graph/onAttribute.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnAttribute:: +INLINE_GRAPH OnAttribute:: OnAttribute() { } @@ -17,7 +17,7 @@ OnAttribute() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnAttribute:: +INLINE_GRAPH OnAttribute:: OnAttribute(const OnAttribute ©) : NodeAttribute(copy) { @@ -28,7 +28,7 @@ OnAttribute(const OnAttribute ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void OnAttribute:: +INLINE_GRAPH void OnAttribute:: operator = (const OnAttribute ©) { NodeAttribute::operator = (copy); } diff --git a/panda/src/graph/onAttribute.h b/panda/src/graph/onAttribute.h index aa1cd7ca84..be79b83770 100644 --- a/panda/src/graph/onAttribute.h +++ b/panda/src/graph/onAttribute.h @@ -18,9 +18,9 @@ class OnTransition; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA OnAttribute : public NodeAttribute { protected: - INLINE OnAttribute(); - INLINE OnAttribute(const OnAttribute ©); - INLINE void operator = (const OnAttribute ©); + INLINE_GRAPH OnAttribute() {}; + INLINE_GRAPH OnAttribute(const OnAttribute ©) : NodeAttribute(copy) {}; + INLINE_GRAPH void operator = (const OnAttribute ©) {NodeAttribute::operator = (copy);}; public: virtual void output(ostream &out) const; @@ -50,9 +50,7 @@ public: private: static TypeHandle _type_handle; -friend class OnTransition; + friend class OnTransition; }; -#include "onAttribute.I" - #endif diff --git a/panda/src/graph/onOffAttribute.I b/panda/src/graph/onOffAttribute.I index ff88de476c..cee1678a40 100644 --- a/panda/src/graph/onOffAttribute.I +++ b/panda/src/graph/onOffAttribute.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnOffAttribute:: +INLINE_GRAPH OnOffAttribute:: OnOffAttribute(bool is_on) { _is_on = is_on; } @@ -18,7 +18,7 @@ OnOffAttribute(bool is_on) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnOffAttribute:: +INLINE_GRAPH OnOffAttribute:: OnOffAttribute(const OnOffAttribute ©) : NodeAttribute(copy), _is_on(copy._is_on) @@ -30,7 +30,7 @@ OnOffAttribute(const OnOffAttribute ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void OnOffAttribute:: +INLINE_GRAPH void OnOffAttribute:: operator = (const OnOffAttribute ©) { NodeAttribute::operator = (copy); _is_on = copy._is_on; @@ -49,7 +49,7 @@ operator = (const OnOffAttribute ©) { // should override this function to accept a value // parameter of the appropriate type. //////////////////////////////////////////////////////////////////// -INLINE void OnOffAttribute:: +INLINE_GRAPH void OnOffAttribute:: set_on() { _is_on = true; } @@ -61,7 +61,7 @@ set_on() { // turns off the attribute for all nodes at this point // and below. //////////////////////////////////////////////////////////////////// -INLINE void OnOffAttribute:: +INLINE_GRAPH void OnOffAttribute:: set_off() { _is_on = false; } @@ -72,7 +72,7 @@ set_off() { // Description: Returns true if the attribute is on, false if it is // not. //////////////////////////////////////////////////////////////////// -INLINE bool OnOffAttribute:: +INLINE_GRAPH bool OnOffAttribute:: is_on() const { return _is_on; } @@ -83,7 +83,7 @@ is_on() const { // Description: Returns true if the attribute is off, false if it is // not. //////////////////////////////////////////////////////////////////// -INLINE bool OnOffAttribute:: +INLINE_GRAPH bool OnOffAttribute:: is_off() const { return !_is_on; } diff --git a/panda/src/graph/onOffAttribute.h b/panda/src/graph/onOffAttribute.h index 000bbd6976..ca82ed7ee6 100644 --- a/panda/src/graph/onOffAttribute.h +++ b/panda/src/graph/onOffAttribute.h @@ -18,16 +18,16 @@ class OnOffTransition; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA OnOffAttribute : public NodeAttribute { protected: - INLINE OnOffAttribute(bool is_on = false); - INLINE OnOffAttribute(const OnOffAttribute ©); - INLINE void operator = (const OnOffAttribute ©); + INLINE_GRAPH OnOffAttribute(bool is_on = false); + INLINE_GRAPH OnOffAttribute(const OnOffAttribute ©); + INLINE_GRAPH void operator = (const OnOffAttribute ©); PUBLISHED: - INLINE void set_on(); - INLINE void set_off(); + INLINE_GRAPH void set_on(); + INLINE_GRAPH void set_off(); - INLINE bool is_on() const; - INLINE bool is_off() const; + INLINE_GRAPH bool is_on() const; + INLINE_GRAPH bool is_off() const; public: virtual void output(ostream &out) const; @@ -63,6 +63,8 @@ private: friend class OnOffTransition; }; +#ifdef BUILDING_PANDA #include "onOffAttribute.I" +#endif #endif diff --git a/panda/src/graph/onOffTransition.I b/panda/src/graph/onOffTransition.I index 337d89f32c..83542b0423 100644 --- a/panda/src/graph/onOffTransition.I +++ b/panda/src/graph/onOffTransition.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnOffTransition:: +INLINE_GRAPH OnOffTransition:: OnOffTransition(TransitionDirection direction) { _direction = direction; } @@ -18,7 +18,7 @@ OnOffTransition(TransitionDirection direction) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnOffTransition:: +INLINE_GRAPH OnOffTransition:: OnOffTransition(const OnOffTransition ©) : NodeTransition(copy), _direction(copy._direction) @@ -30,7 +30,7 @@ OnOffTransition(const OnOffTransition ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void OnOffTransition:: +INLINE_GRAPH void OnOffTransition:: operator = (const OnOffTransition ©) { NodeTransition::operator = (copy); _direction = copy._direction; @@ -43,7 +43,7 @@ operator = (const OnOffTransition ©) { // this has no effect on the attribute for any nodes at // this point and below. //////////////////////////////////////////////////////////////////// -INLINE void OnOffTransition:: +INLINE_GRAPH void OnOffTransition:: set_identity() { _direction = TD_identity; state_changed(); @@ -62,7 +62,7 @@ set_identity() { // should override this function to accept a value // parameter of the appropriate type. //////////////////////////////////////////////////////////////////// -INLINE void OnOffTransition:: +INLINE_GRAPH void OnOffTransition:: set_on() { _direction = TD_on; state_changed(); @@ -75,7 +75,7 @@ set_on() { // turns off the attribute for all nodes at this point // and below. //////////////////////////////////////////////////////////////////// -INLINE void OnOffTransition:: +INLINE_GRAPH void OnOffTransition:: set_off() { _direction = TD_off; state_changed(); @@ -87,7 +87,7 @@ set_off() { // Description: Returns true if this is the identity transition, // false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool OnOffTransition:: +INLINE_GRAPH bool OnOffTransition:: is_identity() const { return _direction == TD_identity; } @@ -100,7 +100,7 @@ is_identity() const { // value, it should define a get_value() function which // allows you to query the on value. //////////////////////////////////////////////////////////////////// -INLINE bool OnOffTransition:: +INLINE_GRAPH bool OnOffTransition:: is_on() const { return _direction == TD_on; } @@ -111,7 +111,7 @@ is_on() const { // Description: Returns true if this transition is the 'off' // transition, false otherwise. //////////////////////////////////////////////////////////////////// -INLINE bool OnOffTransition:: +INLINE_GRAPH bool OnOffTransition:: is_off() const { return _direction == TD_off; } diff --git a/panda/src/graph/onOffTransition.h b/panda/src/graph/onOffTransition.h index 897c76b5da..edb86c1c51 100644 --- a/panda/src/graph/onOffTransition.h +++ b/panda/src/graph/onOffTransition.h @@ -36,18 +36,18 @@ class NodeRelation; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA OnOffTransition : public NodeTransition { protected: - INLINE OnOffTransition(TransitionDirection direction = TD_identity); - INLINE OnOffTransition(const OnOffTransition ©); - INLINE void operator = (const OnOffTransition ©); + INLINE_GRAPH OnOffTransition(TransitionDirection direction = TD_identity); + INLINE_GRAPH OnOffTransition(const OnOffTransition ©); + INLINE_GRAPH void operator = (const OnOffTransition ©); PUBLISHED: - INLINE void set_identity(); - INLINE void set_on(); - INLINE void set_off(); + INLINE_GRAPH void set_identity(); + INLINE_GRAPH void set_on(); + INLINE_GRAPH void set_off(); - INLINE bool is_identity() const; - INLINE bool is_on() const; - INLINE bool is_off() const; + INLINE_GRAPH bool is_identity() const; + INLINE_GRAPH bool is_on() const; + INLINE_GRAPH bool is_off() const; public: virtual NodeTransition *compose(const NodeTransition *other) const; @@ -92,10 +92,11 @@ public: private: static TypeHandle _type_handle; - -friend class OnOffAttribute; + friend class OnOffAttribute; }; +#ifdef BUILDING_PANDA #include "onOffTransition.I" +#endif #endif diff --git a/panda/src/graph/onTransition.I b/panda/src/graph/onTransition.I index d93ff18c4e..0e0a923bcf 100644 --- a/panda/src/graph/onTransition.I +++ b/panda/src/graph/onTransition.I @@ -8,7 +8,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnTransition:: +INLINE_GRAPH OnTransition:: OnTransition() { } @@ -17,7 +17,7 @@ OnTransition() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE OnTransition:: +INLINE_GRAPH OnTransition:: OnTransition(const OnTransition ©) : NodeTransition(copy) { @@ -28,7 +28,7 @@ OnTransition(const OnTransition ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE void OnTransition:: +INLINE_GRAPH void OnTransition:: operator = (const OnTransition ©) { NodeTransition::operator = (copy); } diff --git a/panda/src/graph/onTransition.h b/panda/src/graph/onTransition.h index c45d71f902..463a007bec 100644 --- a/panda/src/graph/onTransition.h +++ b/panda/src/graph/onTransition.h @@ -29,9 +29,9 @@ class NodeRelation; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA OnTransition : public NodeTransition { protected: - INLINE OnTransition(); - INLINE OnTransition(const OnTransition ©); - INLINE void operator = (const OnTransition ©); + INLINE_GRAPH OnTransition(); + INLINE_GRAPH OnTransition(const OnTransition ©); + INLINE_GRAPH void operator = (const OnTransition ©); public: virtual NodeTransition *compose(const NodeTransition *other) const; @@ -72,10 +72,11 @@ public: private: static TypeHandle _type_handle; - -friend class OnAttribute; + friend class OnAttribute; }; +#ifdef BUILDING_PANDA #include "onTransition.I" +#endif #endif diff --git a/panda/src/graph/setTransitionHelpers.T b/panda/src/graph/setTransitionHelpers.T new file mode 100644 index 0000000000..44016d1928 --- /dev/null +++ b/panda/src/graph/setTransitionHelpers.T @@ -0,0 +1,1104 @@ +// Filename: setTransitionHelpers.I +// Created by: drose (25Jan99) +// +//////////////////////////////////////////////////////////////////// + +#include "nodeTransitionCacheEntry.h" +#include "config_graph.h" + +//////////////////////////////////////////////////////////////////// +// Function: tmap_get_interest +// Description: Returns the NodeTransition elements of interest to +// us. These are the elements of the first sequence--a +// NodeTransition map--whose keys appear in the second +// sequence, a sorted list of NodeTransition +// TypeHandles. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_get_interest(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < *first2) { + ++first1; + ++result; + } else if (*first2 < (*first1).first) { + ++first2; + ++result; + } else { + *result = *first1; + ++first1; + ++first2; + ++result; + } + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_override_union +// Description: Accepts two NodeTransition or NodeAttribute maps, and +// builds a new map which is the union of the first two. +// If an element appears in both maps, the entry from +// the second is preferred. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_override_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + *result = *first2; + ++first2; + ++result; + } else { + *result = *first2; + ++first1; + ++first2; + ++result; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + *result = *first2; + ++first2; + ++result; + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_merge_union +// Description: Accepts two NodeAttribute maps, and builds a new map +// which is the union of the first two. If an element +// appears in both maps, the two are merged, preferring +// the second. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_merge_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + *result = *first2; + ++first2; + ++result; + } else { + PT(NodeAttribute) c = (*first1).second->merge((*first2).second); + *result = pair((*first1).first, c); + ++first1; + ++first2; + ++result; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + *result = *first2; + ++first2; + ++result; + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_arc_union +// Description: As above, but updates the transitions on the way to +// indicate they are being attached to (or removed from) +// the indicated arc. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_arc_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + NodeRelation *to_arc, OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + (*first2).second->added_to_arc(to_arc); + *result = *first2; + ++first2; + ++result; + } else { + (*first1).second->removed_from_arc(to_arc); + (*first2).second->added_to_arc(to_arc); + *result = *first2; + ++first1; + ++first2; + ++result; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + (*first2).second->added_to_arc(to_arc); + *result = *first2; + ++first2; + ++result; + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_arc_compose +// Description: +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_arc_compose(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + NodeRelation *to_arc, OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + (*first2).second->added_to_arc(to_arc); + *result = *first2; + ++first2; + ++result; + } else { + (*first1).second->removed_from_arc(to_arc); + + PT(NodeTransition) c = (*first1).second->compose((*first2).second); + if (c != (NodeTransition *)NULL) { + c->added_to_arc(to_arc); + *result = pair((*first1).first, c); + ++result; + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + (*first2).second->added_to_arc(to_arc); + *result = *first2; + ++first2; + ++result; + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_arc_compose +// Description: +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_arc_compose(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + *result = *first2; + ++first2; + ++result; + } else { + NodeTransition *c = (*first1).second->compose((*first2).second); + if (c != (NodeTransition *)NULL) { + *result = pair + ((*first1).first, c); + ++result; + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + *result = *first2; + ++first2; + ++result; + } + return result; +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_compose +// Description: Accepts two NodeTransition maps, and builds a new +// list (a NodeTransition map) which represents the +// memberwise composition of the two input maps. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_compose(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + *result = *first2; + ++first2; + ++result; + } else { + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::compose((*first1).second, (*first2).second)); + ++first1; + ++first2; + ++result; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + *result = *first2; + ++first2; + ++result; + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_invert_compose +// Description: Accepts two NodeTransition maps, and builds a new +// list (a NodeTransition map) which represents the +// memberwise result of invert_compose of the two input +// maps. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_invert_compose(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = pair + ((*first1).first, NodeTransitionCacheEntry::invert((*first1).second)); + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + *result = *first2; + ++first2; + ++result; + } else { + NodeTransitionCacheEntry ic = + NodeTransitionCacheEntry::invert_compose((*first1).second, + (*first2).second); + if (!ic.is_identity()) { + // Only bother to store the result if it's not identity. + *result = pair((*first1).first, ic); + ++result; + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + *result = pair + ((*first1).first, NodeTransitionCacheEntry::invert((*first1).second)); + ++first1; + ++result; + } + + while (first2 != last2) { + *result = *first2; + ++first2; + ++result; + } + return result; +} + +// This macro is used in the various cached_compose functions to +// possibly output debug statements about which pieces we're +// composing. + +#ifndef NDEBUG +#define OUTPUT_CC_ELEM(desc, type) \ +{ \ + if (wrt_cat.is_spam()) { \ + wrt_cat.spam() << "in " << desc << ": " << (type) << "\n"; \ + } \ +} +#else +#define OUTPUT_CC_ELEM(desc, type) +#endif + +//////////////////////////////////////////////////////////////////// +// Function: tmap_cached_compose_not_1 +// Description: One of several support functions for +// tmap_cached_compose(), below, this handles the case +// of tmap_cached_compose() for a NodeTransition that +// is already known not to be present in list 1, but may +// be in one or both of lists 2 and 3. +//////////////////////////////////////////////////////////////////// +template +void +tmap_cached_compose_not_1(InputIterator2 &first2, InputIterator3 &first3, + UpdateSeq now, OutputIterator &result) { + if ((*first2).first < (*first3).first) { + // Here's an element in list 2 that is not in lists 1 or 3. + OUTPUT_CC_ELEM("2", (*first2).first); + + *result = pair + ((*first2).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + (*first2).second, + NodeTransitionCacheEntry(), + now)); + ++first2; + ++result; + + } else if ((*first3).first < (*first2).first) { + // Here's an element in list 3 that is not lists 2 or 1. + OUTPUT_CC_ELEM("3", (*first3).first); + + *result = pair + ((*first3).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + (*first3).second, + now)); + ++first3; + ++result; + + } else { // (*first2).first == (*first3).first + // Here's an element in lists 2 and 3 that is not in list 1. + OUTPUT_CC_ELEM("2, 3", (*first2).first); + + *result = pair + ((*first2).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + (*first2).second, + (*first3).second, + now)); + ++first2; + ++first3; + ++result; + } +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_cached_compose_not_2 +// Description: One of several support functions for +// tmap_cached_compose(), below, this handles the case +// of tmap_cached_compose() for an NodeTransition that +// is already known not to be present in list 2, but may +// be in one or both of lists 1 and 3. +//////////////////////////////////////////////////////////////////// +template +void +tmap_cached_compose_not_2(InputIterator1 &first1, InputIterator3 &first3, + UpdateSeq now, OutputIterator &result) { + if ((*first1).first < (*first3).first) { + // Here's an element in list 1 that is not in lists 2 or 3. + OUTPUT_CC_ELEM("1", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + now)); + ++first1; + ++result; + + } else if ((*first3).first < (*first1).first) { + // Here's an element in list 3 that is not lists 1 or 2. + OUTPUT_CC_ELEM("3", (*first3).first); + + *result = pair + ((*first3).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + (*first3).second, + now)); + ++first3; + ++result; + + } else { // (*first1).first == (*first3).first + // Here's an element in lists 1 and 3 that is not in list 2. + OUTPUT_CC_ELEM("1, 3", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + NodeTransitionCacheEntry(), + (*first3).second, + now)); + ++first1; + ++first3; + ++result; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_cached_compose_not_3 +// Description: One of several support functions for +// tmap_cached_compose(), below, this handles the case +// of tmap_cached_compose() for an NodeTransition that +// is already known not to be present in list 3, but may +// be in one or both of lists 1 and 2. +//////////////////////////////////////////////////////////////////// +template +void +tmap_cached_compose_not_3(InputIterator1 &first1, InputIterator2 &first2, + UpdateSeq now, OutputIterator &result) { + if ((*first1).first < (*first2).first) { + // Here's an element in list 1 that is not in lists 2 or 3. + OUTPUT_CC_ELEM("1", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + now)); + ++first1; + ++result; + + } else if ((*first2).first < (*first1).first) { + // Here's an element in list 2 that is not lists 1 or 3. + OUTPUT_CC_ELEM("2", (*first2).first); + + *result = pair + ((*first2).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + (*first2).second, + NodeTransitionCacheEntry(), + now)); + ++first2; + ++result; + + } else { // (*first1).first == (*first2).first + // Here's an element in lists 1 and 2 that is not in list 3. + OUTPUT_CC_ELEM("1, 2", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + (*first2).second, + NodeTransitionCacheEntry(), + now)); + ++first1; + ++first2; + ++result; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_cached_compose_12 +// Description: One of several support functions for +// tmap_cached_compose(), below, this handles the case +// of tmap_cached_compose() for an NodeTransition that +// is already known to be in both lists 1 and 2, and may +// or may not also be in list 3. +//////////////////////////////////////////////////////////////////// +template +void +tmap_cached_compose_12(InputIterator1 &first1, InputIterator2 &first2, + InputIterator3 &first3, + UpdateSeq now, OutputIterator &result) { + if ((*first1).first < (*first3).first) { + // Here's an element in lists 1 and 2 that is not in list 3. + OUTPUT_CC_ELEM("1, 2", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + (*first2).second, + NodeTransitionCacheEntry(), + now)); + ++first1; + ++first2; + ++result; + + } else if ((*first3).first < (*first1).first) { + // Here's an element in list 3 that is not lists 1 or 2. + OUTPUT_CC_ELEM("3", (*first3).first); + + *result = pair + ((*first3).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + (*first3).second, + now)); + ++first3; + ++result; + + } else { // (*first1).first == (*first3).first + // Here's an element in lists 1, 2, and 3. + OUTPUT_CC_ELEM("1, 2, 3", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + (*first2).second, + (*first3).second, + now)); + ++first1; + ++first2; + ++first3; + ++result; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_cached_compose +// Description: Calls dynamic_cached_compose() on each matching +// element of [first1 .. last1), [cached_first +// .. cached_last), and [value_first .. value_last). +// +// This function is big and complicated because it has +// to do a parallel merge on three separate lists. Any +// NodeTransition type may appear in any or all of the +// lists; if a particular type appears in any list but +// is absent from the others, an implicit identity +// transition should be inferred where it is absent. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_cached_compose(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + InputIterator3 first3, InputIterator3 last3, + UpdateSeq now, OutputIterator result) { + while (first1 != last1 && first2 != last2 && first3 != last3) { + if ((*first1).first < (*first2).first) { + tmap_cached_compose_not_2(first1, first3, now, result); + + } else if ((*first2).first < (*first1).first) { + tmap_cached_compose_not_1(first2, first3, now, result); + + } else { // (*first1).first == (*first2).first + tmap_cached_compose_12(first1, first2, first3, now, result); + } + } + + // Now pick up everything else. + if (first1 == last1) { + while (first2 != last2 && first3 != last3) { + tmap_cached_compose_not_1(first2, first3, now, result); + } + + } else if (first2 == last2) { + while (first1 != last1 && first3 != last3) { + tmap_cached_compose_not_2(first1, first3, now, result); + } + + } else if (first3 == last3) { + while (first1 != last1 && first2 != last2) { + tmap_cached_compose_not_3(first1, first2, now, result); + } + } + + while (first1 != last1) { + // Here's an element in list 1 that is not in lists 2 or 3. + OUTPUT_CC_ELEM("1", (*first1).first); + + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::cached_compose + ((*first1).second, + NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + now)); + ++first1; + ++result; + } + + while (first2 != last2) { + // Here's an element in list 2 that is not in lists 1 or 3. + OUTPUT_CC_ELEM("2", (*first2).first); + + *result = pair + ((*first2).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + (*first2).second, + NodeTransitionCacheEntry(), + now)); + ++first2; + ++result; + } + + while (first3 != last3) { + // Here's an element in list 3 that is not lists 1 or 2. + OUTPUT_CC_ELEM("3", (*first3).first); + + *result = pair + ((*first3).first, + NodeTransitionCacheEntry::cached_compose + (NodeTransitionCacheEntry(), + NodeTransitionCacheEntry(), + (*first3).second, + now)); + ++first3; + ++result; + } + + return result; +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_apply +// Description: Accepts a NodeAttribute map and a NodeTransition map, +// and builds a new list (a NodeAttribute map) which +// represents the memberwise application of the two +// input maps. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_apply(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + *result = *first1; + ++first1; + ++result; + } else if ((*first2).first < (*first1).first) { + *result = pair + ((*first2).first, + NodeTransitionCacheEntry::apply(NULL, (*first2).second)); + ++first2; + ++result; + } else { + *result = pair + ((*first1).first, + NodeTransitionCacheEntry::apply((*first1).second, (*first2).second)); + ++first1; + ++first2; + ++result; + } + } + + while (first1 != last1) { + *result = *first1; + ++first1; + ++result; + } + + while (first2 != last2) { + *result = pair + ((*first2).first, + NodeTransitionCacheEntry::apply(NULL, (*first2).second)); + ++first2; + ++result; + } + return result; +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_invert +// Description: Accepts a NodeTransition map, and builds a new list +// which represents the memberwise inversion of the +// input. Guarantees that the new list will have +// exactly the same length as the input list. +//////////////////////////////////////////////////////////////////// +template +OutputIterator +tmap_invert(InputIterator first, InputIterator last, + OutputIterator result) { + while (first != last) { + *result = pair + ((*first).first, NodeTransitionCacheEntry::invert((*first).second)); + ++first; + ++result; + } + return result; +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_equiv_trans +// Description: Accepts a pair of NodeTransition maps, and returns +// true if they are equivalent, false otherwise. Two +// NodeTransition maps are defined to be equivalent if +// all nonidentity members present in one set are +// present and equivalent in the other set, +//////////////////////////////////////////////////////////////////// +template +bool +tmap_equiv_trans(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + if (!(*first1).second.is_identity()) { + return false; + } + ++first1; + } else if ((*first2).first < (*first1).first) { + if (!(*first2).second.is_identity()) { + return false; + } + ++first2; + } else { + if (!(*first1).second.compare_to((*first2).second) == 0) { + return false; + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + if (!(*first1).second.is_identity()) { + return false; + } + ++first1; + } + + while (first2 != last2) { + if (!(*first2).second.is_identity()) { + return false; + } + ++first2; + } + return true; +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_equiv_attr +// Description: Accepts a pair of NodeAttribute maps, and returns +// true if they are equivalent, false otherwise. Two +// NodeAttributes maps are defined to be equivalent if +// all non-NULL members present in one set are present +// and equivalent in the other set, +//////////////////////////////////////////////////////////////////// +template +bool +tmap_equiv_attr(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + if ((*first1).second != (NodeAttribute *)NULL) { + return false; + } + ++first1; + } else if ((*first2).first < (*first1).first) { + if ((*first2).second != (NodeAttribute *)NULL) { + return false; + } + ++first2; + } else { + if ((*first1).second != (*first2).second) { + if ((*first1).second == (NodeAttribute *)NULL || + (*first2).second == (NodeAttribute *)NULL || + (*first1).second->compare_to((*first2).second) != 0) { + return false; + } + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + if ((*first1).second != (NodeAttribute *)NULL) { + return false; + } + ++first1; + } + + while (first2 != last2) { + if ((*first2).second != (NodeAttribute *)NULL) { + return false; + } + ++first2; + } + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_compare_cache +// Description: Accepts a pair of NodeTransition maps, and returns +// -1 if the first one sorts before the second one, +// 1 if it sorts after, or 0 if they are equivalent. +//////////////////////////////////////////////////////////////////// +template +int +tmap_compare_cache(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + if (!(*first1).second.is_identity()) { + return 1; + } + ++first1; + } else if ((*first2).first < (*first1).first) { + if (!(*first2).second.is_identity()) { + return -1; + } + ++first2; + } else { + int result; + result = (*first1).second.compare_to((*first2).second); + if (result != 0) { + return result; + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + if (!(*first1).second.is_identity()) { + // list1 is longer. + return -1; + } + ++first1; + } + + while (first2 != last2) { + if (!(*first2).second.is_identity()) { + // list2 is longer. + return 1; + } + ++first2; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_compare_trans +// Description: Accepts a pair of NodeTransition maps, and returns +// -1 if the first one sorts before the second one, +// 1 if it sorts after, or 0 if they are equivalent. +//////////////////////////////////////////////////////////////////// +template +int +tmap_compare_trans(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + if ((*first1).second != (NodeTransition *)NULL) { + return 1; + } + ++first1; + } else if ((*first2).first < (*first1).first) { + if ((*first2).second != (NodeTransition *)NULL) { + return -1; + } + ++first2; + } else { + if ((*first1).second != (*first2).second) { + if ((*first1).second == (NodeTransition *)NULL) { + return -1; + } else if ((*first2).second == (NodeTransition *)NULL) { + return 1; + } else { + int result; + result = (*first1).second->compare_to(*(*first2).second); + if (result != 0) { + return result; + } + } + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + if ((*first1).second != (NodeTransition *)NULL) { + // list1 is longer. + return -1; + } + ++first1; + } + + while (first2 != last2) { + if ((*first2).second != (NodeTransition *)NULL) { + // list2 is longer. + return 1; + } + ++first2; + } + + return 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_compare_attr +// Description: Accepts a pair of NodeAttribute maps, and returns +// -1 if the first one sorts before the second one, +// 1 if it sorts after, or 0 if they are equivalent. +//////////////////////////////////////////////////////////////////// +template +int +tmap_compare_attr(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) { + if ((*first1).first < (*first2).first) { + if ((*first1).second != (NodeAttribute *)NULL) { + return 1; + } + ++first1; + } else if ((*first2).first < (*first1).first) { + if ((*first2).second != (NodeAttribute *)NULL) { + return -1; + } + ++first2; + } else { + if ((*first1).second != (*first2).second) { + if ((*first1).second == (NodeAttribute *)NULL) { + return -1; + } else if ((*first2).second == (NodeAttribute *)NULL) { + return 1; + } else { + int result; + result = (*first1).second->compare_to(*(*first2).second); + if (result != 0) { + return result; + } + } + } + ++first1; + ++first2; + } + } + + while (first1 != last1) { + if ((*first1).second != (NodeAttribute *)NULL) { + // list1 is longer. + return -1; + } + ++first1; + } + + while (first2 != last2) { + if ((*first2).second != (NodeAttribute *)NULL) { + // list2 is longer. + return 1; + } + ++first2; + } + + return 0; +} + + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_is_identity +// Description: Accepts a NodeTransition map, and returns true if all +// elements in the map correspond to the identity +// transition, false otherwise. +//////////////////////////////////////////////////////////////////// +template +bool +tmap_is_identity(InputIterator first, InputIterator last) { + while (first != last) { + if (!(*first).second.is_identity()) { + return false; + } + ++first; + } + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: tmap_is_initial +// Description: Accepts a NodeAttribute map, and returns true if all +// elements in the map correspond to the initial +// attribute, false otherwise. +//////////////////////////////////////////////////////////////////// +template +bool +tmap_is_initial(InputIterator first, InputIterator last) { + while (first != last) { + if (!(*first).second.is_initial()) { + return false; + } + ++first; + } + return true; +} + + +//////////////////////////////////////////////////////////////////// +// Function: tmap_output +// Description: Accepts a NodeTransition or NodeAttribute map and +// writes each element to the given output stream with a +// single space separating them. +//////////////////////////////////////////////////////////////////// +template +ostream & +tmap_output(InputIterator first, InputIterator last, ostream &out) { + if (first != last) { + out << *((*first).second); + ++first; + while (first != last) { + out << " " << *((*first).second); + ++first; + } + } + return out; +} diff --git a/panda/src/graph/setTransitionHelpers.h b/panda/src/graph/setTransitionHelpers.h index 6453a4b6d4..0252f3a0c1 100644 --- a/panda/src/graph/setTransitionHelpers.h +++ b/panda/src/graph/setTransitionHelpers.h @@ -120,6 +120,6 @@ template ostream & tmap_output(InputIterator first, InputIterator last, ostream &out); -#include "setTransitionHelpers.I" +#include "setTransitionHelpers.T" #endif diff --git a/panda/src/graph/traverserVisitor.I b/panda/src/graph/traverserVisitor.I index e8fd9a6a16..868d0b1842 100644 --- a/panda/src/graph/traverserVisitor.I +++ b/panda/src/graph/traverserVisitor.I @@ -12,7 +12,7 @@ // should be pruned at this node. //////////////////////////////////////////////////////////////////// template -INLINE bool TraverserVisitor:: +INLINE_GRAPH bool TraverserVisitor:: reached_node(Node *, TraverserVisitor::AttributeWrapper &, LevelState &) { @@ -28,7 +28,7 @@ reached_node(Node *, // pruned and not reach the destination node. //////////////////////////////////////////////////////////////////// template -INLINE bool TraverserVisitor:: +INLINE_GRAPH bool TraverserVisitor:: forward_arc(NodeRelation *, TraverserVisitor::TransitionWrapper &, TraverserVisitor::AttributeWrapper &, @@ -48,7 +48,7 @@ forward_arc(NodeRelation *, // unmatched call to forward_arc. //////////////////////////////////////////////////////////////////// template -INLINE void TraverserVisitor:: +INLINE_GRAPH void TraverserVisitor:: backward_arc(NodeRelation *, TraverserVisitor::TransitionWrapper &, TraverserVisitor::AttributeWrapper &, diff --git a/panda/src/graph/traverserVisitor.T b/panda/src/graph/traverserVisitor.T new file mode 100644 index 0000000000..868d0b1842 --- /dev/null +++ b/panda/src/graph/traverserVisitor.T @@ -0,0 +1,57 @@ +// Filename: traverserVisitor.I +// Created by: drose (20Mar00) +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: TraverserVisitor::reached_node +// Access: Public +// Description: Called for each node visited. It may return true if +// the traversal is to be continued, or false if it +// should be pruned at this node. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool TraverserVisitor:: +reached_node(Node *, + TraverserVisitor::AttributeWrapper &, + LevelState &) { + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: TraverserVisitor::reached_node +// Access: Public +// Description: Called each time an arc is traversed in the forward +// direction. As above, it may return true if the +// traversal should continue, or false if it should be +// pruned and not reach the destination node. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH bool TraverserVisitor:: +forward_arc(NodeRelation *, + TraverserVisitor::TransitionWrapper &, + TraverserVisitor::AttributeWrapper &, + TraverserVisitor::AttributeWrapper &, + LevelState &) { + return true; +} + + +//////////////////////////////////////////////////////////////////// +// Function: TraverserVisitor::reached_node +// Access: Public +// Description: Called each time an arc is traversed in the backward +// direction. It is guaranteed to be paired stack-wise +// with the corresponding call to forward_arc, so that +// each call to backward_arc matches the previous +// unmatched call to forward_arc. +//////////////////////////////////////////////////////////////////// +template +INLINE_GRAPH void TraverserVisitor:: +backward_arc(NodeRelation *, + TraverserVisitor::TransitionWrapper &, + TraverserVisitor::AttributeWrapper &, + TraverserVisitor::AttributeWrapper &, + const LevelState &) { +} diff --git a/panda/src/graph/traverserVisitor.h b/panda/src/graph/traverserVisitor.h index f1688e6878..f09b57b2b5 100644 --- a/panda/src/graph/traverserVisitor.h +++ b/panda/src/graph/traverserVisitor.h @@ -17,7 +17,7 @@ public: typedef TW TransitionWrapper; typedef TYPENAME TransitionWrapper::AttributeWrapper AttributeWrapper; - INLINE bool reached_node(Node *node, + INLINE_GRAPH bool reached_node(Node *node, AttributeWrapper &render_state, LevelState &level_state); @@ -25,15 +25,15 @@ public: // following two functions to mark the crossing of arcs. This will // allow the Visitor to maintain its own internal state as needed. - INLINE bool forward_arc(NodeRelation *arc, TransitionWrapper &trans, + INLINE_GRAPH bool forward_arc(NodeRelation *arc, TransitionWrapper &trans, AttributeWrapper &pre, AttributeWrapper &post, LevelState &level_state); - INLINE void backward_arc(NodeRelation *arc, TransitionWrapper &trans, + INLINE_GRAPH void backward_arc(NodeRelation *arc, TransitionWrapper &trans, AttributeWrapper &pre, AttributeWrapper &post, const LevelState &level_state); }; -#include "traverserVisitor.I" +#include "traverserVisitor.T" #endif diff --git a/panda/src/graph/wrt.I b/panda/src/graph/wrt.I index 58d430c375..427f7e353b 100644 --- a/panda/src/graph/wrt.I +++ b/panda/src/graph/wrt.I @@ -533,7 +533,7 @@ uncached_wrt_base(const Node *from, // various wrt() wrappers instead. //////////////////////////////////////////////////////////////////// template -INLINE void +INLINE_GRAPH void wrt_base(const Node *from, InputIterator1 from_arcs_begin, InputIterator1 from_arcs_end, const Node *to, @@ -554,7 +554,7 @@ wrt_base(const Node *from, } template -INLINE void +INLINE_GRAPH void wrt(const Node *from, const Node *to, TransitionWrapper &result, TypeHandle graph_type) { // In the normal wrt() interface, we have no from_arcs or to_arcs @@ -564,7 +564,7 @@ wrt(const Node *from, const Node *to, } template -INLINE void +INLINE_GRAPH void wrt(const Node *from, InputIterator from_arcs_begin, InputIterator from_arcs_end, const Node *to, @@ -575,7 +575,7 @@ wrt(const Node *from, } template -INLINE void +INLINE_GRAPH void wrt(const Node *from, const Node *to, InputIterator to_arcs_begin, InputIterator to_arcs_end, @@ -586,7 +586,7 @@ wrt(const Node *from, } template -INLINE void +INLINE_GRAPH void wrt(const Node *from, InputIterator1 from_arcs_begin, InputIterator1 from_arcs_end, const Node *to, @@ -599,7 +599,7 @@ wrt(const Node *from, #ifndef NDEBUG template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, const Node *to, TransitionWrapper &result, TypeHandle graph_type) { const NodeRelation *arc = NULL; @@ -607,7 +607,7 @@ uncached_wrt(const Node *from, const Node *to, } template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, InputIterator from_arcs_begin, InputIterator from_arcs_end, const Node *to, @@ -618,7 +618,7 @@ uncached_wrt(const Node *from, } template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, const Node *to, InputIterator to_arcs_begin, InputIterator to_arcs_end, @@ -629,7 +629,7 @@ uncached_wrt(const Node *from, } template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, InputIterator1 from_arcs_begin, InputIterator1 from_arcs_end, const Node *to, @@ -734,7 +734,7 @@ get_uncached_wrt_subtree(Node *node, Node *to, TransitionWrapper &result, } template -INLINE Node * +INLINE_GRAPH Node * uncached_wrt_subtree(NodeRelation *arc, Node *to, TransitionWrapper &result, TypeHandle graph_type) { Node *stop = @@ -921,7 +921,7 @@ cached_wrt_subtree(NodeRelation *arc, Node *to, UpdateSeq as_of, UpdateSeq now, } template -INLINE Node * +INLINE_GRAPH Node * wrt_subtree(NodeRelation *arc, Node *to, UpdateSeq as_of, UpdateSeq now, TransitionWrapper &result, TypeHandle graph_type) { #ifndef NDEBUG diff --git a/panda/src/graph/wrt.h b/panda/src/graph/wrt.h index bd65b04104..007ae19287 100644 --- a/panda/src/graph/wrt.h +++ b/panda/src/graph/wrt.h @@ -35,26 +35,26 @@ class Node; // to_arcs_begin..to_arcs_end. template -INLINE void +INLINE_GRAPH void wrt(const Node *from, const Node *to, TransitionWrapper &result, TypeHandle graph_type); template -INLINE void +INLINE_GRAPH void wrt(const Node *from, InputIterator from_arcs_begin, InputIterator from_arcs_end, const Node *to, TransitionWrapper &result, TypeHandle graph_type); template -INLINE void +INLINE_GRAPH void wrt(const Node *from, const Node *to, InputIterator to_arcs_begin, InputIterator to_arcs_end, TransitionWrapper &result, TypeHandle graph_type); template -INLINE void +INLINE_GRAPH void wrt(const Node *from, InputIterator1 from_arcs_begin, InputIterator1 from_arcs_end, const Node *to, @@ -67,26 +67,26 @@ wrt(const Node *from, // that you can configure 'cache-wrt' or 'paranoid-wrt' to disable or // force verification of the cache implicitly. template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, const Node *to, TransitionWrapper &result, TypeHandle graph_type); template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, InputIterator from_arcs_begin, InputIterator from_arcs_end, const Node *to, TransitionWrapper &result, TypeHandle graph_type); template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, const Node *to, InputIterator to_arcs_begin, InputIterator to_arcs_end, TransitionWrapper &result, TypeHandle graph_type); template -INLINE void +INLINE_GRAPH void uncached_wrt(const Node *from, InputIterator1 from_arcs_begin, InputIterator1 from_arcs_end, const Node *to, @@ -123,11 +123,13 @@ uncached_wrt(const Node *from, // current most recent update sequence anywhere, used to use to mark // any computed cache values. template -INLINE Node * +INLINE_GRAPH Node * wrt_subtree(NodeRelation *arc, Node *to, UpdateSeq as_of, UpdateSeq now, TransitionWrapper &result, TypeHandle graph_type); +#ifdef BUILDING_PANDA #include "wrt.I" +#endif #endif diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index d30589a65a..c5f0e77ab3 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -118,4 +118,50 @@ #endif /* WIN32_VC */ +#ifdef WIN32_VC +#define INLINE_LINMATH __forceinline +#define INLINE_MATHUTIL __forceinline + +#ifdef BUILDING_PANDA +#define INLINE_GRAPH __forceinline +#else +#define INLINE_GRAPH +#endif + +#else +#define INLINE_LINMATH INLINE +#define INLINE_MATHUTIL INLINE +#define INLINE_GRAPH INLINE +#endif + +#define INLINE_CHAR INLINE +#define INLINE_CHAT INLINE +#define INLINE_CHAN INLINE +#define INLINE_CHANCFG INLINE +#define INLINE_COLLIDE INLINE +#define INLINE_CULL INLINE +#define INLINE_DEVICE INLINE +#define INLINE_DGRAPH INLINE +#define INLINE_DISPLAY INLINE +#define INLINE_GOBJ INLINE +#define INLINE_GRUTIL INLINE + +#define INLINE_GSGBASE INLINE +#define INLINE_GSGMISC INLINE +#define INLINE_LIGHT INLINE +#define INLINE_PARAMETRICS INLINE +#define INLINE_SGRATTRIB INLINE +#define INLINE_SGMANIP INLINE +#define INLINE_SGRAPH INLINE +#define INLINE_SGRAPHUTIL INLINE +#define INLINE_SWITCHNODE INLINE +#define INLINE_TEXT INLINE +#define INLINE_TFORM INLINE +#define INLINE_LERP INLINE +#define INLINE_LOADER INLINE +#define INLINE_PUTIL INLINE +#define INLINE_EFFECTS INLINE +#define INLINE_GUI INLINE +#define INLINE_AUDIO INLINE + #endif