Cleaning up the property framework; removal of duplicate methods and incorrect assers
[platform/core/uifw/dali-core.git] / dali / internal / event / object / custom-object-internal.cpp
1 /*
2  * Copyright (c) 2014 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
19 #include <dali/internal/event/object/custom-object-internal.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/common/stage-impl.h>
23 #include <dali/internal/update/common/animatable-property.h>
24 #include <dali/internal/update/common/property-owner.h>
25 #include <dali/internal/update/manager/update-manager.h>
26 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
27
28 using Dali::Internal::SceneGraph::PropertyOwner;
29 using Dali::Internal::SceneGraph::PropertyBase;
30 using Dali::Internal::SceneGraph::UpdateManager;
31 using Dali::Internal::SceneGraph::AnimatableProperty;
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 CustomObject* CustomObject::New()
40 {
41   return new CustomObject();
42 }
43
44 const SceneGraph::PropertyOwner* CustomObject::GetSceneObject() const
45 {
46   return mUpdateObject;
47 }
48
49 const PropertyBase* CustomObject::GetSceneObjectAnimatableProperty( Property::Index index ) const
50 {
51   CustomProperty* custom = FindCustomProperty( index );
52   DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
53   return custom->GetSceneGraphProperty();
54 }
55
56 const PropertyInputImpl* CustomObject::GetSceneObjectInputProperty( Property::Index index ) const
57 {
58   return GetSceneObjectAnimatableProperty( index );
59 }
60
61 unsigned int CustomObject::GetDefaultPropertyCount() const
62 {
63   return 0u;
64 }
65
66 void CustomObject::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
67 {
68 }
69
70 const char* CustomObject::GetDefaultPropertyName( Property::Index index ) const
71 {
72   return NULL;
73 }
74
75 Property::Index CustomObject::GetDefaultPropertyIndex(const std::string& name) const
76 {
77   return Property::INVALID_INDEX;
78 }
79
80 bool CustomObject::IsDefaultPropertyWritable(Property::Index index) const
81 {
82   return false;
83 }
84
85 bool CustomObject::IsDefaultPropertyAnimatable(Property::Index index) const
86 {
87   return false;
88 }
89
90 bool CustomObject::IsDefaultPropertyAConstraintInput( Property::Index index ) const
91 {
92   return false;
93 }
94
95 Property::Type CustomObject::GetDefaultPropertyType(Property::Index index) const
96 {
97   return Property::NONE;
98 }
99
100 void CustomObject::SetDefaultProperty( Property::Index index, const Property::Value& property )
101 {
102   // do nothing
103 }
104
105 Property::Value CustomObject::GetDefaultProperty(Property::Index index) const
106 {
107   return Property::Value();
108 }
109
110 CustomObject::~CustomObject()
111 {
112   // Guard to allow handle destruction after Core has been destroyed
113   if( Stage::IsInstalled() )
114   {
115     if( NULL != mUpdateObject )
116     {
117       RemoveObjectMessage( Stage::GetCurrent()->GetUpdateManager(), mUpdateObject );
118       mUpdateObject = NULL; // object is about to be destroyed
119     }
120   }
121 }
122
123 CustomObject::CustomObject()
124 {
125   PropertyOwner* updateObject = PropertyOwner::New();
126
127   // Pass ownership to the update-thread
128   AddObjectMessage( Stage::GetCurrent()->GetUpdateManager(), updateObject );
129
130   // Keep as const since this should only be modified from update-thread
131   mUpdateObject = updateObject;
132 }
133
134 } // namespace Internal
135
136 } // namespace Dali