1
1
#include " var.hpp"
2
2
3
3
template <class T >
4
- var<T>::var(std::shared_ptr<anim<T>> ani ) : var(ani, std::chrono::steady_clock::now( )) { }
4
+ var<T>::var(T val ) : var(std::make_shared<anim<T>>(val )) { }
5
5
6
6
template <class T >
7
- var<T>::var(std::shared_ptr<anim<T>> ani, std::chrono::time_point<std::chrono::steady_clock> start) : ani(ani), start(start) { }
7
+ var<T>::var(std::shared_ptr<anim<T>> ani) : anis({}) {
8
+ this ->set_anim (ani);
9
+ }
10
+
11
+ template <typename T>
12
+ var<T> & var<T>::operator =(const T & val) {
13
+ this ->anis [BASE] = std::make_shared<anim<T>>(val);
14
+ return *this ;
15
+ }
8
16
9
17
template <typename T>
10
18
var<T>::operator T () {
@@ -13,26 +21,35 @@ var<T>::operator T() {
13
21
14
22
template <typename T>
15
23
T var<T>::operator ()(double time) {
16
- return this ->ani ->get (time );
24
+ return this ->anis [BASE]->at (time );
25
+ }
26
+
27
+ template <typename T>
28
+ T var<T>::operator ()() {
29
+ return this ->anis [BASE]->at (std::chrono::steady_clock::now ());
17
30
}
18
31
19
32
template <typename T>
20
- T var<T>::operator ()(std::chrono::time_point<std::chrono::steady_clock> time ) {
21
- return this ->operator ()(std::chrono::duration< double >( time - this -> start ). count ()) ;
33
+ std::shared_ptr<anim<T>> & var<T>::operator []( int i ) {
34
+ return this ->anis [i] ;
22
35
}
23
36
24
37
template <typename T>
25
- T var<T>::operator ()( ) {
26
- return this ->operator ()( std::chrono::steady_clock::now ()) ;
38
+ bool var<T>::has( int i ) {
39
+ return this ->anis . count (i) != 0 ;
27
40
}
28
41
29
42
template <typename T>
30
- void var<T>::set_anim(std::shared_ptr<anim<T>> ani, std::chrono::time_point<std::chrono::steady_clock> start) {
31
- this ->ani = ani;
32
- this ->start = start;
43
+ std::vector<int > var<T>::get_channels() {
44
+ std::vector<int > channels;
45
+ for (auto & [i, _] : anis) {
46
+ channels.push_back (i);
47
+ }
48
+ return channels;
33
49
}
34
50
35
51
template <typename T>
36
52
void var<T>::set_anim(std::shared_ptr<anim<T>> ani) {
37
- this ->set_anim (ani, std::chrono::steady_clock::now ());
53
+ this ->anis .clear ();
54
+ this ->anis [BASE] = ani;
38
55
}
0 commit comments