1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "SceneCollection.h"
23 #include "SceneCollectionResource.h"
29 SceneCollection::SceneCollection(
30 const SceneCollectionResource::Ptr& sceneCollectionResource) :
31 m_sceneCollectionResource(sceneCollectionResource) {}
33 Scene::Ptr SceneCollection::addNewScene(const std::string& sceneName)
37 throw RCSInvalidParameterException("Scene name is an empty string");
40 m_sceneCollectionResource->addScene(sceneName);
42 return Scene::Ptr(new Scene(sceneName, m_sceneCollectionResource));
45 std::unordered_map< std::string, Scene::Ptr > SceneCollection::getScenes() const
47 std::unordered_map< std::string, Scene::Ptr > scenes;
49 for(const auto &it : m_sceneCollectionResource->getSceneValues())
51 Scene::Ptr scenePtr(new Scene(it, m_sceneCollectionResource));
52 scenes.insert(std::pair< std::string, Scene::Ptr >(it, scenePtr));
57 Scene::Ptr SceneCollection::getScene(const std::string& sceneName) const
59 auto sceneValues = m_sceneCollectionResource->getSceneValues();
60 auto it = std::find(sceneValues.begin(), sceneValues.end(), sceneName);
61 if(it == sceneValues.end())
63 throw RCSInvalidParameterException("Scene Name is Invalid!");
65 return Scene::Ptr(new Scene(sceneName, m_sceneCollectionResource));
68 void SceneCollection::setName(const std::string& name)
70 m_sceneCollectionResource->setName(name);
73 std::string SceneCollection::getName() const
75 return m_sceneCollectionResource->getName();
78 std::string SceneCollection::getId() const
80 return m_sceneCollectionResource->getId();
83 } /* namespace Service */