2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUi_UiBuilderControlTable.cpp
20 * @brief This is the implementation file for _UiBuilderControlTable class.
26 #include <FUiIOrientationEventListener.h>
27 #include <FBaseSysLog.h>
28 #include "FUi_UiBuilderControlTable.h"
29 #include "FUi_UiBuilder.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Ui;
35 namespace Tizen { namespace Ui
37 _UiBuilderControlTable::_UiBuilderControlTable(void)
38 : __pUiBuilderControlTableInFomationList(null)
40 if (__pUiBuilderControlTableInFomationList == null)
42 __pUiBuilderControlTableInFomationList = new (std::nothrow) ArrayListT<_UiBuilderControlTableInFomation*>;
46 _UiBuilderControlTable::~_UiBuilderControlTable(void)
48 if (__pUiBuilderControlTableInFomationList)
50 _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null;
51 int controlCount = __pUiBuilderControlTableInFomationList->GetCount();
52 for (int i = 0; i < controlCount; i++)
54 __pUiBuilderControlTableInFomationList->GetAt(i, pUiBuilderControlTableInFomation);
55 delete pUiBuilderControlTableInFomation;
57 __pUiBuilderControlTableInFomationList->RemoveAll();
58 delete __pUiBuilderControlTableInFomationList;
59 __pUiBuilderControlTableInFomationList = null;
63 _UiBuilderControlTableManager::_UiBuilderControlTableManager(void)
64 : __pControlTable(null)
69 _UiBuilderControlTableManager::~_UiBuilderControlTableManager(void)
75 _UiBuilderControlTableManager::Construct(void)
77 if (__pControlTable == null)
79 __pControlTable = new (std::nothrow) _UiBuilderControlTable;
80 SysTryReturn(NID_UI, __pControlTable != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _UiBuilderControlTable.");
86 _UiBuilderControlTableManager*
87 _UiBuilderControlTableManager::GetInstance()
90 static _UiBuilderControlTableManager* pUiBuilderControlTable = null;
92 if (pUiBuilderControlTable == null)
94 pUiBuilderControlTable = new (std::nothrow) _UiBuilderControlTableManager;
95 SysTryReturn(NID_UI, pUiBuilderControlTable != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _pUiBuilder.");
97 r = pUiBuilderControlTable->Construct();
98 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to construct _pUiBuilder.");
101 return pUiBuilderControlTable;
103 _UiBuilderControlTable*
104 _UiBuilderControlTableManager::GetControlTable() const
106 return __pControlTable;
110 _UiBuilderControlTableManager::RegisterControl(const Tizen::Base::String& controlMakerName, _UiBuilderControlMakerFunctionPointer pControlMakerFunctionPointer)
112 _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance();
113 _UiBuilderControlTable* pUiBuilderControlTable = null;
114 if(pUiBuilderControlTableManager != null && pControlMakerFunctionPointer != null)
116 pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable();
123 _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null;
124 pUiBuilderControlTableInFomation = new (std::nothrow) _UiBuilderControlTableInFomation;
125 if (pUiBuilderControlTableInFomation != null)
127 pUiBuilderControlTableInFomation->__controlMakerName = controlMakerName;
128 pUiBuilderControlTableInFomation->__pContolMakerFunctionPointer = pControlMakerFunctionPointer;
129 pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->Add(pUiBuilderControlTableInFomation);
133 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[UiBuilder] Failed to CreateControl()");
136 SysLog(NID_UI, "[UiBuilder]Register success [%ls]", pUiBuilderControlTableInFomation->__controlMakerName.GetPointer());
140 _UiBuilderControlTableManager::UnregisterControl(const Tizen::Base::String& controlMakerName)
142 _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance();
143 _UiBuilderControlTable* pUiBuilderControlTable = null;
144 if(controlMakerName.IsEmpty() == false)
146 pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable();
153 IEnumeratorT<_UiBuilderControlTableInFomation*>* pEnum = pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->GetEnumeratorN();
154 _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null;
156 while (pEnum->MoveNext() == E_SUCCESS)
158 pEnum->GetCurrent(pUiBuilderControlTableInFomation);
159 if (pUiBuilderControlTableInFomation->__controlMakerName.Equals(controlMakerName, false))
161 pUiBuilderControlTableInFomation->__pContolMakerFunctionPointer = null;
170 _UiBuilderControlTableManager::GetName(int index) const
172 _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance();
173 SysTryReturn(NID_UI, pUiBuilderControlTableManager != null, null, E_SYSTEM,
174 "[E_SYSTEM] IUnable to get the UiBuilderControlTableManager");
176 _UiBuilderControlTable* pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable();
178 _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null;
179 pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->GetAt(index, pUiBuilderControlTableInFomation);
180 SysTryReturn(NID_UI, pUiBuilderControlTableInFomation != null, L"", GetLastResult(), "Failed to GetControl()");
182 return (const Tizen::Base::String) pUiBuilderControlTableInFomation->__controlMakerName;
185 _UiBuilderControlMakerFunctionPointer
186 _UiBuilderControlTableManager::GetControlMaker(int index) const
189 _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance();
190 SysTryReturn(NID_UI, pUiBuilderControlTableManager != null, null, E_SYSTEM,
191 "[E_SYSTEM] IUnable to get the UiBuilderControlTableManager");
193 _UiBuilderControlTable* pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable();
194 _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null;
195 pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->GetAt(index, pUiBuilderControlTableInFomation);
196 SysTryReturn(NID_UI, pUiBuilderControlTableInFomation != null, null, GetLastResult(), "Failed to GetControl()");
198 return pUiBuilderControlTableInFomation->__pContolMakerFunctionPointer;