3bdb2c15a1ad9c8904f7a2b279ae48b8f6ff9bf2
[framework/web/wrt-plugins-common.git] / src / modules / tizen / DEPRACATED / Display / Manager.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #include "Manager.h"
17 #include <commons/Exception.h>
18 #include "Screen.h"
19
20 namespace {
21 const std::size_t NUMBER_OF_AVAILABLE_SCREENS = 1;
22 const std::size_t INDEX_OF_DEFAULT_SCREEN = 1;
23 } // anonymous
24
25 namespace WrtPlugins {
26 namespace Platform {
27 namespace Display {
28 Manager& Manager::getInstance()
29 {
30     static Manager instance;
31     return instance;
32 }
33
34 Api::Display::IScreen* Manager::getScreen(std::size_t index) const
35 {
36     if (index == 0) {
37         index = INDEX_OF_DEFAULT_SCREEN;
38     }
39
40     if (index > NUMBER_OF_AVAILABLE_SCREENS) {
41         ThrowMsg(Commons::OutOfRangeException, "Screen is not available.");
42     }
43
44     Screens::iterator it = m_screens.find(index);
45     if (it == m_screens.end()) {
46         Api::Display::IScreen* screen = new Screen(index);
47         m_screens.insert(Screens::value_type(index, screen));
48         return screen;
49     }
50     return it->second;
51 }
52
53 std::size_t Manager::getScreensCount() const
54 {
55     return NUMBER_OF_AVAILABLE_SCREENS;
56 }
57
58 Manager::~Manager()
59 {
60     Screens::iterator it = m_screens.begin();
61     for (; it != m_screens.end(); ++it) {
62         delete it->second;
63     }
64 }
65
66 Manager::Manager()
67 {
68 }
69 } // Display
70 } // Platform
71 } // WrtPlugins