node.I 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Filename: node.I
  2. // Created by: drose (26Oct98)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #include <notify.h>
  19. ////////////////////////////////////////////////////////////////////
  20. // Function: Node::find_connection
  21. // Access: Public
  22. // Description: Returns a const reference to the NodeConnection of
  23. // the indicated graph type, if one exists, or a const
  24. // reference to an empty NodeConnection if a connection
  25. // of the indicated type does not exist.
  26. ////////////////////////////////////////////////////////////////////
  27. INLINE_GRAPH const NodeConnection &Node::
  28. find_connection(TypeHandle graph_type) const {
  29. if (_connections[0].get_graph_type() == graph_type) {
  30. return _connections[0];
  31. }
  32. if (max_node_graphs > 1) {
  33. return p_find_connection(graph_type);
  34. } else {
  35. return _empty_connection;
  36. }
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: Node::update_connection
  40. // Access: Public
  41. // Description: Returns a non-const pointer to the NodeConnection of
  42. // the indicated graph type, if one exists. If a
  43. // NodeConnection of the indicated type does not already
  44. // exist, creates one if possible and returns its
  45. // pointer. Otherwise, returns NULL.
  46. ////////////////////////////////////////////////////////////////////
  47. INLINE_GRAPH NodeConnection *Node::
  48. update_connection(TypeHandle graph_type) {
  49. if (_connections[0].get_graph_type() == graph_type) {
  50. return &_connections[0];
  51. }
  52. if (max_node_graphs > 1) {
  53. return p_update_connection(graph_type);
  54. } else {
  55. return (NodeConnection *)NULL;
  56. }
  57. }
  58. ////////////////////////////////////////////////////////////////////
  59. // Function: remove_child
  60. // Description: Finds the arc that connects the indicated nodes and
  61. // removes it. Returns true if the arc was found and
  62. // removed, false if it did not exist.
  63. ////////////////////////////////////////////////////////////////////
  64. EXPCL_PANDA INLINE_GRAPH bool
  65. remove_child(Node *parent, Node *child, TypeHandle graph_type) {
  66. NodeRelation *arc = find_arc(parent, child, graph_type);
  67. if (arc != (NodeRelation *)NULL) {
  68. remove_arc(arc);
  69. return true;
  70. }
  71. return false;
  72. }
  73. EXPCL_PANDA INLINE_GRAPH ostream &
  74. operator << (ostream &out, const Node &node) {
  75. node.output(out);
  76. return out;
  77. }