OLD | NEW |
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // Search the pack for all objects of a certain class. | 387 // Search the pack for all objects of a certain class. |
388 // This function is for Javascript. | 388 // This function is for Javascript. |
389 // Parameters: | 389 // Parameters: |
390 // class_type_name: the Class of the object. It is okay to pass base types | 390 // class_type_name: the Class of the object. It is okay to pass base types |
391 // for example Node::GetApparentClass()->name will return | 391 // for example Node::GetApparentClass()->name will return |
392 // both Transforms and Shapes. | 392 // both Transforms and Shapes. |
393 // Returns: | 393 // Returns: |
394 // Array of Object Pointers. | 394 // Array of Object Pointers. |
395 ObjectBaseArray GetObjectsByClassName(const String& class_type_name) const; | 395 ObjectBaseArray GetObjectsByClassName(const String& class_type_name) const; |
396 | 396 |
| 397 // Register the given object with the Pack. The pack will add a reference |
| 398 // to the object, guaranteeing its existence as long as the pack has not |
| 399 // been destroyed. This is public so that it can be called by static |
| 400 // factory methods. |
| 401 // Parameters: |
| 402 // object: Pointer to a ObjectBase to register within the pack |
| 403 void RegisterObject(ObjectBase *object); |
| 404 |
397 private: | 405 private: |
398 // Texture objects function as factories for RenderSurface objects. | 406 // Texture objects function as factories for RenderSurface objects. |
399 // Constructed RenderSurfaces are registered with the pack associated with | 407 // Constructed RenderSurfaces are registered with the pack associated with |
400 // the texture, so Texture is befriended to Pack for access to the | 408 // the texture, so Texture is befriended to Pack for access to the |
401 // RegisterObject routine below. | 409 // RegisterObject routine below. |
402 friend class Texture; | 410 friend class Texture; |
403 | 411 |
404 explicit Pack(ServiceLocator* service_locator); | 412 explicit Pack(ServiceLocator* service_locator); |
405 | 413 |
406 virtual ~Pack(); | 414 virtual ~Pack(); |
407 | 415 |
408 // Register the given object with the Pack. The pack will add a reference | |
409 // to the object, guaranteeing its existence as long as the pack has not | |
410 // been destroyed. | |
411 // Parameters: | |
412 // object: Pointer to a ObjectBase to register within the pack | |
413 void RegisterObject(ObjectBase *object); | |
414 | |
415 // Unregister a registered object from the pack. If this is the last reference | 416 // Unregister a registered object from the pack. If this is the last reference |
416 // to the object it will be destroyed. | 417 // to the object it will be destroyed. |
417 // Parameters: | 418 // Parameters: |
418 // object: Pointer to ObjectBase to unregister. | 419 // object: Pointer to ObjectBase to unregister. |
419 // Returns: | 420 // Returns: |
420 // false if the object was not in the pack. | 421 // false if the object was not in the pack. |
421 bool UnregisterObject(ObjectBase *object); | 422 bool UnregisterObject(ObjectBase *object); |
422 | 423 |
423 // Helper class used as less-than comparator for ordered container classes. | 424 // Helper class used as less-than comparator for ordered container classes. |
424 class IdObjectComparator { | 425 class IdObjectComparator { |
(...skipping 24 matching lines...) Expand all Loading... |
449 O3D_DECL_CLASS(Pack, NamedObject); | 450 O3D_DECL_CLASS(Pack, NamedObject); |
450 DISALLOW_COPY_AND_ASSIGN(Pack); | 451 DISALLOW_COPY_AND_ASSIGN(Pack); |
451 }; | 452 }; |
452 | 453 |
453 // Array container for Pack pointers. | 454 // Array container for Pack pointers. |
454 typedef std::vector<Pack*> PackArray; | 455 typedef std::vector<Pack*> PackArray; |
455 | 456 |
456 } // namespace o3d | 457 } // namespace o3d |
457 | 458 |
458 #endif // O3D_CORE_CROSS_PACK_H_ | 459 #endif // O3D_CORE_CROSS_PACK_H_ |
OLD | NEW |