Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / resource / FUi_ResourceConfigLoader.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17 #include <pthread.h>
18 #include "FUi_ResourceConfigLoader.h"
19
20 using namespace Tizen::Base::Collection;
21
22 namespace Tizen { namespace Ui { namespace _Resource {
23
24 ConfigLoader* pColorLoader = null;
25
26 ConfigLoader*
27 ConfigLoader::GetInstance(void)
28 {
29         static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
30
31         if (pColorLoader == null)
32         {
33                 pthread_once(&onceBlock, CreateInstance);
34         }
35         return pColorLoader;
36 }
37
38 void
39 ConfigLoader::CreateInstance(void)
40 {
41         static ConfigLoader loader;
42         pColorLoader = &loader;
43 }
44
45 ConfigLoader::~ConfigLoader(void)
46 {
47         __itemList.RemoveAll();
48 }
49 void
50 ConfigLoader::AddInitFunc(_Init_Func func)
51 {
52         __itemList.Add(func);
53 }
54 int
55 ConfigLoader::GetInitFuncCount(void) const
56 {
57         return __itemList.GetCount();
58 }
59 bool
60 ConfigLoader::GetInitFunc(int index, _Init_Func& func) const
61 {
62         int count = __itemList.GetCount();
63         if (index >= count)
64         {
65                 return null;
66         }
67         return __itemList.GetAt(index, func);
68 }
69 ConfigLoader::ConfigLoader(void)
70         : __itemList()
71 {
72 }
73 }}}//Tizen::Ui::_Resource