Conversion to Apache 2.0 license
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-types.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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
18 // CLASS HEADER
19 #include <dali/public-api/object/property-types.h>
20
21 namespace Dali DALI_EXPORT_API
22 {
23
24 namespace PropertyTypes
25 {
26
27 static const char* PROPERTY_TYPE_NAMES[Property::TYPE_COUNT] =
28 {
29   "NONE",
30   "BOOLEAN",
31   "FLOAT",
32   "INTEGER",
33   "UNSIGNED_INTEGER",
34   "VECTOR2",
35   "VECTOR3",
36   "VECTOR4",
37   "MATRIX3",
38   "MATRIX",
39   "RECTANGLE",
40   "ROTATION",
41   "STRING",
42   "ARRAY",
43   "MAP",
44 };
45
46 const char* GetName(Property::Type type)
47 {
48   if (type < Property::TYPE_COUNT)
49   {
50     return PROPERTY_TYPE_NAMES[type];
51   }
52
53   return PROPERTY_TYPE_NAMES[Property::NONE];
54 }
55
56 template <typename T> Property::Type Get()             { return Property::NONE;  }
57 template <>           Property::Type Get<bool>()       { return Property::BOOLEAN;  }
58 template <>           Property::Type Get<float>()      { return Property::FLOAT;    }
59 template <>           Property::Type Get<int>()        { return Property::INTEGER;  }
60 template <>           Property::Type Get<unsigned int>(){ return Property::UNSIGNED_INTEGER;  }
61 template <>           Property::Type Get<Vector2>()    { return Property::VECTOR2;  }
62 template <>           Property::Type Get<Vector3>()    { return Property::VECTOR3;  }
63 template <>           Property::Type Get<Vector4>()    { return Property::VECTOR4;  }
64 template <>           Property::Type Get<Matrix3>()    { return Property::MATRIX3;  }
65 template <>           Property::Type Get<Matrix>()     { return Property::MATRIX;  }
66 template <>           Property::Type Get<AngleAxis>()  { return Property::ROTATION; } // Rotation has two representations
67 template <>           Property::Type Get<Quaternion>() { return Property::ROTATION; } // Rotation has two representations
68 template <>           Property::Type Get<std::string>(){ return Property::STRING; }
69 template <>           Property::Type Get<Dali::Rect<int> >(){ return Property::RECTANGLE; }
70 template <>           Property::Type Get<Property::Map>() { return Property::MAP; }
71 template <>           Property::Type Get<Property::Array>() { return Property::ARRAY; }
72
73
74 }; // namespace PropertyTypes
75
76 } // namespace Dali