235fbd43bca26e151b435d4f495af61df9144198
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-notification-manager.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 // INTERNAL INCLUDES
19 #include <dali/internal/event/common/property-notification-manager.h>
20 #include <dali/internal/event/common/property-notification-impl.h>
21
22 namespace Dali
23 {
24
25 namespace Internal
26 {
27
28 PropertyNotificationManager* PropertyNotificationManager::New()
29 {
30   return new PropertyNotificationManager;
31 }
32
33 PropertyNotificationManager::~PropertyNotificationManager()
34 {
35 }
36
37 void PropertyNotificationManager::PropertyNotificationCreated( PropertyNotification& propertyNotification )
38 {
39   mPropertyNotifications.insert( &propertyNotification );
40 }
41
42 void PropertyNotificationManager::PropertyNotificationDestroyed( PropertyNotification& propertyNotification )
43 {
44   std::set< PropertyNotification* >::iterator iter = std::find( mPropertyNotifications.begin(), mPropertyNotifications.end(), &propertyNotification );
45   DALI_ASSERT_ALWAYS( iter != mPropertyNotifications.end() && "PropertyNotification not found" );
46
47   mPropertyNotifications.erase( iter );
48 }
49
50 void PropertyNotificationManager::NotifyProperty( SceneGraph::PropertyNotification* propertyNotification, bool validity )
51 {
52   std::set< PropertyNotification* >::iterator iter = mPropertyNotifications.begin();
53   std::set< PropertyNotification* >::iterator endIter = mPropertyNotifications.end();
54
55   // walk the collection of PropertyNotifications
56   for( ; iter != endIter; ++iter )
57   {
58     // found one with the matching SceneGraph::PropertyNotification?
59     if( (*iter)->CompareSceneObject( propertyNotification ) )
60     {
61       // allow application to access the value that triggered this emit incase of NotifyOnChanged mode
62       (*iter)->SetNotifyResult(validity);
63       // yes..emit signal
64       (*iter)->EmitSignalNotify();
65       break;
66     }
67   }
68 }
69
70 PropertyNotificationManager::PropertyNotificationManager()
71 {
72 }
73
74 } // namespace Internal
75
76 } // namespace Dali
77