• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

src/SceneTree.hh

00001 /*
00002  * Copyright Staffan Gimåker 2006-2009.
00003  * Copyright Anders Boberg 2006.
00004  *
00005  * ---
00006  *
00007  * This file is part of peekabot.
00008  *
00009  * peekabot 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; either version 3 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * peekabot is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021  */
00022 
00023 #ifndef PEEKABOT_SCENE_TREE_HH_INCLUDED
00024 #define PEEKABOT_SCENE_TREE_HH_INCLUDED
00025 
00026 
00027 #include <map>
00028 #include <string>
00029 #include <boost/utility.hpp>
00030 #include <boost/thread/recursive_mutex.hpp>
00031 
00032 #include "Types.hh"
00033 
00034 
00035 namespace peekabot
00036 {
00037     class SceneObject;
00038     class SceneTreePtr;
00039 
00040 
00044     class SceneTree : public boost::noncopyable
00045     {
00046     public:
00047         SceneTree();
00048 
00049         virtual ~SceneTree() throw();
00050 
00051         SceneObject *get_root() throw();
00052 
00053         SceneObject *get_object(ObjectID id) throw();
00054 
00059         SceneObject *get_object(
00060             const std::string &path,
00061             SceneObject *path_parent = 0) throw();
00062 
00063     private:
00064         friend class SceneTreePtr;
00065 
00066         typedef boost::recursive_mutex SceneTreeMutex;
00067 
00068         SceneTreeMutex m_scene_mutex;
00069 
00070     private:
00071         SceneObject *m_root;
00072 
00076         class TranslationTable : public boost::noncopyable
00077         {
00078         public:
00087             TranslationTable(SceneObject *root) throw();
00088 
00089             SceneObject *translate(ObjectID id) const throw();
00090 
00091         private:
00092             void on_child_attached(SceneObject *object) throw();
00093 
00105             void on_detached(SceneObject *object) throw();
00106 
00107             bool add_rule(SceneObject *object) throw();
00108 
00109             bool remove_rule(SceneObject *object) throw();
00110 
00111         private:
00112             typedef std::map<ObjectID, SceneObject *> TranslationMap;
00113 
00114             TranslationMap m_id_map;
00115         };
00116 
00117         TranslationTable m_translation_table;
00118     };
00119 }
00120 
00121 
00122 #endif // PEEKABOT_SCENE_TREE_HH_INCLUDED

Generated on Sun Jan 30 2011 for peekabot by  doxygen 1.7.1