feisty meow concerns codebase  2.140
path.h
Go to the documentation of this file.
1 #ifndef PATH_CLASS
2 #define PATH_CLASS
3 
4 /*****************************************************************************\
5 * *
6 * Name : path *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 1992-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include <basis/contracts.h>
19 #include <basis/enhance_cpp.h>
20 #include <basis/outcome.h>
21 
22 namespace nodes {
23 
24 // forward:
25 class node;
26 class path_node_stack;
27 
29 
35 class path : public virtual basis::nameable
36 {
37 public:
38  path(const node *root);
40 
43  path(const path &to_copy);
44 
45  ~path();
46 
48 
49  path &operator =(const path &to_copy);
50 
51  int size() const;
53 
54  node *root() const;
56 
57  node *current() const;
58  node *follow() const;
60 
62  node *pop();
64 
67  basis::outcome push(node *to_add);
69 
72  basis::outcome push(int index);
74 
77  bool generate_path(node *to_locate, path &to_follow) const;
79 
83  node *operator [] (int index) const;
85 
86 private:
87  path_node_stack *_stack;
88 };
89 
90 } // namespace.
91 
92 #endif
93 
Root object for any class that knows its own name.
Definition: contracts.h:123
Outcomes describe the state of completion for an operation.
Definition: outcome.h:31
An object representing the interstitial cell in most linked data structures.
Definition: node.h:41
A method for tracing a route from a tree's root to a particular node.
Definition: path.h:36
bool generate_path(node *to_locate, path &to_follow) const
finds the way to get from the root to the "to_locate" node.
Definition: path.cpp:87
node * current() const
Definition: path.cpp:59
path & operator=(const path &to_copy)
Definition: path.cpp:63
node * root() const
returns the relative root node for this path.
Definition: path.cpp:57
int size() const
returns the number of items in the path.
Definition: path.cpp:55
node * follow() const
Returns the node specified by this path.
Definition: path.cpp:61
path(const node *root)
the path is relative to the "root" node.
Definition: path.cpp:39
DEFINE_CLASS_NAME("path")
basis::outcome push(node *to_add)
puts the node "to_add" on the top of the stack.
Definition: path.cpp:78
node * operator[](int index) const
returns the node stored at "index", or NULL_POINTER if "index" is invalid.
Definition: path.cpp:53
node * pop()
returns the top node on the path stack.
Definition: path.cpp:70