2 * Copyright (c) 2015 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/devel-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 );
54 mObject->RemoveObserver( *this );
59 * From Object::Observer
61 virtual void SceneObjectAdded( Internal::Object& object )
66 * From Object::Observer
68 virtual void SceneObjectRemoved( Internal::Object& object )
73 * From Object::Observer
75 virtual void ObjectDestroyed( Internal::Object& object )
81 Internal::Object* mObject;
84 WeakHandleBase::WeakHandleBase()
89 WeakHandleBase::WeakHandleBase( Handle& handle )
90 : mImpl( new Impl( handle ) )
94 WeakHandleBase::~WeakHandleBase()
100 WeakHandleBase::WeakHandleBase(const WeakHandleBase& handle)
103 Handle object = handle.GetBaseHandle();
104 mImpl = new Impl(object);
107 WeakHandleBase& WeakHandleBase::operator=( const WeakHandleBase& rhs )
113 Handle handle = rhs.GetBaseHandle();
114 mImpl = new Impl(handle);
120 bool WeakHandleBase::operator==( const WeakHandleBase& rhs ) const
122 return this->mImpl->mObject == rhs.mImpl->mObject;
125 bool WeakHandleBase::operator!=( const WeakHandleBase& rhs ) const
127 return !( *this == rhs );
130 Handle WeakHandleBase::GetBaseHandle() const
132 return Handle( mImpl->mObject );
135 void WeakHandleBase::Reset()