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.
18 * @file FUiKeyEventManager.cpp
19 * @brief This is the implementation file for KeyEventManager class.
21 * @see Tizen::Ui::KeyEventManager
26 #include <FBaseSysLog.h>
27 #include <FUiControl.h>
28 #include <FUiKeyEventManager.h>
29 #include "FUi_KeyEventManagerImpl.h"
30 #include "FUi_ControlImpl.h"
32 using namespace Tizen::Ui;
34 namespace Tizen { namespace Ui
36 KeyEventManager* pKeyEventManagerInstance = null;
38 ////////////////////////////////////////////////////////////////////////////////
39 /// KeyEventManager class Lifecycle
41 KeyEventManager::KeyEventManager(void)
45 KeyEventManager::~KeyEventManager(void)
50 KeyEventManager::Construct(void)
56 KeyEventManager::GetInstance(void)
58 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
60 pthread_once(&once_block, InitializeInstance);
62 _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance();
68 return pKeyEventManagerInstance;
72 KeyEventManager::InitializeInstance(void)
74 static KeyEventManager instance;
75 pKeyEventManagerInstance = &instance;
79 ////////////////////////////////////////////////////////////////////////////////
80 /// KeyEventManager class Operation
83 KeyEventManager::AddKeyEventListener(IKeyEventListener& listener)
85 _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance();
86 SysAssertf(pEventImpl != null, "Not yet constructed. Construct() should be called before use.");
88 pEventImpl->AddKeyEventListener(listener);
92 KeyEventManager::RemoveKeyEventListener(IKeyEventListener& listener)
94 _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance();
95 SysAssertf(pEventImpl != null, "Not yet constructed. Construct() should be called before use.");
97 pEventImpl->RemoveKeyEventListener(listener);