00001 #ifndef NODE_CLASS
00002 #define NODE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "node_dll.h"
00019
00020 namespace nodes {
00021
00022
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
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 }
00135
00136 #endif
00137