node.h

Go to the documentation of this file.
00001 #ifndef NODE_CLASS
00002 #define NODE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : node                                                              *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1992-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "node_dll.h"
00019 
00020 namespace nodes {
00021 
00022 // forward:
00023 class node_link_amorph;
00024 
00026 
00040 class NODES_CLASS_STYLE node
00041 {
00042 public:
00043   node(int number_of_links = 0);
00045 
00058   virtual ~node();
00060 
00065   int links() const;
00067 
00068   void set_link(int link_number, node *new_link);
00070 
00074   node *get_link(int link_number) const;
00076 
00078   void zap_link(int link_number);
00080 
00081   void insert_link(int where, node *to_add = NIL);
00083 
00088   int which(node *to_find) const;
00090 
00094 private:
00095   node_link_amorph *_links;  
00096 
00097   void set_empty(int link_number);
00099 
00100   // disallowed:
00101   node(const node &);
00102   node &operator =(const node &);
00103 };
00104 
00106 
00108 
00113 template <class contents>
00114 class basket : public node
00115 {
00116 public:
00117   basket(int links, const contents &to_store = contents())
00118           : node(links), _storage(to_store) {}
00119 
00120   basket(const basket &to_copy) { *this = to_copy; }
00121 
00122   basket &operator = (const contents &to_copy)
00123           { if (&to_copy != this) _storage = to_copy; return *this; }
00124 
00125   const contents &stored() const { return _storage; }
00127   contents &stored() { return _storage; }
00129 
00130 private:
00131   contents _storage;
00132 };
00133 
00134 } // end namespace.
00135 
00136 #endif
00137 

Generated on Fri Nov 28 04:29:17 2008 for HOOPLE Libraries by  doxygen 1.5.1