41 #ifndef INCLUDED_GLS_ANIMATION_OBSERVER_H
42 #define INCLUDED_GLS_ANIMATION_OBSERVER_H
53 typedef stdortr1::shared_ptr<GlsAnimationObserverBase>
Ptr;
54 typedef Detail::ID
ID;
102 template<
class OnStartedCallback,
class OnUpdatedCallback,
class OnCompletedCallback,
class OnCanceledCallback>
104 const OnStartedCallback& onStarted,
105 const OnUpdatedCallback& onUpdated,
106 const OnCompletedCallback& onCompleted,
107 const OnCanceledCallback& onCanceled )
108 : _onStarted( MakeCallback( onStarted ) )
109 , _onUpdated( MakeCallback( onUpdated ) )
110 , _onCompleted( MakeCallback( onCompleted ) )
111 , _onCanceled( MakeCallback( onCanceled ) )
137 (*_onCompleted)( id );
146 (*_onCanceled)( id );
154 typedef stdortr1::shared_ptr<CallbackBase>
Ptr;
155 virtual ~CallbackBase() {}
156 virtual void operator()(
ID ) = 0;
160 struct Callback : CallbackBase
162 explicit Callback(
const Fn& fn ) : _fn( fn ) {}
163 virtual void operator()(
ID id )
173 template<
typename T,
typename RESULT=
bool>
176 template <
typename U, RESULT (U::*)()>
struct Check;
177 template <
typename U>
static char func(Check<U, &U::operator bool> *);
178 template <
typename U>
static int func(...);
180 typedef HasPolicyBool type;
181 enum { value =
sizeof(func<T>(0)) ==
sizeof(char) };
184 template<
typename T,
typename RESULT=
void*>
187 template <
typename U, RESULT (U::*)()>
struct Check;
188 template <
typename U>
static char func(Check<U, &U::operator void*> *);
189 template <
typename U>
static int func(...);
191 typedef HasPolicyVoid type;
192 enum { value =
sizeof(func<T>(0)) ==
sizeof(char) };
196 template<
class Fn>
static bool IsValid( Fn fn,
typename Detail::enable_if< HasPolicyBool<Fn>::value && HasPolicyVoid<Fn>::value >::type* = 0 ) {
return static_cast<bool>(fn); }
197 template<
class Fn>
static bool IsValid( Fn fn,
typename Detail::enable_if< !HasPolicyBool<Fn>::value && HasPolicyVoid<Fn>::value >::type* = 0 ) {
return static_cast<void*
>(fn) != NULL; }
198 template<
class Fn>
static bool IsValid( Fn fn,
typename Detail::enable_if< HasPolicyBool<Fn>::value && !HasPolicyVoid<Fn>::value >::type* = 0 ) {
return static_cast<bool>(fn); }
199 template<
class Fn>
static bool IsValid( Fn fn,
typename Detail::enable_if< !HasPolicyBool<Fn>::value && !HasPolicyVoid<Fn>::value >::type* = 0 ) {
return true; }
200 static bool IsValid(
void(*fn)(
ID) ) {
return fn != 0; }
205 static CallbackBase::Ptr MakeCallback(
const Fn& fn )
207 return CallbackBase::Ptr( IsValid(fn) ?
new Callback<Fn>( fn ) : 0 );
211 const CallbackBase::Ptr _onStarted;
212 const CallbackBase::Ptr _onUpdated;
213 const CallbackBase::Ptr _onCompleted;
214 const CallbackBase::Ptr _onCanceled;
virtual void OnStarted(ID id)
Inherited from GlsAnimationObserverBase.
Definition: gls_animation_observer.h:115
GlsAnimationObserverBase()
Constructor.
Definition: gls_animation_observer.h:57
virtual ~GlsAnimationObserverBase()
Destructor.
Definition: gls_animation_observer.h:60
virtual void OnCompleted(ID)
Definition: gls_animation_observer.h:73
virtual void OnCanceled(ID)
Called when the animation is canceled.
Definition: gls_animation_observer.h:76
Definition: gls_animation_observer.h:50
virtual void OnUpdated(ID id)
Inherited from GlsAnimationObserverBase.
Definition: gls_animation_observer.h:124
virtual void OnStarted(ID)
Definition: gls_animation_observer.h:64
virtual void OnUpdated(ID)
Called when the animation updates (i.e., SetKey() is called with a new value)
Definition: gls_animation_observer.h:67
The GL Studio keyframe animation classes.
Detail::ID ID
Alias for easier reading.
Definition: gls_animation_observer.h:54
GlsAnimationObserver(const OnStartedCallback &onStarted, const OnUpdatedCallback &onUpdated, const OnCompletedCallback &onCompleted, const OnCanceledCallback &onCanceled)
Definition: gls_animation_observer.h:103
virtual void OnCanceled(ID id)
Inherited from GlsAnimationObserverBase.
Definition: gls_animation_observer.h:142
virtual void OnCompleted(ID id)
Inherited from GlsAnimationObserverBase.
Definition: gls_animation_observer.h:133
stdortr1::shared_ptr< GlsAnimationObserverBase > Ptr
Alias for easier reading.
Definition: gls_animation_observer.h:53
Definition: gls_animation_observer.h:93
Definition: gls_animation.cpp:64