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

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

Issue 155276: Add ClientInfo... (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 21 matching lines...) Expand all
32 32
33 #ifndef O3D_CORE_CROSS_OBJECT_MANAGER_H_ 33 #ifndef O3D_CORE_CROSS_OBJECT_MANAGER_H_
34 #define O3D_CORE_CROSS_OBJECT_MANAGER_H_ 34 #define O3D_CORE_CROSS_OBJECT_MANAGER_H_
35 35
36 #include <map> 36 #include <map>
37 #include <vector> 37 #include <vector>
38 38
39 #include "core/cross/object_base.h" 39 #include "core/cross/object_base.h"
40 #include "core/cross/named_object.h" 40 #include "core/cross/named_object.h"
41 #include "core/cross/service_implementation.h" 41 #include "core/cross/service_implementation.h"
42 #include "core/cross/service_dependency.h"
42 #include "core/cross/types.h" 43 #include "core/cross/types.h"
43 #include "core/cross/error.h" 44 #include "core/cross/error.h"
44 45
45 namespace o3d { 46 namespace o3d {
46 47
47 class Pack; 48 class Pack;
48 49
49 // Maintains a collection of all objects deriving from ObjectBase. Objects and 50 // Maintains a collection of all objects deriving from ObjectBase. Objects and
50 // lists of objects can be found based on various criteria. 51 // lists of objects can be found based on various criteria.
51 class ObjectManager { 52 class ObjectManager {
52 public: 53 public:
53
54 static const InterfaceId kInterfaceId; 54 static const InterfaceId kInterfaceId;
55 55
56 explicit ObjectManager(ServiceLocator* service_locator); 56 explicit ObjectManager(ServiceLocator* service_locator);
57 ~ObjectManager(); 57 ~ObjectManager();
58 58
59 // Disallows pack creation. 59 // Disallows pack creation.
60 void DisallowPackCreation(); 60 void DisallowPackCreation();
61 61
62 // Searches in the Client for a base object by its id. If the dynamic type 62 // Searches in the Client for a base object by its id. If the dynamic type
63 // of the object matches the requested type, then a pointer to the instance 63 // of the object matches the requested type, then a pointer to the instance
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Creates a pack object, and registers it within the Client's internal 176 // Creates a pack object, and registers it within the Client's internal
177 // dictionary strutures. Note that multiple packs may share the same name. 177 // dictionary strutures. Note that multiple packs may share the same name.
178 // The system does not enforce pack name uniqueness. 178 // The system does not enforce pack name uniqueness.
179 // Returns: 179 // Returns:
180 // A smart-pointer reference to the newly created pack object. 180 // A smart-pointer reference to the newly created pack object.
181 Pack* CreatePack(); 181 Pack* CreatePack();
182 182
183 // Destroys all registered packs. 183 // Destroys all registered packs.
184 void DestroyAllPacks(); 184 void DestroyAllPacks();
185 185
186 size_t GetNumObjects() const {
187 return object_map_.size();
188 }
189
186 private: 190 private:
187
188 typedef std::vector<SmartPointer<Pack> > PackRefArray; 191 typedef std::vector<SmartPointer<Pack> > PackRefArray;
189 192
190 // Dictionary of Objects indexed by their unique ID 193 // Dictionary of Objects indexed by their unique ID
191 typedef std::map<Id, ObjectBase*> ObjectMap; 194 typedef std::map<Id, ObjectBase*> ObjectMap;
192 195
193 ServiceLocator* service_locator_; 196 ServiceLocator* service_locator_;
194 ServiceImplementation<ObjectManager> service_; 197 ServiceImplementation<ObjectManager> service_;
195 198
196 // Map of objects to Ids 199 // Map of objects to Ids
197 ObjectMap object_map_; 200 ObjectMap object_map_;
198 201
199 // Array required to maintain references to the currently live pack objects. 202 // Array required to maintain references to the currently live pack objects.
200 PackRefArray pack_array_; 203 PackRefArray pack_array_;
201 204
202 DISALLOW_COPY_AND_ASSIGN(ObjectManager); 205 DISALLOW_COPY_AND_ASSIGN(ObjectManager);
203 }; 206 };
204 } // namespace o3d 207 } // namespace o3d
205 208
206 #endif // O3D_CORE_CROSS_OBJECT_MANAGER_H_ 209 #endif // O3D_CORE_CROSS_OBJECT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698