2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.1 (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
8 * http://floralicense.org/license/
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.
17 * @file AppBoxObserver.cpp
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
23 #include <Core/Util/Log.h>
24 #include "AppBoxRenderView.h"
25 #include "AppBoxRenderBuffer.h"
26 #include "AppBoxObserver.h"
29 // static variable intialization
30 AppBoxObserver* AppBoxObserver::s_instance = NULL;
32 AppBoxObserver::AppBoxObserver()
33 : m_initialized(false)
40 AppBoxObserver::~AppBoxObserver()
45 AppBoxObserver* AppBoxObserver::Instance()
49 s_instance = new AppBoxObserver();
55 void AppBoxObserver::initialize()
59 LogD("already initialized");
66 void AppBoxObserver::shutdown()
70 LogD("not yet initialized");
74 m_initialized = false;
77 AppBoxRenderView* AppBoxObserver::getRenderView(std::string instanceId)
81 auto it = m_renderViewMap.find(instanceId);
82 if (it != m_renderViewMap.end()) {
83 LogD("registered: %s (%p)", it->first.c_str(), it->second);
90 void AppBoxObserver::registerRenderView(std::string instanceId, AppBoxRenderView* view)
94 if (getRenderView(instanceId)) {
95 LogD("already registered");
99 m_renderViewMap.insert(RenderViewMapPair(instanceId, view));
102 void AppBoxObserver::unregisterRenderView(std::string instanceId)
105 m_renderViewMap.erase(instanceId);
108 AppBoxRenderBuffer* AppBoxObserver::getRenderBuffer(std::string instanceId)
112 auto it = m_renderBufferMap.find(instanceId);
113 if (it != m_renderBufferMap.end()) {
114 LogD("registered: %s (%p)", it->first.c_str(), it->second);
121 void AppBoxObserver::registerRenderBuffer(std::string instanceId, AppBoxRenderBuffer* buffer)
125 if (getRenderBuffer(instanceId)) {
126 LogD("already registered");
130 m_renderBufferMap.insert(RenderBufferMapPair(instanceId, buffer));
133 void AppBoxObserver::unregisterRenderBuffer(std::string instanceId)
136 m_renderBufferMap.erase(instanceId);