784ffbdf77df24f92c6cc441467fa7d5f59bb2da
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / relayout-controller.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 // FILE HEADER
19
20 #include "relayout-controller.h"
21 #include "relayout-controller-impl.h"
22
23 // EXTERNAL INCLUDES
24
25 #include <boost/thread/tss.hpp>
26 #include <stack>
27 #include <sstream>
28 #include <dali/integration-api/debug.h>
29
30 // INTERNAL INCLUDES
31
32 #include "dali-toolkit/public-api/controls/control.h"
33 #include "dali-toolkit/public-api/controls/control-impl.h"
34 #include "dali-toolkit/public-api/controls/text-view/text-view.h"
35
36 namespace Dali
37 {
38
39 namespace Toolkit
40 {
41
42 namespace Internal
43 {
44
45 RelayoutController::RelayoutController()
46 {
47
48 }
49
50 RelayoutController::~RelayoutController()
51 {
52
53 }
54
55 RelayoutController RelayoutController::Get()
56 {
57   RelayoutController controller;
58
59   // Check whether the RelayoutController is already created
60   Dali::Adaptor& adaptor = Dali::Adaptor::Get();
61   Dali::BaseHandle handle = adaptor.GetSingleton(typeid(RelayoutController));
62
63   if(handle)
64   {
65     // If so, downcast the handle of singleton to RelayoutController
66     controller = RelayoutController(dynamic_cast<Internal::RelayoutControllerImpl*>(handle.GetObjectPtr()));
67   }
68
69   if(!controller)
70   {
71     // If not, create the RelayoutController and register it as a singleton
72     controller = RelayoutController(new Internal::RelayoutControllerImpl());
73     adaptor.RegisterSingleton(typeid(controller), controller);
74   }
75
76   return controller;
77 }
78
79 RelayoutController::RelayoutController(Internal::RelayoutControllerImpl *impl)
80   : BaseHandle(impl)
81 {
82 }
83
84 void RelayoutController::Request()
85 {
86   GetImpl(*this).Request();
87 }
88
89
90 } // namespace Internal
91
92 } // namespace Toolkit
93
94 } // namespace Dali
95