3395b4215b1ac1f4462deabe85b3f56288ea5ae5
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-view / text-actor-cache.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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
17 // CLASS HEADER
18 #include <dali-toolkit/internal/controls/text-view/text-actor-cache.h>
19
20 namespace Dali
21 {
22
23 namespace Toolkit
24 {
25
26 namespace Internal
27 {
28
29 TextActorCache::TextActorCache()
30 : mTextActors()
31 {
32 }
33
34 TextActorCache::~TextActorCache()
35 {
36 }
37
38 void TextActorCache::InsertTextActors( const std::vector<TextActor>& textActors )
39 {
40   mTextActors.insert( mTextActors.end(), textActors.rbegin(), textActors.rend() );
41 }
42
43 TextActor TextActorCache::RetrieveTextActor()
44 {
45   // Text-actors are inserted in the order needed to retrieve always the last one.
46
47   // Returns a non initialized handle if the cache is empty.
48   TextActor textActor;
49
50   if( !mTextActors.empty() )
51   {
52     textActor = mTextActors.back();
53     mTextActors.pop_back();
54   }
55
56   return textActor;
57 }
58
59 void TextActorCache::ClearTexts()
60 {
61   for( std::vector<TextActor>::iterator it = mTextActors.begin(); it != mTextActors.end(); ++it )
62   {
63     (*it).SetText("");
64   }
65 }
66
67 } // namespace Internal
68
69 } // namespace Toolkit
70
71 } // namespace Dali