1 /*****************************************************************************\
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 1992-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
18 #include <basis/astring.h>
19 #include <structures/stack.h>
23 using namespace basis;
24 using namespace structures;
27 #define LOG(to_print) printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s())
31 class path_node_stack : public stack<node *>
34 path_node_stack() : stack<node *>(0) {}
39 path::path(const node *start)
40 : _stack(new path_node_stack)
41 { _stack->push(const_cast<node *>(start)); }
43 path::path(const path &to_copy)
44 : _stack(new path_node_stack(*to_copy._stack))
49 while (_stack->elements()) _stack->pop();
53 node *path::operator [] (int index) const { return (*_stack)[index]; }
55 int path::size() const { return _stack->size(); }
57 node *path::root() const { return (*_stack)[0]; }
59 node *path::current() const { return _stack->top(); }
61 node *path::follow() const { return _stack->top(); }
63 path &path::operator = (const path &to_copy)
65 if (this == &to_copy) return *this;
66 *_stack = *to_copy._stack;
73 if (_stack->acquire_pop(to_return) != common::OKAY)
78 outcome path::push(node *to_add)
79 { return _stack->push(to_add); }
81 outcome path::push(int index)
83 if (!_stack->top()->get_link(index)) return common::NOT_FOUND;
84 return _stack->push(_stack->top()->get_link(index));
87 bool path::generate_path(node *to_locate, path &to_follow) const
89 FUNCDEF("generate_path")
91 if (to_locate || to_follow.current()) {}
92 LOG("hmmm: path::generate_path is not implemented.");