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