2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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.
20 #include <dali/internal/update/common/uniform-map.h>
29 void UniformMap::AddObserver( Observer& observer )
31 bool foundObserver = false;
32 for( ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
34 if( *iter == &observer )
42 mObservers.PushBack( &observer );
46 void UniformMap::RemoveObserver( Observer& observer )
48 for( ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
50 if( *iter == &observer )
52 mObservers.Erase(iter);
58 void UniformMap::MappingChanged()
60 for( ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
62 Observer* observer = (*iter);
63 observer->UniformMappingsChanged( *this );
67 void UniformMap::Add(UniformPropertyMapping newMap)
69 auto iter = std::find_if(mUniformMaps.Begin(),
71 [&](auto& element) { return element.uniformName == newMap.uniformName; });
73 if(iter != mUniformMaps.End())
75 // Mapping already exists - update it.
76 (*iter).propertyPtr = newMap.propertyPtr;
81 mUniformMaps.PushBack(newMap);
87 void UniformMap::Remove( ConstString uniformName )
89 auto iter = std::find_if(mUniformMaps.Begin(),
91 [&](auto& element) { return element.uniformName == uniformName; });
93 if(iter != mUniformMaps.End())
95 mUniformMaps.Erase(iter);
100 const PropertyInputImpl* UniformMap::Find(ConstString uniformName)
102 auto iter = std::find_if(mUniformMaps.Begin(),
104 [&](auto& element) { return element.uniformName == uniformName; });
106 return (iter != mUniformMaps.End()) ? (*iter).propertyPtr : nullptr;
109 UniformMap::SizeType UniformMap::Count() const
111 return static_cast<UniformMap::SizeType>( mUniformMaps.Count() );
114 const UniformPropertyMapping& UniformMap::operator[]( UniformMap::SizeType index ) const
116 return mUniformMaps[index];