Dali 3D User Interface Engine
weak-handle.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // INTERNAL INCLUDES
23 
24 namespace Dali
25 {
26 
28 {
29  // Construction
30  Impl()
31  : mObject( NULL )
32  {
33  }
34 
35  // Construction
36  Impl( Handle& handle )
37  : mObject( NULL )
38  {
39  if(handle)
40  {
41  mObject = static_cast<Internal::Object*>( handle.GetObjectPtr() );
42  if(mObject)
43  {
44  mObject->AddObserver( *this );
45  }
46  }
47  }
48 
49  // Destruction
51  {
52  if( mObject )
53  {
54  mObject->RemoveObserver( *this );
55  }
56  }
57 
61  virtual void SceneObjectAdded( Internal::Object& object )
62  {
63  }
64 
68  virtual void SceneObjectRemoved( Internal::Object& object )
69  {
70  }
71 
75  virtual void ObjectDestroyed( Internal::Object& object )
76  {
77  mObject = NULL;
78  }
79 
80  // Data
82 };
83 
85 : mImpl( new Impl() )
86 {
87 }
88 
90 : mImpl( new Impl( handle ) )
91 {
92 }
93 
95 {
96  delete mImpl;
97  mImpl = NULL;
98 }
99 
101 : mImpl( NULL )
102 {
103  Handle object = handle.GetBaseHandle();
104  mImpl = new Impl(object);
105 }
106 
108 {
109  if( this != &rhs )
110  {
111  delete mImpl;
112 
113  Handle handle = rhs.GetBaseHandle();
114  mImpl = new Impl(handle);
115  }
116 
117  return *this;
118 }
119 
121 {
122  return this->mImpl->mObject == rhs.mImpl->mObject;
123 }
124 
126 {
127  return !( *this == rhs );
128 }
129 
131 {
132  return Handle( mImpl->mObject );
133 }
134 
136 {
137  delete mImpl;
138  mImpl = NULL;
139 }
140 
141 
142 } // Dali
Dali Docs Home
Read more about Dali