Up: Classes   [Index]


ClassLibraryTree

ClassLibraryTree Class

A ClassLibraryTree application is a utility program that formats a tree of the available Ctalk class hierarchy.

The class lists the libraries in Ctalk’s default installation directory, and in any directories named by the ‘CLASSLIBDIRS’ environment variable.

The class contains one method, init, which collects the class and superclass information into a set TreeNode objects. The prototype of init is:


TreeNode instanceMethod init (TreeNode classTree, Boolean verbose);

After the method finishes the classTree object contains the classes and subclasses. You can then print or format the with the TreeNode methods format and print.

The verbose argument, if True, tells the method to print dots to indicate its progress.

Here is an example program that displays the class hierarchy on a terminal.


Boolean new verbose;

int main (int argc, char **argv) {

  TreeNode new tree;
  ClassLibraryTree new classTree;
  Integer new nParams;
  Integer new i;
  String new param;

  verbose = True;

  classTree parseArgs argc, argv;
  nParams = classTree cmdLineArgs size;

  for (i = 1; i < nParams; i++) {

    param = classTree cmdLineArgs at i;

    if (param == "-q") {
      verbose = False;
      continue;
    }

    if (param == "-h" || param == "--help") {
      printf ("Usage: classes [-q] [-h]\n");
      exit (0);
    }

  }

  classTree init tree, verbose;
  tree print;

  exit (0);
}

Instance Methods

init instance method (TreeNode tree, Boolean printDots)

Creates a a tree of the class library with tree as the root node of the tree. If printDots is true, prints the method’s progress on the terminal.