Browse Source

Object const-correctness.

Const function shouldn̈́'t return anything with which it would be possible
to change object's internal state:

 * It is possible to get non-constant pointer to itself from
   parent().children() array, so parent() cannot be const function.
 * The same applies to scene().
 * It is also possible to get non-constant pointer to itself from
   children()[0].parent(), so children() also cannot be const function.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
72e667b9fd
  1. 2
      src/Object.cpp
  2. 6
      src/Object.h

2
src/Object.cpp

@ -79,7 +79,7 @@ Object::~Object() {
delete *_children.begin();
}
Scene* Object::scene() const {
Scene* Object::scene() {
/* Goes up the family tree until it finds object which is parent of itself
(that's the scene) */
Object* p = parent();

6
src/Object.h

@ -65,13 +65,13 @@ class MAGNUM_EXPORT Object {
* @brief %Scene
* @return If the object is not assigned to any scene, returns nullptr.
*/
Scene* scene() const;
Scene* scene();
/** @brief Parent object */
inline Object* parent() const { return _parent; }
inline Object* parent() { return _parent; }
/** @brief Child objects */
inline const std::set<Object*>& children() const { return _children; }
inline const std::set<Object*>& children() { return _children; }
/** @brief Set parent object */
void setParent(Object* parent);

Loading…
Cancel
Save