Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

node.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: node.h,v 1.12 2005/10/14 11:04:01 jamu Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 
00022         Node
00023 
00024         HISTORY:
00025                 15.06.2002 MK
00026                         - initial version
00027                 02.09.2002 MK
00028                         - removed quad-link
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     // functions
00049     //
00050 public:
00052     Node(const std::string &name = "<Unnamed>");
00053     virtual ~Node();
00054 
00055     // hierarchy
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     // iterator helpers
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     // members
00111     //
00112 protected:
00113     // object hierarchy related stuff
00114     TLeafList mChildren;
00115 };
00116 
00117 
00118 // define this here to avoid cyclic dependencies
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         //node = boost::shared_static_cast<Node>(make_shared(node->GetParent()));
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 } //namespace zeitgeist;
00156 
00157 #endif //ZEITGEIST_NODE_H

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4