X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Factor-observer.h;h=31adc3480593cc5fd2b15fcd5de5bb4fd84397b3;hb=c1df908470fc3dd242fef202248e56009727bca4;hp=3cc8b19b560ef8de1a864d918aac42c141467b89;hpb=44e58219df5016af2640db8c065cfc1520451f8e;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/actor-observer.h b/dali/internal/event/events/actor-observer.h index 3cc8b19..31adc34 100644 --- a/dali/internal/event/events/actor-observer.h +++ b/dali/internal/event/events/actor-observer.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_ACTOR_OBSERVER_H__ -#define __DALI_INTERNAL_ACTOR_OBSERVER_H__ +#ifndef DALI_INTERNAL_ACTOR_OBSERVER_H +#define DALI_INTERNAL_ACTOR_OBSERVER_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include namespace Dali @@ -44,17 +45,60 @@ public: ActorObserver(); /** + * Constructor with a callback which is called when the observed actor is removed from the scene. + * + * The callback should have the following signature: + * @code + * void MyCallback( Actor* actor ); + * @endcode + * Where actor is a pointer to the object that has been removed from the scene. + * + * @param[in] callback The callback to connect to. + * + * @note Ownership of callback is passed onto this class. + */ + ActorObserver( CallbackBase* callback ); + + /** * Non virtual destructor */ ~ActorObserver(); + // 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 ); + + /** + * 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 ); + + // 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. @@ -70,42 +114,36 @@ public: 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) { } + virtual void SceneObjectAdded( Object& object ); /** - * 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); + virtual void SceneObjectRemoved( Object& object ); /** * 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); + virtual void ObjectDestroyed( Object& object ); private: - Actor* mActor; ///< Raw pointer to an Actor. - bool mActorDisconnected; ///< Indicates whether the actor has been disconnected 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__ +#endif // DALI_INTERNAL_ACTOR_OBSERVER_H