22#ifndef QDENGINE_QDCORE_QD_OBJECT_MAP_CONTAINER_H
23#define QDENGINE_QDCORE_QD_OBJECT_MAP_CONTAINER_H
25#include "common/system.h"
27#include "qdengine/qdengine.h"
44 T *get_object(
const char *name);
45 const T *get_object(
const char *name)
const;
47 bool add_object(T *p);
48 bool remove_object(T *p);
49 bool rename_object(T *p,
const char *name);
50 bool remove_object(
const char *name);
51 bool is_in_list(
const char *name)
const {
52 return (get_object(name) != 0);
54 bool is_in_list(
const T *p)
const {
55 return (get_object(p->name()) != 0);
69 typename object_map_t::iterator it = _object_map.find(p->name());
70 if (it != _object_map.end())
73 _object_map[p->name()] = p;
74 _object_list.push_back(p);
80const T *qdObjectMapContainer<T>::get_object(
const char *name)
const {
82 typename object_map_t::const_iterator it = _object_map.find(name);
83 if (it != _object_map.end())
90T *qdObjectMapContainer<T>::get_object(
const char *name) {
91 typename object_map_t::iterator it = _object_map.find(name);
92 if (it != _object_map.end())
99bool qdObjectMapContainer<T>::remove_object(T *p) {
100 typename object_list_t::iterator it;
101 for (it = _object_list.begin(); it != _object_list.end(); it++) {
103 _object_list.erase(it);
104 typename object_map_t::iterator im = _object_map.find(p->name());
105 if (im != _object_map.end())
106 _object_map.erase(im);
116bool qdObjectMapContainer<T>::remove_object(
const char *name) {
117 T *p = get_object(name);
118 if (!p)
return false;
120 return remove_object(p);
124bool qdObjectMapContainer<T>::rename_object(T *p,
const char *name) {
125 typename object_map_t::iterator im = _object_map.find(p->name());
126 if (im != _object_map.end()) {
127 _object_map.erase(im);
129 _object_map[p->name()] = p;
137qdObjectMapContainer<T>::qdObjectMapContainer() {
141qdObjectMapContainer<T>::~qdObjectMapContainer() {
146bool qdObjectMapContainer<T>::clear() {
149 for (
typename object_list_t::iterator it = _object_list.begin(); it != _object_list.end(); ++it)
152 _object_list.clear();
Definition: qd_object_map_container.h:33
Базовый класс для игровых ресурсов.
Definition: console.h:28