Fix assetion error in FocusManager
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / factory / localized-control-factory.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
20 #include <dali-toolkit/public-api/factory/localized-control-factory.h>
21
22 // EXTERNAL INCLUDES
23
24 // INTERNAL INCLUDES
25
26 #include <dali-toolkit/internal/factory/localized-control-factory-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 Dali::Toolkit::TextView LocalizedControlFactory::CreateLocalizedTextView( const std::string& textID, const std::string& textDomain, const std::string& textViewTheme )
35 {
36   LocalizedControlFactory factory = Get();
37   return GetImpl(factory).CreateLocalizedTextView(textID, textDomain, textViewTheme);
38 }
39
40 LocalizedControlFactory::LocalizedControlFactory()
41 {
42 }
43
44 LocalizedControlFactory::~LocalizedControlFactory()
45 {
46 }
47
48 LocalizedControlFactory LocalizedControlFactory::Get()
49 {
50   LocalizedControlFactory factory;
51
52   // Check whether the focus factory is already created
53   Dali::Adaptor& adaptor = Dali::Adaptor::Get();
54   Dali::BaseHandle handle = adaptor.GetSingleton(typeid(LocalizedControlFactory));
55   if(handle)
56   {
57     // If so, downcast the handle of singleton to focus factory
58     factory = LocalizedControlFactory(dynamic_cast<Internal::LocalizedControlFactory*>(handle.GetObjectPtr()));
59   }
60
61   if(!factory)
62   {
63     // If not, create the focus factory and register it as a singleton
64     factory = LocalizedControlFactory(new Internal::LocalizedControlFactory());
65     adaptor.RegisterSingleton(typeid(factory), factory);
66   }
67
68   return factory;
69 }
70
71 LocalizedControlFactory::LocalizedControlFactory(Internal::LocalizedControlFactory *impl)
72   : BaseHandle(impl)
73 {
74 }
75
76 } // namespace Toolkit
77
78 } // namespace Dali