xoreos  0.0.5
objectman.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
27 
29 
30 namespace Aurora {
31 
32 namespace NWScript {
33 
36 
37  uint32 id = object->getID();
38  if (_objects.find(id) == _objects.end())
39  _objects.insert(std::make_pair(id, object));
40 }
41 
44 
45  _objects.erase(object->getID());
46 }
47 
50 
51  std::map<uint32, Object *>::iterator it = _objects.find(id);
52  if (it == _objects.end())
53  return 0;
54 
55  return it->second;
56 }
57 
58 } // End of namespace NWScript
59 
60 } // End of namespace Aurora
uint32 getID() const
Definition: object.h:45
Object * findObject(uint32 id)
Definition: objectman.cpp:48
NWScript object manager.
#define DECLARE_SINGLETON(T)
Note that you need to use this macro from the global namespace.
Definition: singleton.h:122
void unregisterObject(Object *object)
Definition: objectman.cpp:42
Convenience class that locks a mutex on creation and unlocks it on destruction.
Definition: mutex.h:71
An NWScript object.
uint32_t uint32
Definition: types.h:204
std::map< uint32, Object * > _objects
Definition: objectman.h:49
void registerObject(Object *object)
Definition: objectman.cpp:34