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