2
* This file is part of peekabot.
4
* peekabot is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* peekabot is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "IDTranslationTable.hh"
19
#include "SceneObject.hh"
22
using namespace peekabot;
25
// --------------------- IDTranslationTable implementation ---------------------
27
void IDTranslationTable::add_node_translation_entry(
28
ObjectID object_id, NodeID node_id) throw()
30
m_node_id_map.insert(std::make_pair(object_id, node_id));
34
void IDTranslationTable::remove_node_translation_entry(
35
ObjectID object_id) throw()
37
m_node_id_map.erase(object_id);
40
void IDTranslationTable::remove_node_translation_entries(
41
SceneObject *subtree) throw()
43
remove_node_translation_entry(subtree->get_object_id());
45
SceneObject::ChildContainer &children = subtree->get_children();
46
for( SceneObject::ChildContainer::iterator it = children.begin();
47
it != children.end(); ++it )
49
remove_node_translation_entries(*it);
53
NodeID IDTranslationTable::get_node_id(
54
ObjectID object_id) const throw()
56
NodeIDMap::const_iterator it = m_node_id_map.find(object_id);
58
if( it != m_node_id_map.end() )
61
return -1; /// \todo We should report errors somehow. Throw?
65
void IDTranslationTable::add_primitive_translation_entry(
66
ObjectID object_id, PrimitiveID primitive_id) throw()
68
m_primitive_id_map.insert(std::make_pair(object_id, primitive_id));
72
void IDTranslationTable::remove_primitive_translation_entry(
73
ObjectID object_id) throw()
75
m_primitive_id_map.erase(object_id);
78
void IDTranslationTable::remove_primitive_translation_entries(
79
SceneObject *subtree) throw()
81
remove_primitive_translation_entry(subtree->get_object_id());
83
SceneObject::ChildContainer &children = subtree->get_children();
84
for( SceneObject::ChildContainer::iterator it = children.begin();
85
it != children.end(); ++it )
87
remove_primitive_translation_entries(*it);
91
PrimitiveID IDTranslationTable::get_primitive_id(
92
ObjectID object_id) const throw()
94
PrimitiveIDMap::const_iterator it = m_primitive_id_map.find(object_id);
96
if( it != m_primitive_id_map.end() )
99
return -1; /// \todo We should report errors somehow. Throw?