Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / renderer / math / FUiEffects_RendererMathVectorTraits.h
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_RendererMathVectorTraits.h
20  * @brief      The VectorTraits class
21  *
22  */
23
24 #ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_H_
25 #define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_H_
26
27 #include <renderer/math/FUiEffects_RendererMathVectorTraitsBase.h>
28
29 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math
30 {
31
32 template<typename T, int Dimension>
33 class VectorTraits :
34         public VectorTraitsBase<T, Dimension>
35 {
36 public:
37         typedef Vector<T, Dimension> VectorType;
38         typedef VectorTraitsBase<T, Dimension> VectorTraitsBaseType;
39         typedef typename VectorTraitsBaseType::TypeReference TypeReference;
40
41         using VectorTraitsBaseType::data;
42
43         inline T& X(void);
44         inline const TypeReference X(void) const;
45
46         inline T& Y(void);
47         inline const TypeReference Y(void) const;
48
49         inline T& Z(void);
50         inline const TypeReference Z(void) const;
51
52         inline T& W(void);
53         inline const TypeReference W(void) const;
54
55         inline VectorType& Set(const TypeReference x, const TypeReference y, const TypeReference z, const TypeReference w);
56 };
57
58 template<typename T, int Dimension>
59 T& VectorTraits<T, Dimension>::X(void)
60 {
61         return data[0];
62 }
63
64 template<typename T, int Dimension>
65 const typename VectorTraits<T, Dimension>::TypeReference VectorTraits<T, Dimension>::X(void) const
66 {
67         return data[0];
68 }
69
70 template<typename T, int Dimension>
71 T& VectorTraits<T, Dimension>::Y(void)
72 {
73         return data[1];
74 }
75
76 template<typename T, int Dimension>
77 const typename VectorTraits<T, Dimension>::TypeReference VectorTraits<T, Dimension>::Y(void) const
78 {
79         return data[1];
80 }
81
82 template<typename T, int Dimension>
83 T& VectorTraits<T, Dimension>::Z(void)
84 {
85         return data[2];
86 }
87
88 template<typename T, int Dimension>
89 const typename VectorTraits<T, Dimension>::TypeReference VectorTraits<T, Dimension>::Z(void) const
90 {
91         return data[2];
92 }
93
94 template<typename T, int Dimension>
95 T& VectorTraits<T, Dimension>::W(void)
96 {
97         return data[3];
98 }
99
100 template<typename T, int Dimension>
101 const typename VectorTraits<T, Dimension>::TypeReference VectorTraits<T, Dimension>::W(void) const
102 {
103         return data[3];
104 }
105
106 template<typename T, int Dimension>
107 typename VectorTraits<T, Dimension>::VectorType& VectorTraits<T, Dimension>::Set(const TypeReference x, const TypeReference y, const TypeReference z, const TypeReference w)
108 {
109         data[0] = x;
110         data[1] = y;
111         data[2] = z;
112         data[3] = w;
113         return *(static_cast<VectorType*>(this));
114 }
115
116 }}}}} //Tizen::Ui::Effects::_Renderer::Math
117
118
119 #endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_H_