Source for file Tree.interface.php

Documentation is available at Tree.interface.php

  1. <?php
  2.  
  3. /**
  4. * The interface for the Tree data structure used by the Hierarchy.
  5. *
  6. * @package harmoni.osid_v2.hierarchy.tree
  7. *
  8. * @copyright Copyright &copy; 2005, Middlebury College
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  10. *
  11. * @version $Id: Tree.interface.php,v 1.7 2007/09/04 20:25:42 adamfranco Exp $
  12. */
  13. class TreeInterface {
  14.  
  15.  
  16.  
  17. /**
  18. * Adds the specified node to the hierarchy and makes it a child of the specified
  19. * parent. If the parent is not specified, then it makes the node a root.
  20. * @access public
  21. * @param ref object The node to add.
  22. * @param optional ref object parent The node that will become the parent of the added node.
  23. * @return boolean <code>true</code> on success; <code>false</code>, otherwise.
  24. */
  25. function addNode($node, $parent) {
  26. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  27. }
  28. /**
  29. * Returns the size (number of nodes) in this hierarchy.
  30. * @access public
  31. * @return integer The size (number of nodes) in this hierarchy.
  32. */
  33. function getSize() {
  34. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  35. }
  36.  
  37.  
  38. /**
  39. * Returns all the ancestors of the given node.
  40. * @access public
  41. * @param ref object node The node whose ancestors are to be found.
  42. * @return array An array of all the ancestors of the given node. Each array
  43. * key corresponds to the hierarchy level of the ancestor. Each element stores
  44. * the system id of the ancestor.
  45. */
  46. function getAncestors($node) {
  47. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  48. }
  49.  
  50. /**
  51. * Returns the subtree rooted at the specified node (excluding the root).
  52. * @access public
  53. * @param ref object node The node whose subtree is to be found.
  54. * @return array An array of all the nodes in the subtree rooted at the
  55. * specified node. Each array key corresponds to a certain level
  56. * in the hierarchy. For example, the first level (with array key = 0) will
  57. * contain the root's children. The second level will have the root's
  58. * grandchildren and so forth. The array does not consist of the actual node objects;
  59. * instead, it only stores their system ids.
  60. */
  61. function getSubtree($node) {
  62. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  63. }
  64. /**
  65. * Delete the node from the tree. This can only be done if the node has no
  66. * parents and no children.
  67. * @access public
  68. * @param object node The node to delete.
  69. * @return void
  70. ***/
  71. function deleteNode($node) {
  72. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  73. }
  74.  
  75. /**
  76. * Returns the node with the specified id. If it does not exist, return <code>null</code>.
  77. * @access public
  78. * @param string id The id of the requested node.
  79. * @return ref object The requested node. <code>Null</code>, if the node
  80. * is not in the tree.
  81. */
  82. function getNode($id) {
  83. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  84. }
  85. /**
  86. * Returns <code>true</code> if the node with the specified id (string) exists.
  87. * @access public
  88. * @param string id The id of the node.
  89. * @return boolean <code>true</code> if the node with the specified id is in the tree; else <code>false</code>.
  90. */
  91. function nodeExists($id) {
  92. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  93. }
  94.  
  95. /**
  96. * Simply returns all nodes of this hierarchy in an array in no particular
  97. * order.
  98. * @access public
  99. * @return ref array An array of all nodes.
  100. */
  101. function getAllNodes() {
  102. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  103. }
  104. /**
  105. * Traverses the hierarchy and returns all the nodes in an array. The traversal
  106. * is a pre-order traversal starting from the specified node.
  107. * @access public
  108. * @param optional ref object node An optional node to start traversal from.
  109. * @return ref array An array of all nodes in the hierarchy visited in a pre-order
  110. * manner.
  111. */
  112. function traverse($node) {
  113. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  114. }
  115. }
  116.  
  117.  
  118. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:33 -0400 by phpDocumentor 1.3.0RC3