Sleeping Wombat GUI  0.100
swGUI
DefaultInterpolators.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "IInterpolator.h"
11 
12 #include <string>
13 
14 
16 namespace DefaultInterpolators
17 {
18 
25  template< typename KeyType >
27  {
28  const static bool value = false;
29  };
30 
31 
32 
33  template< typename KeyType >
35  const Key< KeyType >& rightKey,
36  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
37  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
38 
39  template< typename KeyType >
41  const Key< KeyType >& rightKey,
42  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
43  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
44 
45  template< typename KeyType >
47  const Key< KeyType >& rightKey,
48  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
49  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
50 
51 
52  template< typename KeyType >
54  const Key< KeyType >& leftKey,
55  const Key< KeyType >& rightKey,
56  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
57  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
58 
59 
60 
65  template< typename KeyType >
67  Create ( const Key< KeyType >& leftKey,
68  const Key< KeyType >& rightKey,
69  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
70  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
71 
72  template< typename KeyType >
74  Create ( const Key< KeyType >& leftKey,
75  const Key< KeyType >& rightKey,
76  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
77  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
78 
79  template<>
81  Create ( const Key< bool >& leftKey,
82  const Key< bool >& rightKey,
83  UPtr< const IInterpolator< bool > >& leftInterpolator,
84  UPtr< const IInterpolator< bool > >& rightInterpolator );
85 
86  template< typename KeyType >
88  Create ( const Key< KeyType >& leftKey,
89  const Key< KeyType >& rightKey,
90  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
91  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
92 
93  template< typename KeyType >
95  Create ( const Key< KeyType >& leftKey,
96  const Key< KeyType >& rightKey,
97  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
98  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
99 
100  template< typename KeyType >
102  Create ( const Key< KeyType >& leftKey,
103  const Key< KeyType >& rightKey,
104  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
105  UPtr< const IInterpolator< KeyType > >& rightInterpolator );
106 
107 //====================================================================================//
108 // Specialization declarations
109 //====================================================================================//
110 
111 #define DECLARE_SPECIALIZATON( type, Function ) \
112 template \
113 UPtr< IInterpolator< type > > Function< type >( const Key< type >& leftKey, \
114  const Key< type >& rightKey, \
115  UPtr< const IInterpolator< type > >& leftInterpolator, \
116  UPtr< const IInterpolator< type > >& rightInterpolator );
117 
129 
142 DECLARE_SPECIALIZATON( std::wstring, CreateDiscrete );
143 DECLARE_SPECIALIZATON( std::string, CreateDiscrete );
144 
156 
157 #undef DECLARE_SPECIALIZATON
158 
159 //====================================================================================//
160 // Implementation
161 //====================================================================================//
162 
163 // ================================ //
164 //
165 template< typename KeyType >
167  const Key< KeyType >& leftKey,
168  const Key< KeyType >& rightKey,
169  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
170  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
171 {
172  switch( type )
173  {
175  return CreateDiscrete< KeyType >( leftKey, rightKey, leftInterpolator, rightInterpolator );
177  return CreateLinear< KeyType >( leftKey, rightKey, leftInterpolator, rightInterpolator );
179  return CreateCosinus< KeyType >( leftKey, rightKey, leftInterpolator, rightInterpolator );
182  return DummyInterpolator< KeyType >( leftKey, rightKey, leftInterpolator, rightInterpolator );
183  default:
184  return DummyInterpolator< KeyType >( leftKey, rightKey, leftInterpolator, rightInterpolator );
185  }
186 }
187 
188 // ================================ //
189 //
190 template< typename KeyType >
192  Create ( const Key< KeyType >& leftKey,
193  const Key<KeyType>& rightKey,
194  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
195  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
196 {
197  return CreateLinear( leftKey, rightKey, leftInterpolator, rightInterpolator );
198 }
199 
200 
201 // ================================ //
202 //
203 template< typename KeyType >
205  Create ( const Key< KeyType >& leftKey,
206  const Key< KeyType >& rightKey,
207  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
208  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
209 {
210  return CreateLinear( leftKey, rightKey, leftInterpolator, rightInterpolator );
211 }
212 
213 
214 // ================================ //
215 //
216 template<>
218  Create ( const Key< bool >& leftKey,
219  const Key< bool >& rightKey,
220  UPtr< const IInterpolator< bool > >& leftInterpolator,
221  UPtr< const IInterpolator< bool > >& rightInterpolator )
222 {
223  return CreateDiscrete( leftKey, rightKey, leftInterpolator, rightInterpolator );
224 }
225 
226 // ================================ //
227 //
228 template< typename KeyType >
230  Create ( const Key< KeyType >& leftKey,
231  const Key<KeyType>& rightKey,
232  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
233  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
234 {
235  return CreateDiscrete( leftKey, rightKey, leftInterpolator, rightInterpolator );
236 }
237 
238 // ================================ //
239 //
240 template< typename KeyType >
242  Create ( const Key< KeyType >& leftKey,
243  const Key<KeyType>& rightKey,
244  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
245  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
246 {
247  return CreateDiscrete( leftKey, rightKey, leftInterpolator, rightInterpolator );
248 }
249 
250 // ================================ //
251 //
252 template< typename KeyType >
254  Create ( const Key< KeyType >& leftKey,
255  const Key< KeyType >& rightKey,
256  UPtr< const IInterpolator< KeyType > >& leftInterpolator,
257  UPtr< const IInterpolator< KeyType > >& rightInterpolator )
258 {
259  return CreateLinear( leftKey, rightKey, leftInterpolator, rightInterpolator );
260 }
261 
262 
263 
264 } // DefaultInterpolators
Interpolators helpers functions.
Definition: DefaultInterpolators.cpp:14
uint16_t uint16
Definition: TypesDefinitions.h:29
UPtr< IInterpolator< KeyType > > CreateCosinus(const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator)
Definition: DefaultInterpolators.inl:41
Base class for interpolators.
Definition: IInterpolator.h:38
Definition: UPtr.h:10
int8_t int8
Definition: TypesDefinitions.h:26
KeyType
Definition: all_0.js:13
static const bool value
Definition: DefaultInterpolators.h:28
UPtr< IInterpolator< KeyType > > CreateDiscrete(const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator)
Definition: DefaultInterpolators.inl:30
uint64_t uint64
Definition: TypesDefinitions.h:33
int64_t int64
Definition: TypesDefinitions.h:32
InterpolatorType
Definition: IInterpolator.h:24
uint32_t uint32
Definition: TypesDefinitions.h:31
Animation key.
Definition: IInterpolator.h:21
uint8_t uint8
Definition: TypesDefinitions.h:27
UPtr< IInterpolator< KeyType > > Create(InterpolatorType type, const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator)
Definition: DefaultInterpolators.h:166
DECLARE_SPECIALIZATON(float, CreateLinear)
Trait for enabling types for parameter animation.
Definition: DefaultInterpolators.h:26
int32_t int32
Definition: TypesDefinitions.h:30
UPtr< IInterpolator< KeyType > > CreateLinear(const Key< KeyType > &leftKey, const Key< KeyType > &rightKey, UPtr< const IInterpolator< KeyType > > &leftInterpolator, UPtr< const IInterpolator< KeyType > > &rightInterpolator)
Definition: DefaultInterpolators.inl:18
int16_t int16
Definition: TypesDefinitions.h:28
Temporary interpolator for internal use.
Definition: IInterpolator.h:67