Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / renderer / engine-model / FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file                FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp
20  * @brief               This file contains implementation of PropertyHolderMaterial class
21  *
22  */
23
24 #include <renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.h>
25 #include <FUiEffects_RendererLog.h>
26
27 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel
28 {
29
30 PropertyHolderMaterial::PropertyHolderMaterial(void)
31 {
32 }
33
34 PropertyHolderMaterial::~PropertyHolderMaterial(void)
35 {
36 }
37
38 PropertyPtr
39 PropertyHolderMaterial::GetProperty(const std::string& name)
40 {
41         const PropertyListSizeType len = _properties.size();
42         for (PropertyListSizeType i = 0; len > i; ++i)
43         {
44                 if (name == _properties[i].first)
45                 {
46                         return _properties[i].second;
47                 }
48         }
49         return PropertyPtr();
50 }
51
52 PropertyPtr
53 PropertyHolderMaterial::GetProperty(PropertyListSizeType index)
54 {
55         if (_properties.size() > index)
56         {
57                 return _properties[index].second;
58         }
59         return PropertyPtr();
60 }
61
62 size_t
63 PropertyHolderMaterial::GetNumProperties(void)
64 {
65         return _properties.size();
66 }
67
68 void
69 PropertyHolderMaterial::AddProperty(const std::string& name, PropertyPtr pProperty)
70 {
71         const PropertyListSizeType len = _properties.size();
72         for (PropertyListSizeType i = 0; len > i; ++i)
73         {
74                 if (name == _properties[i].first)
75                 {
76                         _properties[i].second = pProperty;
77                         return;
78                 }
79         }
80         _properties.push_back(std::make_pair(name, pProperty));
81         return;
82 }
83
84 void
85 PropertyHolderMaterial::RemoveProperty(const std::string& name)
86 {
87         const PropertyListSizeType len = _properties.size();
88         for (PropertyListSizeType i = 0; len > i; ++i)
89         {
90                 if (name == _properties[i].first)
91                 {
92                         _properties[i] = _properties[len - 1];
93                         _properties.resize(len - 1);
94                         return;
95                 }
96         }
97         return;
98 }
99
100 void
101 PropertyHolderMaterial::RemoveProperty(PropertyListSizeType index)
102 {
103         const PropertyListSizeType len = _properties.size();
104         if (len <= index)
105         {
106                 return;
107         }
108         _properties[index] = _properties[len - 1];
109         _properties.resize(len - 1);
110         return;
111 }
112
113 }}}}} //Tizen::Ui::Effects::_Renderer::EngineModel