Dali 3D User Interface Engine
constraint-base.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H__
2 #define __DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H__
3 
4 /*
5  * Copyright (c) 2014 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
27 
28 namespace Dali
29 {
30 
31 namespace Internal
32 {
33 
34 class EventThreadServices;
35 class Object;
38 
39 namespace SceneGraph
40 {
41 class ConstraintBase;
42 
43 template <typename T>
45 }
46 
51 {
52 public:
53 
55 
63  ConstraintBase( Object& object, Property::Index targetPropertyIndex, SourceContainer& sources );
64 
70  virtual ConstraintBase* Clone( Object& object ) = 0;
71 
75  virtual ~ConstraintBase();
76 
82  void AddSource( Source source );
83 
87  void Apply();
88 
92  void Remove();
93 
99  void RemoveInternal();
100 
105  Object* GetParent();
106 
111 
116 
120  void SetRemoveAction(RemoveAction action);
121 
126 
130  void SetTag(const unsigned int tag);
131 
135  unsigned int GetTag() const;
136 
137 private: // Object::Observer methods
138 
142  virtual void SceneObjectAdded( Object& object );
143 
147  virtual void SceneObjectRemoved( Object& object );
148 
152  virtual void ObjectDestroyed( Object& object );
153 
154 private:
155 
159  void ObserveObject( Object& object );
160 
164  void StopObservation();
165 
166  // To be implemented in derived classes
167 
171  virtual void ConnectConstraint() = 0;
172 
173 protected:
174 
183  {
185  return mEventThreadServices;
186  }
187 
196  {
198  return mEventThreadServices;
199  }
200 
201 protected:
206  ObjectContainer mObservedObjects; // We don't observe the same object twice
209  unsigned int mTag;
210  bool mApplied:1;
212 };
213 
214 } // namespace Internal
215 
216 // Helpers for public-api forwarding methods
217 
219 {
220  DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
221 
222  BaseObject& handle = constraint.GetBaseObject();
223 
224  return static_cast<Internal::ConstraintBase&>(handle);
225 }
226 
228 {
229  DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
230 
231  const BaseObject& handle = constraint.GetBaseObject();
232 
233  return static_cast<const Internal::ConstraintBase&>(handle);
234 }
235 
236 } // namespace Dali
237 
238 #endif // __DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H__
Dali Docs Home
Read more about Dali