2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/object/weak-handle.h>
22 #include <dali/internal/event/common/object-impl.h>
27 struct WeakHandleBase::Impl : public Internal::Object::Observer
36 Impl( Handle& handle )
41 mObject = static_cast<Internal::Object*>( handle.GetObjectPtr() );
44 mObject->AddObserver( *this );
59 mObject->RemoveObserver( *this );
65 * From Object::Observer
67 virtual void SceneObjectAdded( Internal::Object& object )
72 * From Object::Observer
74 virtual void SceneObjectRemoved( Internal::Object& object )
79 * From Object::Observer
81 virtual void ObjectDestroyed( Internal::Object& object )
87 Internal::Object* mObject;
90 WeakHandleBase::WeakHandleBase()
95 WeakHandleBase::WeakHandleBase( Handle& handle )
96 : mImpl( new Impl( handle ) )
100 WeakHandleBase::~WeakHandleBase()
106 WeakHandleBase::WeakHandleBase(const WeakHandleBase& handle)
109 Handle object = handle.GetBaseHandle();
110 mImpl = new Impl(object);
113 WeakHandleBase& WeakHandleBase::operator=( const WeakHandleBase& rhs )
119 Handle handle = rhs.GetBaseHandle();
120 mImpl = new Impl(handle);
126 bool WeakHandleBase::operator==( const WeakHandleBase& rhs ) const
128 return this->mImpl->mObject == rhs.mImpl->mObject;
131 bool WeakHandleBase::operator!=( const WeakHandleBase& rhs ) const
133 return !( *this == rhs );
136 Handle WeakHandleBase::GetBaseHandle() const
138 return Handle( mImpl->mObject );
141 void WeakHandleBase::Reset()