Use existing callback ID for recurring callbacks
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / generic / accessibility-adaptor-impl-generic.cpp
1 /*
2  * Copyright (c) 2019 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/accessibility/common/accessibility-adaptor-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/devel-api/common/singleton-service.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace Adaptor
32 {
33
34 Dali::AccessibilityAdaptor AccessibilityAdaptor::Get()
35 {
36   Dali::AccessibilityAdaptor adaptor;
37
38   Dali::SingletonService service( SingletonService::Get() );
39   if ( service )
40   {
41     // Check whether the singleton is already created
42     Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) );
43     if(handle)
44     {
45       // If so, downcast the handle
46       adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) );
47     }
48     else
49     {
50       adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptor() );
51       service.Register( typeid( adaptor ), adaptor );
52     }
53   }
54
55   return adaptor;
56 }
57
58 void AccessibilityAdaptor::OnDestroy()
59 {
60   // Nothing to do here
61 }
62
63 } // namespace Adaptor
64
65 } // namespace Internal
66
67 } // namespace Dali