00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ZEITGEIST_NODE_H
00031 #define ZEITGEIST_NODE_H
00032
00033 #include <salt/defines.h>
00034 #include "class.h"
00035 #include "leaf.h"
00036
00037 namespace zeitgeist
00038 {
00039 #if 0
00040 }
00041 #endif
00042
00045 class Node : public Leaf
00046 {
00047
00048
00049
00050 public:
00052 Node(const std::string &name = "<Unnamed>");
00053 virtual ~Node();
00054
00055
00056
00059 virtual boost::shared_ptr<Leaf> GetChild(const std::string &name, bool recursive = false);
00060
00064 virtual boost::shared_ptr<Leaf> GetChildOfClass(const std::string &name, bool recursive = false);
00065
00069 virtual boost::shared_ptr<Leaf> GetChildSupportingClass(const std::string &name, bool recursive = false);
00070
00072 virtual void GetChildren(const std::string &name, TLeafList &baseList, bool recursive = false);
00073
00075 virtual void GetChildrenOfClass(const std::string &name, TLeafList &baseList, bool recursive = false);
00076
00080 virtual void GetChildrenSupportingClass(const std::string &name, TLeafList &baseList, bool recursive = false);
00081
00083 virtual bool IsLeaf() const;
00084
00086 virtual void UpdateCached();
00087
00089 virtual void RemoveChildReference(const boost::shared_ptr<Leaf> &base);
00090
00092 virtual void UnlinkChildren();
00093
00095 virtual bool AddChildReference(const boost::shared_ptr<Leaf> &base);
00096
00098 virtual void Dump() const;
00099
00100
00101 virtual TLeafList::iterator begin();
00102 virtual TLeafList::const_iterator begin() const;
00103 virtual TLeafList::iterator end();
00104 virtual TLeafList::const_iterator end() const;
00105 private:
00106 Node(const Node &obj);
00107 Node& operator=(const Node &obj);
00108
00109
00110
00111
00112 protected:
00113
00114 TLeafList mChildren;
00115 };
00116
00117
00118
00119
00127 template<class CLASS>
00128 boost::weak_ptr<CLASS>
00129 Leaf::FindParentSupportingClass() const
00130 {
00131 boost::shared_ptr<Node> node
00132 = boost::shared_static_cast<Node>(make_shared(GetParent()));
00133
00134 while (node.get() != 0)
00135 {
00136 boost::shared_ptr<CLASS> test =
00137 boost::shared_dynamic_cast<CLASS>(node);
00138
00139 if (test.get() != 0)
00140 {
00141 return test;
00142 }
00143
00144
00145 node = boost::shared_static_cast<Node>(node->GetParent().lock());
00146
00147 }
00148
00149 return boost::shared_ptr<CLASS>();
00150 }
00151
00152
00153 DECLARE_CLASS(Node);
00154
00155 }
00156
00157 #endif //ZEITGEIST_NODE_H