2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 * @author Karol Majewski (k.majewski@samsung.com)
22 #ifndef WRTPLUGINSIEVENTGETCAMERAS_H_
23 #define WRTPLUGINSIEVENTGETCAMERAS_H_
27 #include <dpl/shared_ptr.h>
28 #include <Commons/Exception.h>
29 #include <Commons/IEvent.h>
31 #include <Commons/WidgetConfiguration/ConfigurationSupport.h>
33 namespace WrtDeviceApis {
37 class EventGetCameras :
38 public WrtDeviceApis::Commons::ConfigurationSupport,
39 public WrtDeviceApis::Commons::IEvent<EventGetCameras>
42 EventGetCameras() : m_defaultCameraIndex(0) {}
44 void setCamerasRef(const std::vector< ICameraSharedPtr > &cameras,
45 std::size_t defaultCameraIndex)
48 m_defaultCameraIndex = defaultCameraIndex;
51 ICameraSharedPtr getCamera(std::size_t index)
53 if (index >= m_cameras.size() || m_cameras.size() == 0) {
54 Throw(Commons::InvalidArgumentException);
56 return m_cameras[index];
59 ICameraSharedPtr getDefaultCamera()
61 if (m_cameras.empty()) {
62 LogError("There are no cameras to choose from");
63 Throw(Commons::OutOfRangeException);
65 if (m_defaultCameraIndex >= m_cameras.size()) {
66 LogError("Default camera index is out of range");
67 Throw(Commons::InvalidArgumentException);
69 return m_cameras[m_defaultCameraIndex];
72 std::size_t getNumberOfCameras(){ return m_cameras.size(); }
75 std::vector< ICameraSharedPtr > m_cameras;
76 std::size_t m_defaultCameraIndex;
79 typedef DPL::SharedPtr<EventGetCameras> EventGetCamerasPtr;