Dali 3D User Interface Engine
object-connector.h
Go to the documentation of this file.
1 #ifndef DALI_INTERNAL_OBJECT_CONNECTOR_H
2 #define DALI_INTERNAL_OBJECT_CONNECTOR_H
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // INTERNAL INCLUDES
23 
24 namespace Dali
25 {
26 
27 namespace Internal
28 {
29 
35 template<typename Object>
37 {
38 public:
40 
45 
50 
54  ObjectConnector( const ObjectConnector& connector )
55  : mObject( connector.mObject )
56  {
57  }
58 
63  {
64  this->mObject = connector.mObject;
65  return *this;
66  }
67 
72  ObjectPtr Get() const
73  {
74  return mObject;
75  }
76 
82  void Set( Object& object, bool onStage )
83  {
84  if ( mObject.Get() != &object )
85  {
86  // Disconnect from old object
87  if ( mObject && onStage )
88  {
89  mObject->Disconnect();
90  }
91 
92  mObject = &object;
93 
94  // Connect to new object
95  if ( mObject && onStage )
96  {
97  mObject->Connect();
98  }
99  }
100  }
101 
108  {
109  if ( mObject )
110  {
111  mObject->Connect();
112  }
113  }
114 
121  {
122  if ( mObject )
123  {
124  mObject->Disconnect();
125  }
126  }
127 
128 private: //data
130 
131 };
132 
133 } // namespace Internal
134 
135 } // namespace Dali
136 
137 #endif // DALI_INTERNAL_OBJECT_CONNECTOR_H
Dali Docs Home
Read more about Dali