#define DALI_INTERNAL_ACTOR_OBSERVER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/signals/callback.h>
#include <dali/internal/event/common/object-impl.h>
+#include <dali/public-api/signals/callback.h>
namespace Dali
{
-
namespace Internal
{
-
class Actor;
/**
struct ActorObserver : public Object::Observer
{
public:
-
// Construction & Destruction
/**
*
* @note Ownership of callback is passed onto this class.
*/
- ActorObserver( CallbackBase* callback );
+ ActorObserver(CallbackBase* callback);
/**
* Non virtual destructor
*/
- ~ActorObserver();
+ ~ActorObserver() override;
+
+ // Movable
+
+ /**
+ * Move constructor.
+ *
+ * @param[in] other The object to move the data from
+ *
+ * @note The other's actor is appropriately disconnected.
+ * @note Ownership of callback is passed onto this class.
+ */
+ ActorObserver(ActorObserver&& other) noexcept;
+
+ /**
+ * Move assignment operator.
+ *
+ * @param[in] other The object to move the data from
+ *
+ * @note The other's actor is appropriately disconnected.
+ * @note Ownership of callback is passed onto this class.
+ */
+ ActorObserver& operator=(ActorObserver&& other) noexcept;
+
+ // Not copyable
+
+ ActorObserver(const ActorObserver&) = delete; ///< Deleted copy constructor.
+ ActorObserver& operator=(const ActorObserver&) = delete; ///< Deleted copy assignment operator.
// Methods
/**
* Return the stored Actor pointer.
* @return The Actor pointer.
+ * @note Returns nullptr while the observed actor is not on the scene.
*/
- Actor* GetActor();
+ Actor* GetActor() const;
/**
* Assignment operator.
* This disconnects the required signals from the currently set actor and connects to the required
* signals for the the actor specified (if set).
*/
- void SetActor( Actor* actor );
+ void SetActor(Actor* actor);
/**
* Resets the set actor and disconnects any connected signals.
void ResetActor();
private:
-
- // Undefined
- ActorObserver( const ActorObserver& );
- ActorObserver& operator=( const ActorObserver& );
-
-private:
-
/**
- * This will never get called as we do not observe objects that have not been added to the scene.
+ * This will be called if an actor is added to the scene.
* @param[in] object The object object.
* @see Object::Observer::SceneObjectAdded()
*/
- virtual void SceneObjectAdded(Object& object) { }
+ void SceneObjectAdded(Object& object) override;
/**
- * This will be called when the actor is removed from the stage, we should clear and stop
- * observing it.
+ * This will be called when the actor is removed from the scene.
* @param[in] object The object object.
* @see Object::Observer::SceneObjectRemoved()
*/
- virtual void SceneObjectRemoved(Object& object);
+ void SceneObjectRemoved(Object& object) override;
/**
* This will be called when the actor is destroyed. We should clear the actor.
* No need to stop observing as the object is being destroyed anyway.
* @see Object::Observer::ObjectDestroyed()
*/
- virtual void ObjectDestroyed(Object& object);
+ void ObjectDestroyed(Object& object) override;
private:
- Actor* mActor; ///< Raw pointer to an Actor.
- bool mActorDisconnected; ///< Indicates whether the actor has been disconnected from the scene
- CallbackBase* mRemoveCallback; ///< Callback to call when the observed actor is removed from the scene
+ Actor* mActor; ///< Raw pointer to an Actor.
+ bool mActorDisconnected; ///< Indicates whether the actor has been disconnected from the scene
+ CallbackBase* mRemoveCallback; ///< Callback to call when the observed actor is removed from the scene
};
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_ACTOR_OBSERVER_H
-