[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-value.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/public-api/object/property-value.h>
19
20 // EXTERNAL INCLUDES
21 #include <boost/any.hpp>
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/math/angle-axis.h>
25 #include <dali/public-api/math/radian.h>
26 #include <dali/public-api/math/vector2.h>
27 #include <dali/public-api/math/vector3.h>
28 #include <dali/public-api/math/vector4.h>
29 #include <dali/public-api/math/matrix3.h>
30 #include <dali/public-api/math/matrix.h>
31 #include <dali/public-api/math/rect.h>
32 #include <dali/public-api/math/quaternion.h>
33 #include <dali/public-api/object/property-types.h>
34 #include <dali/integration-api/debug.h>
35
36 namespace Dali
37 {
38
39 struct Property::Value::Impl
40 {
41   Impl()
42   : mType( Property::NONE )
43   {
44   }
45
46   Impl(bool boolValue)
47   : mType( PropertyTypes::Get<bool>() ),
48     mValue( boolValue )
49   {
50   }
51
52   Impl(float floatValue)
53   : mType( PropertyTypes::Get<float>() ),
54     mValue( floatValue )
55   {
56   }
57
58   Impl(int integerValue)
59   : mType( PropertyTypes::Get<int>() ),
60     mValue( integerValue )
61   {
62   }
63
64   Impl(unsigned int unsignedIntegerValue)
65   : mType( PropertyTypes::Get<unsigned int>() ),
66     mValue( unsignedIntegerValue )
67   {
68   }
69
70   Impl(const Vector2& vectorValue)
71   : mType( PropertyTypes::Get<Vector2>() ),
72     mValue( vectorValue )
73   {
74   }
75
76   Impl(const Vector3& vectorValue)
77   : mType( PropertyTypes::Get<Vector3>() ),
78     mValue( vectorValue )
79   {
80   }
81
82   Impl(const Vector4& vectorValue)
83   : mType( PropertyTypes::Get<Vector4>() ),
84     mValue( vectorValue )
85   {
86   }
87
88   Impl(const Matrix3& matrixValue)
89   : mType(PropertyTypes::Get<Matrix3>()),
90     mValue(matrixValue)
91   {
92   }
93
94   Impl(const Matrix& matrixValue)
95   : mType(PropertyTypes::Get<Matrix>()),
96     mValue(matrixValue)
97   {
98   }
99
100   Impl(const AngleAxis& angleAxisValue)
101   : mType( PropertyTypes::Get<AngleAxis>() ),
102     mValue( angleAxisValue )
103   {
104   }
105
106   Impl(const Quaternion& quaternionValue)
107   : mType( PropertyTypes::Get<Quaternion>() ),
108     mValue( quaternionValue )
109   {
110   }
111
112   Impl(const std::string& stringValue)
113     : mType( PropertyTypes::Get<std::string>() ),
114       mValue( stringValue )
115   {
116   }
117
118   Impl(const Rect<int>& rect)
119     : mType( PropertyTypes::Get<Rect<int> >() ),
120       mValue( rect )
121   {
122   }
123
124   Impl(Property::Map container)
125     : mType( PropertyTypes::Get<Property::Map >() ),
126       mValue( container )
127   {
128   }
129
130   Impl(Property::Array container)
131     : mType( PropertyTypes::Get<Property::Array >() ),
132       mValue( container )
133   {
134   }
135
136   Type mType;
137
138   typedef boost::any AnyValue;
139   AnyValue mValue;
140 };
141
142 Property::Value::Value()
143 : mImpl( NULL )
144 {
145   mImpl = new Impl();
146 }
147
148 Property::Value::Value(bool boolValue)
149 : mImpl( NULL )
150 {
151   mImpl = new Impl( boolValue );
152 }
153
154 Property::Value::Value(float floatValue)
155 : mImpl( NULL )
156 {
157   mImpl = new Impl( floatValue );
158 }
159
160 Property::Value::Value(int integerValue)
161 : mImpl( NULL )
162 {
163   mImpl = new Impl( integerValue );
164 }
165
166 Property::Value::Value(unsigned int unsignedIntegerValue)
167 : mImpl( NULL )
168 {
169   mImpl = new Impl( unsignedIntegerValue );
170 }
171
172 Property::Value::Value(const Vector2& vectorValue)
173 : mImpl( NULL )
174 {
175   mImpl = new Impl( vectorValue );
176 }
177
178 Property::Value::Value(const Vector3& vectorValue)
179 : mImpl( NULL )
180 {
181   mImpl = new Impl( vectorValue );
182 }
183
184 Property::Value::Value(const Vector4& vectorValue)
185 : mImpl( NULL )
186 {
187   mImpl = new Impl( vectorValue );
188 }
189
190 Property::Value::Value(const Matrix3& matrixValue)
191 : mImpl( NULL )
192 {
193   mImpl = new Impl( matrixValue );
194 }
195
196 Property::Value::Value(const Matrix& matrixValue)
197 : mImpl( NULL )
198 {
199   mImpl = new Impl( matrixValue );
200 }
201
202 Property::Value::Value(const Rect<int>& rect)
203 : mImpl( NULL )
204 {
205   mImpl = new Impl( rect );
206 }
207
208 Property::Value::Value(const AngleAxis& angleAxisValue)
209 : mImpl( NULL )
210 {
211   mImpl = new Impl( angleAxisValue );
212 }
213
214 Property::Value::Value(const Quaternion& quaternionValue)
215 {
216   mImpl = new Impl( quaternionValue );
217 }
218
219 Property::Value::Value(const std::string& stringValue)
220 {
221   mImpl = new Impl( stringValue );
222 }
223
224 Property::Value::Value(const char *stringValue)
225 {
226   mImpl = new Impl( std::string(stringValue) );
227 }
228
229 Property::Value::Value(Property::Array &arrayValue)
230 {
231   mImpl = new Impl( arrayValue );
232 }
233
234 Property::Value::Value(Property::Map &mapValue)
235 {
236   mImpl = new Impl( mapValue );
237 }
238
239
240 Property::Value::~Value()
241 {
242   delete mImpl;
243 }
244
245 Property::Value::Value(const Value& value)
246 {
247   switch (value.GetType())
248   {
249     case Property::BOOLEAN:
250     {
251       mImpl = new Impl( value.Get<bool>() );
252       break;
253     }
254
255     case Property::FLOAT:
256     {
257       mImpl = new Impl( value.Get<float>() );
258       break;
259     }
260
261     case Property::INTEGER:
262     {
263       mImpl = new Impl( value.Get<int>() );
264       break;
265     }
266
267     case Property::UNSIGNED_INTEGER:
268     {
269       mImpl = new Impl( value.Get<unsigned int>() );
270       break;
271     }
272
273     case Property::VECTOR2:
274     {
275       mImpl = new Impl( value.Get<Vector2>() );
276       break;
277     }
278
279     case Property::VECTOR3:
280     {
281       mImpl = new Impl( value.Get<Vector3>() );
282       break;
283     }
284
285     case Property::VECTOR4:
286     {
287       mImpl = new Impl( value.Get<Vector4>() );
288       break;
289     }
290
291     case Property::RECTANGLE:
292     {
293       mImpl = new Impl( value.Get<Rect<int> >() );
294       break;
295     }
296
297     case Property::ROTATION:
298     {
299       mImpl = new Impl( value.Get<Quaternion>() );
300       break;
301     }
302
303     case Property::MATRIX3:
304     {
305       mImpl = new Impl( value.Get<Matrix3>());
306       break;
307     }
308
309     case Property::MATRIX:
310     {
311       mImpl = new Impl( value.Get<Matrix>());
312       break;
313     }
314
315     case Property::STRING:
316     {
317       mImpl = new Impl( value.Get<std::string>() );
318       break;
319     }
320
321     case Property::MAP:
322     {
323       mImpl = new Impl( value.Get<Property::Map>() );
324       break;
325     }
326
327     case Property::ARRAY:
328     {
329       mImpl = new Impl( value.Get<Property::Array>() );
330       break;
331     }
332
333     case Property::NONE: // fall
334     default:
335     {
336       mImpl = new Impl();
337       break;
338     }
339   }
340 }
341
342 Property::Value::Value(Type type)
343 {
344   switch (type)
345   {
346     case Property::BOOLEAN:
347     {
348       mImpl = new Impl( false );
349       break;
350     }
351
352     case Property::FLOAT:
353     {
354       mImpl = new Impl( 0.f );
355       break;
356     }
357
358     case Property::INTEGER:
359     {
360       mImpl = new Impl( 0 );
361       break;
362     }
363
364     case Property::UNSIGNED_INTEGER:
365     {
366       mImpl = new Impl( 0U );
367       break;
368     }
369
370     case Property::VECTOR2:
371     {
372       mImpl = new Impl( Vector2::ZERO );
373       break;
374     }
375
376     case Property::VECTOR3:
377     {
378       mImpl = new Impl( Vector3::ZERO );
379       break;
380     }
381
382     case Property::VECTOR4:
383     {
384       mImpl = new Impl( Vector4::ZERO );
385       break;
386     }
387
388     case Property::RECTANGLE:
389     {
390       mImpl = new Impl( Rect<int>(0,0,0,0) );
391       break;
392     }
393
394     case Property::ROTATION:
395     {
396       mImpl = new Impl( Quaternion(0.f, Vector4::YAXIS) );
397       break;
398     }
399
400     case Property::STRING:
401     {
402       mImpl = new Impl( std::string() );
403       break;
404     }
405
406     case Property::MAP:
407     {
408       mImpl = new Impl( Property::Map() );
409       break;
410     }
411
412     case Property::MATRIX:
413     {
414       mImpl = new Impl( Matrix() );
415       break;
416     }
417
418     case Property::MATRIX3:
419     {
420       mImpl = new Impl( Matrix3() );
421       break;
422     }
423
424     case Property::ARRAY:
425     {
426       mImpl = new Impl( Property::Array() );
427       break;
428     }
429
430     case Property::NONE: // fall
431     default:
432     {
433       mImpl = new Impl();
434       break;
435     }
436   }
437 }
438
439 Property::Value& Property::Value::operator=(const Property::Value& value)
440 {
441   if (this == &value)
442   {
443     // skip self assignment
444     return *this;
445   }
446
447   mImpl->mType = value.GetType();
448
449   switch (mImpl->mType)
450   {
451     case Property::BOOLEAN:
452     {
453       mImpl->mValue = value.Get<bool>();
454       break;
455     }
456
457     case Property::FLOAT:
458     {
459       mImpl->mValue = value.Get<float>();
460       break;
461     }
462
463     case Property::INTEGER:
464     {
465       mImpl->mValue = value.Get<int>();
466       break;
467     }
468
469     case Property::UNSIGNED_INTEGER:
470     {
471       mImpl->mValue = value.Get<unsigned int>();
472       break;
473     }
474
475     case Property::VECTOR2:
476     {
477       mImpl->mValue = value.Get<Vector2>();
478       break;
479     }
480
481     case Property::VECTOR3:
482     {
483       mImpl->mValue = value.Get<Vector3>();
484       break;
485     }
486
487     case Property::VECTOR4:
488     {
489       mImpl->mValue = value.Get<Vector4>();
490       break;
491     }
492
493     case Property::RECTANGLE:
494     {
495       mImpl->mValue = value.Get<Rect<int> >();
496       break;
497     }
498
499     case Property::ROTATION:
500     {
501       mImpl->mValue = value.Get<Quaternion>();
502       break;
503     }
504
505     case Property::STRING:
506     {
507       mImpl->mValue = value.Get<std::string>();
508       break;
509     }
510
511     case Property::MATRIX:
512     {
513       mImpl->mValue = value.Get<Matrix>();
514       break;
515     }
516
517     case Property::MATRIX3:
518     {
519       mImpl->mValue = value.Get<Matrix3>();
520       break;
521     }
522
523     case Property::MAP:
524     {
525       mImpl->mValue = value.Get<Property::Map>();
526       break;
527     }
528
529     case Property::ARRAY:
530     {
531       mImpl->mValue = value.Get<Property::Array>();
532       break;
533     }
534
535     case Property::NONE: // fall
536     default:
537     {
538       mImpl->mValue = Impl::AnyValue(0);
539       break;
540     }
541   }
542
543   return *this;
544 }
545
546 Property::Type Property::Value::GetType() const
547 {
548   return mImpl->mType;
549 }
550
551 void Property::Value::Get(bool& boolValue) const
552 {
553   DALI_ASSERT_ALWAYS( Property::BOOLEAN == GetType() && "Property type invalid" );
554
555   boolValue = boost::any_cast<bool>(mImpl->mValue);
556 }
557
558 void Property::Value::Get(float& floatValue) const
559 {
560   DALI_ASSERT_ALWAYS( Property::FLOAT == GetType() && "Property type invalid" );
561
562   floatValue = boost::any_cast<float>(mImpl->mValue);
563 }
564
565 void Property::Value::Get(int& integerValue) const
566 {
567   DALI_ASSERT_ALWAYS( Property::INTEGER == GetType() && "Property type invalid" );
568
569   integerValue = boost::any_cast<int>(mImpl->mValue);
570 }
571
572 void Property::Value::Get(unsigned int& unsignedIntegerValue) const
573 {
574   DALI_ASSERT_ALWAYS( Property::UNSIGNED_INTEGER == GetType() && "Property type invalid" );
575
576   unsignedIntegerValue = boost::any_cast<unsigned int>(mImpl->mValue);
577 }
578
579 void Property::Value::Get(Vector2& vectorValue) const
580 {
581   DALI_ASSERT_ALWAYS( Property::VECTOR2 == GetType() && "Property type invalid" );
582
583   vectorValue = boost::any_cast<Vector2>(mImpl->mValue);
584 }
585
586 void Property::Value::Get(Vector3& vectorValue) const
587 {
588   DALI_ASSERT_ALWAYS( Property::VECTOR3 == GetType() && "Property type invalid" );
589
590   vectorValue = boost::any_cast<Vector3>(mImpl->mValue);
591 }
592
593 void Property::Value::Get(Vector4& vectorValue) const
594 {
595   DALI_ASSERT_ALWAYS( Property::VECTOR4 == GetType() && "Property type invalid" );
596
597   vectorValue = boost::any_cast<Vector4>(mImpl->mValue);
598 }
599
600 void Property::Value::Get(Matrix3& matrixValue) const
601 {
602   DALI_ASSERT_ALWAYS( Property::MATRIX3 == GetType() && "Property type invalid" );
603   matrixValue = boost::any_cast<Matrix3>(mImpl->mValue);
604 }
605
606 void Property::Value::Get(Matrix& matrixValue) const
607 {
608   DALI_ASSERT_ALWAYS( Property::MATRIX == GetType() && "Property type invalid" );
609   matrixValue = boost::any_cast<Matrix>(mImpl->mValue);
610 }
611
612 void Property::Value::Get(Rect<int>& rect) const
613 {
614   DALI_ASSERT_ALWAYS( Property::RECTANGLE == GetType() && "Property type invalid" );
615
616   rect = boost::any_cast<Rect<int> >(mImpl->mValue);
617 }
618
619 void Property::Value::Get(AngleAxis& angleAxisValue) const
620 {
621   DALI_ASSERT_ALWAYS( Property::ROTATION == GetType() && "Property type invalid" );
622
623   // Rotations have two representations
624   DALI_ASSERT_DEBUG( typeid(Quaternion) == mImpl->mValue.type() ||
625                      typeid(AngleAxis)  == mImpl->mValue.type() );
626
627   if ( typeid(Quaternion) == mImpl->mValue.type() )
628   {
629     Quaternion quaternion = boost::any_cast<Quaternion>(mImpl->mValue);
630
631     Radian angleRadians(0.0f);
632     quaternion.ToAxisAngle( angleAxisValue.axis, angleRadians );
633     angleAxisValue.angle = angleRadians;
634   }
635   else
636   {
637     angleAxisValue = boost::any_cast<AngleAxis>(mImpl->mValue);
638   }
639 }
640
641 void Property::Value::Get(Quaternion& quaternionValue) const
642 {
643   DALI_ASSERT_ALWAYS( Property::ROTATION == GetType() && "Property type invalid" );
644
645   // Rotations have two representations
646   DALI_ASSERT_DEBUG( typeid(Quaternion) == mImpl->mValue.type() ||
647                typeid(AngleAxis)  == mImpl->mValue.type() );
648
649   if ( typeid(Quaternion) == mImpl->mValue.type() )
650   {
651     quaternionValue = boost::any_cast<Quaternion>(mImpl->mValue);
652   }
653   else
654   {
655     AngleAxis angleAxis = boost::any_cast<AngleAxis>(mImpl->mValue);
656
657     quaternionValue = Quaternion( Radian(angleAxis.angle), angleAxis.axis );
658   }
659 }
660
661 void Property::Value::Get(std::string &out) const
662 {
663   DALI_ASSERT_ALWAYS(Property::STRING == GetType() && "Property type invalid");
664
665   out = boost::any_cast<std::string>(mImpl->mValue);
666 }
667
668 void Property::Value::Get(Property::Array &out) const
669 {
670   DALI_ASSERT_ALWAYS(Property::ARRAY == GetType() && "Property type invalid");
671
672   out = boost::any_cast<Property::Array>(mImpl->mValue);
673 }
674
675 void Property::Value::Get(Property::Map &out) const
676 {
677   DALI_ASSERT_ALWAYS(Property::MAP == GetType() && "Property type invalid");
678
679   out = boost::any_cast<Property::Map>(mImpl->mValue);
680 }
681
682 Property::Value& Property::Value::GetValue(const std::string& key) const
683 {
684   DALI_ASSERT_ALWAYS(Property::MAP == GetType() && "Property type invalid");
685
686   Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
687
688   DALI_ASSERT_DEBUG(container);
689
690   if(container)
691   {
692     for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
693     {
694       if(iter->first == key)
695       {
696         return iter->second;
697       }
698     }
699   }
700
701   DALI_LOG_WARNING("Cannot find property map key %s", key.c_str());
702   DALI_ASSERT_ALWAYS(!"Cannot find property map key");
703
704   // should never return this
705   static Property::Value null;
706   return null;
707 }
708
709 bool Property::Value::HasKey(const std::string& key) const
710 {
711   bool has = false;
712
713   if( Property::MAP == GetType() )
714   {
715     Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
716
717     DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
718
719     if(container)
720     {
721       for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
722       {
723         if(iter->first == key)
724         {
725           has = true;
726         }
727       }
728     }
729   }
730
731   return has;
732 }
733
734
735 const std::string& Property::Value::GetKey(const int index) const
736 {
737   switch( GetType() )
738   {
739     case Property::MAP:
740     {
741       int i = 0;
742       Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
743       DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
744       if(container)
745       {
746         if(0 <= index && index < static_cast<int>(container->size()))
747         {
748           for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
749           {
750             if(i++ == index)
751             {
752               return iter->first;
753             }
754           }
755         }
756       }
757     }
758     break;
759     case Property::NONE:
760     case Property::ARRAY:
761     case Property::BOOLEAN:
762     case Property::FLOAT:
763     case Property::UNSIGNED_INTEGER:
764     case Property::INTEGER:
765     case Property::VECTOR2:
766     case Property::VECTOR3:
767     case Property::VECTOR4:
768     case Property::MATRIX:
769     case Property::MATRIX3:
770     case Property::RECTANGLE:
771     case Property::ROTATION:
772     case Property::STRING:
773     case Property::TYPE_COUNT:
774     {
775       break;
776     }
777   }
778
779
780   // should never return this
781   static std::string null;
782   return null;
783 }
784
785
786 void Property::Value::SetValue(const std::string& key, const Property::Value &value)
787 {
788   DALI_ASSERT_ALWAYS(Property::MAP == GetType() && "Property type invalid");
789
790   Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
791
792   if(container)
793   {
794     for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
795     {
796       if(iter->first == key)
797       {
798         iter->second = value;
799         return;
800       }
801     }
802
803     // if we get here its a new key
804     container->push_back(Property::StringValuePair(key, value));
805
806   }
807 }
808
809 Property::Value& Property::Value::GetItem(const int index) const
810 {
811   switch( GetType() )
812   {
813     case Property::MAP:
814     {
815       int i = 0;
816       Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
817
818       DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
819       if(container)
820       {
821         DALI_ASSERT_ALWAYS(index < static_cast<int>(container->size()) && "Property array index invalid");
822         DALI_ASSERT_ALWAYS(index >= 0 && "Property array index invalid");
823
824         for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
825         {
826           if(i++ == index)
827           {
828             return iter->second;
829           }
830         }
831       }
832     }
833     break;
834
835     case Property::ARRAY:
836     {
837       int i = 0;
838       Property::Array *container = boost::any_cast<Property::Array>(&(mImpl->mValue));
839
840       DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
841       if(container)
842       {
843         DALI_ASSERT_ALWAYS(index < static_cast<int>(container->size()) && "Property array index invalid");
844         DALI_ASSERT_ALWAYS(index >= 0 && "Property array index invalid");
845
846         for(Property::Array::iterator iter = container->begin(); iter != container->end(); ++iter)
847         {
848           if(i++ == index)
849           {
850             return *iter;
851           }
852         }
853       }
854     }
855     break;
856
857     case Property::NONE:
858     case Property::BOOLEAN:
859     case Property::FLOAT:
860     case Property::INTEGER:
861     case Property::UNSIGNED_INTEGER:
862     case Property::VECTOR2:
863     case Property::VECTOR3:
864     case Property::VECTOR4:
865     case Property::MATRIX3:
866     case Property::MATRIX:
867     case Property::RECTANGLE:
868     case Property::ROTATION:
869     case Property::STRING:
870     case Property::TYPE_COUNT:
871     {
872       DALI_ASSERT_ALWAYS(!"Cannot GetItem on property Type; not a container");
873       break;
874     }
875
876   } // switch GetType()
877
878
879   DALI_ASSERT_ALWAYS(!"Property value index not valid");
880
881   // should never return this
882   static Property::Value null;
883   return null;
884 }
885
886 void Property::Value::SetItem(const int index, const Property::Value &value)
887 {
888   switch( GetType() )
889   {
890     case Property::MAP:
891     {
892       Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
893       if( container && index < static_cast<int>(container->size()) )
894       {
895         int i = 0;
896         for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
897         {
898           if(i++ == index)
899           {
900             iter->second = value;
901             break;
902           }
903         }
904       }
905     }
906     break;
907
908     case Property::ARRAY:
909     {
910       Property::Array *container = boost::any_cast<Property::Array>(&(mImpl->mValue));
911       if( container && index < static_cast<int>(container->size()) )
912       {
913         (*container)[index] = value;
914       }
915     }
916     break;
917
918     case Property::NONE:
919     case Property::BOOLEAN:
920     case Property::FLOAT:
921     case Property::INTEGER:
922     case Property::UNSIGNED_INTEGER:
923     case Property::VECTOR2:
924     case Property::VECTOR3:
925     case Property::VECTOR4:
926     case Property::MATRIX3:
927     case Property::MATRIX:
928     case Property::RECTANGLE:
929     case Property::ROTATION:
930     case Property::STRING:
931     case Property::TYPE_COUNT:
932     {
933       DALI_ASSERT_ALWAYS(!"Cannot SetItem on property Type; not a container");
934       break;
935     }
936   }
937 }
938
939 int Property::Value::AppendItem(const Property::Value &value)
940 {
941   DALI_ASSERT_ALWAYS(Property::ARRAY == GetType() && "Property type invalid");
942
943   Property::Array *container = boost::any_cast<Property::Array>(&(mImpl->mValue));
944
945   if(container)
946   {
947     container->push_back(value);
948     return container->size() - 1;
949   }
950   else
951   {
952     return -1;
953   }
954
955 }
956
957 int Property::Value::GetSize() const
958 {
959   int ret = 0;
960
961   switch(GetType())
962   {
963     case Property::MAP:
964     {
965       Property::Map *container = boost::any_cast<Property::Map>(&(mImpl->mValue));
966       if(container)
967       {
968         ret = container->size();
969       }
970     }
971     break;
972
973     case Property::ARRAY:
974     {
975       Property::Array *container = boost::any_cast<Property::Array>(&(mImpl->mValue));
976       if(container)
977       {
978         ret = container->size();
979       }
980     }
981     break;
982
983     case Property::NONE:
984     case Property::BOOLEAN:
985     case Property::FLOAT:
986     case Property::INTEGER:
987     case Property::UNSIGNED_INTEGER:
988     case Property::VECTOR2:
989     case Property::VECTOR3:
990     case Property::VECTOR4:
991     case Property::MATRIX3:
992     case Property::MATRIX:
993     case Property::RECTANGLE:
994     case Property::ROTATION:
995     case Property::STRING:
996     case Property::TYPE_COUNT:
997     {
998       break;
999     }
1000
1001   }
1002
1003   return ret;
1004 }
1005
1006
1007 } // namespace Dali