Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: core/cross/object_manager.cc

Issue 151103: Changed way Packs cannot be created if there is no Renderer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 25 matching lines...) Expand all
36 #include "core/cross/pack.h" 36 #include "core/cross/pack.h"
37 #include "core/cross/client.h" 37 #include "core/cross/client.h"
38 38
39 namespace o3d { 39 namespace o3d {
40 40
41 const InterfaceId ObjectManager::kInterfaceId = 41 const InterfaceId ObjectManager::kInterfaceId =
42 InterfaceTraits<ObjectManager>::kInterfaceId; 42 InterfaceTraits<ObjectManager>::kInterfaceId;
43 43
44 ObjectManager::ObjectManager(ServiceLocator* service_locator) 44 ObjectManager::ObjectManager(ServiceLocator* service_locator)
45 : service_locator_(service_locator), 45 : service_locator_(service_locator),
46 service_(service_locator_, this), 46 service_(service_locator_, this) {
47 allow_pack_creation_(true) {
48 } 47 }
49 48
50 ObjectManager::~ObjectManager() { 49 ObjectManager::~ObjectManager() {
51 // Free all the packs. 50 // Free all the packs.
52 pack_array_.clear(); 51 pack_array_.clear();
53 52
54 DLOG_ASSERT(object_map_.empty()) << "Client node leak."; 53 DLOG_ASSERT(object_map_.empty()) << "Client node leak.";
55 } 54 }
56 55
57 void ObjectManager::DisallowPackCreation() {
58 allow_pack_creation_ = false;
59 }
60
61 std::vector<ObjectBase*> ObjectManager::GetObjects( 56 std::vector<ObjectBase*> ObjectManager::GetObjects(
62 const String& name, 57 const String& name,
63 const String& class_type_name) const { 58 const String& class_type_name) const {
64 ObjectBaseArray objects; 59 ObjectBaseArray objects;
65 ObjectMap::const_iterator end(object_map_.end()); 60 ObjectMap::const_iterator end(object_map_.end());
66 for (ObjectMap::const_iterator iter(object_map_.begin()); 61 for (ObjectMap::const_iterator iter(object_map_.begin());
67 iter != end; 62 iter != end;
68 ++iter) { 63 ++iter) {
69 if (iter->second->IsAClassName(class_type_name) && 64 if (iter->second->IsAClassName(class_type_name) &&
70 iter->second->IsA(NamedObjectBase::GetApparentClass()) && 65 iter->second->IsA(NamedObjectBase::GetApparentClass()) &&
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 pack); 122 pack);
128 DLOG_ASSERT(iter != pack_array_.end()) << "Destruction of unknown pack."; 123 DLOG_ASSERT(iter != pack_array_.end()) << "Destruction of unknown pack.";
129 if (iter != pack_array_.end()) { 124 if (iter != pack_array_.end()) {
130 pack_array_.erase(iter); 125 pack_array_.erase(iter);
131 return true; 126 return true;
132 } 127 }
133 return false; 128 return false;
134 } 129 }
135 130
136 Pack* ObjectManager::CreatePack() { 131 Pack* ObjectManager::CreatePack() {
137 if (!allow_pack_creation_) {
138 O3D_ERROR(service_locator_) << "Pack creation not allowed";
139 return NULL;
140 }
141 Pack::Ref pack(new Pack(service_locator_)); 132 Pack::Ref pack(new Pack(service_locator_));
142 if (pack) { 133 if (pack) {
143 pack_array_.push_back(pack); 134 pack_array_.push_back(pack);
144 } 135 }
145 return pack; 136 return pack;
146 } 137 }
147 138
148 void ObjectManager::DestroyAllPacks() { 139 void ObjectManager::DestroyAllPacks() {
149 pack_array_.clear(); 140 pack_array_.clear();
150 } 141 }
151 } // namespace o3d 142 } // namespace o3d
OLDNEW
« core/cross/client.cc ('K') | « core/cross/object_manager.h ('k') | core/cross/pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698