[dali_1.0.8] Merge branch 'tizen'
[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   SingletonService singletonService( SingletonService::Get() );
54   if ( singletonService )
55   {
56     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(LocalizedControlFactory));
57     if(handle)
58     {
59       // If so, downcast the handle of singleton to focus factory
60       factory = LocalizedControlFactory(dynamic_cast<Internal::LocalizedControlFactory*>(handle.GetObjectPtr()));
61     }
62
63     if(!factory)
64     {
65       // If not, create the focus factory and register it as a singleton
66       factory = LocalizedControlFactory(new Internal::LocalizedControlFactory());
67       singletonService.Register(typeid(factory), factory);
68     }
69   }
70
71   return factory;
72 }
73
74 LocalizedControlFactory::LocalizedControlFactory(Internal::LocalizedControlFactory *impl)
75   : BaseHandle(impl)
76 {
77 }
78
79 } // namespace Toolkit
80
81 } // namespace Dali