diff --git a/libopenage/curve/base_curve.h b/libopenage/curve/base_curve.h index 0e8d2d8100..515babdf64 100644 --- a/libopenage/curve/base_curve.h +++ b/libopenage/curve/base_curve.h @@ -204,7 +204,7 @@ void BaseCurve::set_last(const time::time_t &at, const T &value) { auto hint = this->container.last(at, this->last_element); // erase max one same-time value - if (hint->time == at) { + if (hint->time() == at) { hint--; } @@ -221,7 +221,7 @@ template void BaseCurve::set_insert(const time::time_t &at, const T &value) { auto hint = this->container.insert_after(at, value, this->last_element); // check if this is now the final keyframe - if (hint->time > this->last_element->time) { + if (hint->time() > this->last_element->time()) { this->last_element = hint; } this->changes(at); @@ -245,7 +245,7 @@ void BaseCurve::erase(const time::time_t &at) { template std::pair BaseCurve::frame(const time::time_t &time) const { auto e = this->container.last(time, this->container.end()); - return std::make_pair(e->time, e->value); + return std::make_pair(e->time(), e->value()); } @@ -253,7 +253,7 @@ template std::pair BaseCurve::next_frame(const time::time_t &time) const { auto e = this->container.last(time, this->container.end()); e++; - return std::make_pair(e->time, e->value); + return std::make_pair(e->time(), e->value()); } template @@ -261,7 +261,7 @@ std::string BaseCurve::str() const { std::stringstream ss; ss << "Curve[" << this->idstr() << "]{" << std::endl; for (const auto &keyframe : this->container) { - ss << " " << keyframe.time << ": " << keyframe.value << "," << std::endl; + ss << " " << keyframe.time() << ": " << keyframe.value() << "," << std::endl; } ss << "}"; @@ -272,10 +272,10 @@ template void BaseCurve::check_integrity() const { time::time_t last_time = time::TIME_MIN; for (const auto &keyframe : this->container) { - if (keyframe.time < last_time) { + if (keyframe.time() < last_time) { throw Error{MSG(err) << "curve is broken after t=" << last_time << ": " << this->str()}; } - last_time = keyframe.time; + last_time = keyframe.time(); } } diff --git a/libopenage/curve/continuous.h b/libopenage/curve/continuous.h index 3eb7170ddb..aa09869130 100644 --- a/libopenage/curve/continuous.h +++ b/libopenage/curve/continuous.h @@ -1,4 +1,4 @@ -// Copyright 2017-2023 the openage authors. See copying.md for legal info. +// Copyright 2017-2024 the openage authors. See copying.md for legal info. #pragma once @@ -48,7 +48,7 @@ void Continuous::set_last(const time::time_t &at, const T &value) { auto hint = this->container.last(at, this->last_element); // erase all same-time entries - while (hint->time == at) { + while (hint->time() == at) { hint--; } diff --git a/libopenage/curve/discrete.h b/libopenage/curve/discrete.h index cdcb3daa31..e5371464fd 100644 --- a/libopenage/curve/discrete.h +++ b/libopenage/curve/discrete.h @@ -1,4 +1,4 @@ -// Copyright 2017-2023 the openage authors. See copying.md for legal info. +// Copyright 2017-2024 the openage authors. See copying.md for legal info. #pragma once @@ -55,7 +55,7 @@ template T Discrete::get(const time::time_t &time) const { auto e = this->container.last(time, this->last_element); this->last_element = e; // TODO if Caching? - return e->value; + return e->value(); } @@ -78,7 +78,7 @@ template std::pair Discrete::get_time(const time::time_t &time) const { auto e = this->container.last(time, this->last_element); this->last_element = e; - return std::make_pair(e->time, e->value); + return std::make_pair(e->time(), e->value()); } @@ -94,7 +94,7 @@ std::optional> Discrete::get_previous(const time:: } e--; - return std::make_pair(e->time, e->value); + return std::make_pair(e->time(), e->value()); } } // namespace openage::curve diff --git a/libopenage/curve/discrete_mod.h b/libopenage/curve/discrete_mod.h index de036bbf10..953939f975 100644 --- a/libopenage/curve/discrete_mod.h +++ b/libopenage/curve/discrete_mod.h @@ -93,7 +93,7 @@ void DiscreteMod::erase(const time::time_t &at) { BaseCurve::erase(at); if (this->time_length == at) { - this->time_length = this->last_element->time; + this->time_length = this->container.get(this->container.size() - 1).time(); } } diff --git a/libopenage/curve/interpolated.h b/libopenage/curve/interpolated.h index d5d4a1dedf..c7f2ab8af2 100644 --- a/libopenage/curve/interpolated.h +++ b/libopenage/curve/interpolated.h @@ -48,10 +48,10 @@ T Interpolated::get(const time::time_t &time) const { time::time_t interval = 0; - auto offset = time - e->time; + auto offset = time - e->time(); if (nxt != this->container.end()) { - interval = nxt->time - e->time; + interval = nxt->time() - e->time(); } // here, offset > interval will never hold. @@ -62,7 +62,7 @@ T Interpolated::get(const time::time_t &time) const { || offset == 0 // values equal -> don't need to interpolate || interval == 0) { // values at the same time -> division-by-zero-error - return e->value; + return e->value(); } else { // Interpolation between time(now) and time(next) that has elapsed @@ -72,7 +72,7 @@ T Interpolated::get(const time::time_t &time) const { // TODO: nxt->value - e->value will produce wrong results if // the nxt->value < e->value and curve element type is unsigned // Example: nxt = 2, e = 4; type = uint8_t ==> 2 - 4 = 254 - return e->value + (nxt->value - e->value) * elapsed_frac; + return e->value() + (nxt->value() - e->value()) * elapsed_frac; } } diff --git a/libopenage/curve/keyframe.h b/libopenage/curve/keyframe.h index 82e36ed147..489048ce97 100644 --- a/libopenage/curve/keyframe.h +++ b/libopenage/curve/keyframe.h @@ -1,4 +1,4 @@ -// Copyright 2019-2023 the openage authors. See copying.md for legal info. +// Copyright 2019-2024 the openage authors. See copying.md for legal info. #pragma once @@ -24,17 +24,44 @@ class Keyframe { * New, default-constructed element at the given time */ Keyframe(const time::time_t &time) : - time{time} {} + timestamp{time} {} /** * New element fron time and value */ Keyframe(const time::time_t &time, const T &value) : - time{time}, - value{value} {} + timestamp{time}, + val{value} {} - const time::time_t time = time::TIME_MIN; - T value = T{}; + + /** + * Get the time of this keyframe. + * + * @return Keyframe time. + */ + const time::time_t &time() const { + return this->timestamp; + } + + /** + * Get the value of this keyframe. + * + * @return Keyframe value. + */ + const T &value() const { + return this->val; + } + +private: + /** + * The time of this keyframe. + */ + time::time_t timestamp = time::TIME_MIN; + + /** + * The value of this keyframe. + */ + T val = T{}; }; } // namespace openage::curve diff --git a/libopenage/curve/keyframe_container.h b/libopenage/curve/keyframe_container.h index b9e6850257..3c9a7f901f 100644 --- a/libopenage/curve/keyframe_container.h +++ b/libopenage/curve/keyframe_container.h @@ -3,9 +3,9 @@ #pragma once #include +#include #include #include -#include #include "curve/keyframe.h" #include "time/time.h" @@ -38,7 +38,7 @@ class KeyframeContainer { * The most important property of this container is the iterator validity on * insert and remove. */ - using container_t = std::list; + using container_t = std::deque; /** * The iterator type to access elements in the container @@ -75,6 +75,17 @@ class KeyframeContainer { */ size_t size() const; + /** + * Get the element at a specific position in the underlying container. + * + * @param idx Index of the element to get. + * + * @return Element at the given index. + */ + const keyframe_t &get(const size_t &idx) const { + return this->container.at(idx); + } + /** * Get the last element in the curve which is at or before the given time. * (i.e. elem->time <= time). Given a hint where to start the search. @@ -136,7 +147,7 @@ class KeyframeContainer { * get a hint. */ iterator insert_before(const time::time_t &time, const T &value) { - return this->insert_before(keyframe_t(time, value), std::end(this->container)); + return this->insert_before(keyframe_t{time, value}, std::end(this->container)); } /** @@ -145,7 +156,7 @@ class KeyframeContainer { * before the old one. */ iterator insert_before(const time::time_t &time, const T &value, const iterator &hint) { - return this->insert_before(keyframe_t(time, value), hint); + return this->insert_before(keyframe_t{time, value}, hint); } /** @@ -166,7 +177,7 @@ class KeyframeContainer { * only, if your really do not have the possibility to get a hint. */ iterator insert_overwrite(const time::time_t &time, const T &value) { - return this->insert_overwrite(keyframe_t(time, value), + return this->insert_overwrite(keyframe_t{time, value}, std::end(this->container)); } @@ -181,7 +192,7 @@ class KeyframeContainer { const T &value, const iterator &hint, bool overwrite_all = false) { - return this->insert_overwrite(keyframe_t(time, value), hint, overwrite_all); + return this->insert_overwrite(keyframe_t{time, value}, hint, overwrite_all); } /** @@ -198,7 +209,7 @@ class KeyframeContainer { * use it only, if your really do not have the possibility to get a hint. */ iterator insert_after(const time::time_t &time, const T &value) { - return this->insert_after(keyframe_t(time, value), + return this->insert_after(keyframe_t{time, value}, std::end(this->container)); } @@ -207,7 +218,7 @@ class KeyframeContainer { * identical time. Provide a insertion hint to abbreviate the search for the insertion point. */ iterator insert_after(const time::time_t &time, const T &value, const iterator &hint) { - return this->insert_after(keyframe_t(time, value), hint); + return this->insert_after(keyframe_t{time, value}, hint); } /** @@ -305,7 +316,7 @@ class KeyframeContainer { */ void dump() const { for (auto &e : container) { - std::cout << "Element: time: " << e.time << " v: " << e.value << std::endl; + std::cout << "Element: time: " << e.time() << " v: " << e.value() << std::endl; } } @@ -328,7 +339,7 @@ template KeyframeContainer::KeyframeContainer() { // Create a default element at -Inf, that can always be dereferenced - so // there will by definition never be a element that cannot be dereferenced - this->container.push_back(keyframe_t(time::TIME_MIN, T())); + this->container.push_back(keyframe_t{time::TIME_MIN, T()}); } @@ -336,7 +347,7 @@ template KeyframeContainer::KeyframeContainer(const T &defaultval) { // Create a default element at -Inf, that can always be dereferenced - so // there will by definition never be a element that cannot be dereferenced - this->container.push_back(keyframe_t(time::TIME_MIN, defaultval)); + this->container.push_back(keyframe_t{time::TIME_MIN, defaultval}); } @@ -360,10 +371,10 @@ typename KeyframeContainer::iterator KeyframeContainer::last(const time::t iterator e = hint; auto end = std::end(this->container); - if (e != end and e->time <= time) { + if (e != end and e->time() <= time) { // walk to the right until the time is larget than the searched // then go one to the left to get the last item with <= requested time - while (e != end && e->time <= time) { + while (e != end && e->time() <= time) { e++; } e--; @@ -371,7 +382,7 @@ typename KeyframeContainer::iterator KeyframeContainer::last(const time::t else { // e == end or e->time > time // walk to the left until the element time is smaller than or equal to the searched time auto begin = std::begin(this->container); - while (e != begin and (e == end or e->time > time)) { + while (e != begin and (e == end or e->time() > time)) { e--; } } @@ -394,10 +405,10 @@ typename KeyframeContainer::iterator KeyframeContainer::last_before(const iterator e = hint; auto end = std::end(this->container); - if (e != end and e->time < time) { + if (e != end and e->time() < time) { // walk to the right until the time is larget than the searched // then go one to the left to get the last item with <= requested time - while (e != end && e->time <= time) { + while (e != end && e->time() <= time) { e++; } e--; @@ -405,7 +416,7 @@ typename KeyframeContainer::iterator KeyframeContainer::last_before(const else { // e == end or e->time > time // walk to the left until the element time is smaller than the searched time auto begin = std::begin(this->container); - while (e != begin and (e == end or e->time >= time)) { + while (e != begin and (e == end or e->time() >= time)) { e--; } } @@ -421,9 +432,9 @@ template typename KeyframeContainer::iterator KeyframeContainer::insert_before(const KeyframeContainer::keyframe_t &e, const KeyframeContainer::iterator &hint) { - iterator at = this->last(e.time, hint); + iterator at = this->last(e.time(), hint); // seek over all same-time elements, so we can insert before the first one - while (at != std::begin(this->container) and at->time == e.time) { + while (at != std::begin(this->container) and at->time() == e.time()) { --at; } @@ -445,14 +456,14 @@ KeyframeContainer::insert_overwrite( const KeyframeContainer::keyframe_t &e, const KeyframeContainer::iterator &hint, bool overwrite_all) { - iterator at = this->last(e.time, hint); + iterator at = this->last(e.time(), hint); if (overwrite_all) { - at = this->erase_group(e.time, at); + at = this->erase_group(e.time(), at); } else if (at != std::end(this->container)) { // overwrite the same-time element - if (at->time == e.time) { + if (at->time() == e.time()) { at = this->container.erase(at); } else { @@ -472,7 +483,7 @@ typename KeyframeContainer::iterator KeyframeContainer::insert_after( const KeyframeContainer::keyframe_t &e, const KeyframeContainer::iterator &hint) { - iterator at = this->last(e.time, hint); + iterator at = this->last(e.time(), hint); if (at != std::end(this->container)) { ++at; @@ -493,10 +504,9 @@ KeyframeContainer::erase_after(KeyframeContainer::iterator last_valid) { } // Delete everything to the end. - while (last_valid != this->container.end()) { - last_valid = this->container.erase(last_valid); - } - return last_valid; + auto new_end = this->container.erase(last_valid, this->container.end()); + --new_end; // return the last valid element that was not deleted + return new_end; } @@ -523,7 +533,7 @@ KeyframeContainer::sync(const KeyframeContainer &other, // Copy all elements from other with time >= start while (at_other != other.end()) { - if (at_other->time >= start) { + if (at_other->time() >= start) { at = this->insert_after(*at_other, at); } ++at_other; @@ -548,9 +558,9 @@ KeyframeContainer::sync(const KeyframeContainer &other, // Copy all elements from other with time >= start while (at_other != other.end()) { - if (at_other->time >= start) { + if (at_other->time() >= start) { // Convert the value to the type of this container - at = this->insert_after(at_other->time, converter(at_other->value), at); + at = this->insert_after(at_other->time(), converter(at_other->value()), at); } ++at_other; } @@ -567,7 +577,7 @@ KeyframeContainer::erase_group(const time::time_t &time, // if the time what we're looking for // erase elements until all element with that time are purged - while (at != std::end(this->container) and at->time == time) { + while (at != std::end(this->container) and at->time() == time) { at = this->container.erase(at); if (at != std::begin(this->container)) [[likely]] { --at; diff --git a/libopenage/curve/queue.h b/libopenage/curve/queue.h index 7698c18c5c..df0d45b1c2 100644 --- a/libopenage/curve/queue.h +++ b/libopenage/curve/queue.h @@ -3,8 +3,8 @@ #pragma once #include +#include #include -#include #include #include @@ -60,7 +60,7 @@ class Queue : public event::EventEntity { }; public: - using container_t = typename std::list; + using container_t = typename std::deque; using const_iterator = typename container_t::const_iterator; using iterator = typename container_t::iterator; @@ -357,6 +357,10 @@ QueueFilterIterator> Queue::between(const time::time_t &begin, template void Queue::erase(const CurveIterator> &it) { container.erase(it.get_base()); + + // erasing invalidate the front_start cache + // change it to begin() + this->front_start = this->container.begin(); } diff --git a/libopenage/curve/segmented.h b/libopenage/curve/segmented.h index e02572060f..1dcf46cddf 100644 --- a/libopenage/curve/segmented.h +++ b/libopenage/curve/segmented.h @@ -1,4 +1,4 @@ -// Copyright 2019-2023 the openage authors. See copying.md for legal info. +// Copyright 2019-2024 the openage authors. See copying.md for legal info. #pragma once @@ -62,7 +62,7 @@ void Segmented::set_last_jump(const time::time_t &at, const T &leftval, const auto hint = this->container.last(at, this->last_element); // erase all one same-time values - while (hint->time == at) { + while (hint->time() == at) { hint--; } diff --git a/libopenage/curve/tests/curve_types.cpp b/libopenage/curve/tests/curve_types.cpp index 40f20395ee..6d2c2c43e0 100644 --- a/libopenage/curve/tests/curve_types.cpp +++ b/libopenage/curve/tests/curve_types.cpp @@ -1,4 +1,4 @@ -// Copyright 2017-2023 the openage authors. See copying.md for legal info. +// Copyright 2017-2024 the openage authors. See copying.md for legal info. #include #include @@ -36,133 +36,133 @@ void curve_types() { { auto it = c.begin(); - TESTEQUALS(it->value, 0); - TESTEQUALS(it->time, time::TIME_MIN); - TESTEQUALS((++it)->time, 0); - TESTEQUALS(it->value, 0); - TESTEQUALS((++it)->time, 1); - TESTEQUALS(it->value, 1); - TESTEQUALS((++it)->time, 10); - TESTEQUALS(it->value, 2); + TESTEQUALS(it->value(), 0); + TESTEQUALS(it->time(), time::TIME_MIN); + TESTEQUALS((++it)->time(), 0); + TESTEQUALS(it->value(), 0); + TESTEQUALS((++it)->time(), 1); + TESTEQUALS(it->value(), 1); + TESTEQUALS((++it)->time(), 10); + TESTEQUALS(it->value(), 2); } // last function tests without hints - TESTEQUALS(c.last(0)->value, 0); - TESTEQUALS(c.last(1)->value, 1); - TESTEQUALS(c.last(5)->value, 1); - TESTEQUALS(c.last(10)->value, 2); - TESTEQUALS(c.last(47)->value, 2); + TESTEQUALS(c.last(0)->value(), 0); + TESTEQUALS(c.last(1)->value(), 1); + TESTEQUALS(c.last(5)->value(), 1); + TESTEQUALS(c.last(10)->value(), 2); + TESTEQUALS(c.last(47)->value(), 2); // last() with hints. - TESTEQUALS(c.last(0, pa)->value, 0); - TESTEQUALS(c.last(1, pa)->value, 1); - TESTEQUALS(c.last(5, pa)->value, 1); - TESTEQUALS(c.last(10, pa)->value, 2); - TESTEQUALS(c.last(47, pa)->value, 2); - - TESTEQUALS(c.last(0, p0)->value, 0); - TESTEQUALS(c.last(1, p0)->value, 1); - TESTEQUALS(c.last(5, p0)->value, 1); - TESTEQUALS(c.last(10, p0)->value, 2); - TESTEQUALS(c.last(47, p0)->value, 2); - - TESTEQUALS(c.last(0, p1)->value, 0); - TESTEQUALS(c.last(1, p1)->value, 1); - TESTEQUALS(c.last(5, p1)->value, 1); - TESTEQUALS(c.last(10, p1)->value, 2); - TESTEQUALS(c.last(47, p1)->value, 2); - - TESTEQUALS(c.last(0, p2)->value, 0); - TESTEQUALS(c.last(1, p2)->value, 1); - TESTEQUALS(c.last(5, p2)->value, 1); - TESTEQUALS(c.last(10, p2)->value, 2); - TESTEQUALS(c.last(47, p2)->value, 2); - - TESTEQUALS(c.last(0, pe)->value, 0); - TESTEQUALS(c.last(1, pe)->value, 1); - TESTEQUALS(c.last(5, pe)->value, 1); - TESTEQUALS(c.last(10, pe)->value, 2); - TESTEQUALS(c.last(47, pe)->value, 2); + TESTEQUALS(c.last(0, pa)->value(), 0); + TESTEQUALS(c.last(1, pa)->value(), 1); + TESTEQUALS(c.last(5, pa)->value(), 1); + TESTEQUALS(c.last(10, pa)->value(), 2); + TESTEQUALS(c.last(47, pa)->value(), 2); + + TESTEQUALS(c.last(0, p0)->value(), 0); + TESTEQUALS(c.last(1, p0)->value(), 1); + TESTEQUALS(c.last(5, p0)->value(), 1); + TESTEQUALS(c.last(10, p0)->value(), 2); + TESTEQUALS(c.last(47, p0)->value(), 2); + + TESTEQUALS(c.last(0, p1)->value(), 0); + TESTEQUALS(c.last(1, p1)->value(), 1); + TESTEQUALS(c.last(5, p1)->value(), 1); + TESTEQUALS(c.last(10, p1)->value(), 2); + TESTEQUALS(c.last(47, p1)->value(), 2); + + TESTEQUALS(c.last(0, p2)->value(), 0); + TESTEQUALS(c.last(1, p2)->value(), 1); + TESTEQUALS(c.last(5, p2)->value(), 1); + TESTEQUALS(c.last(10, p2)->value(), 2); + TESTEQUALS(c.last(47, p2)->value(), 2); + + TESTEQUALS(c.last(0, pe)->value(), 0); + TESTEQUALS(c.last(1, pe)->value(), 1); + TESTEQUALS(c.last(5, pe)->value(), 1); + TESTEQUALS(c.last(10, pe)->value(), 2); + TESTEQUALS(c.last(47, pe)->value(), 2); // Now test the basic erase() function // Delete the 1-element, new values should be [-inf:0, 0:0, 10:2] c.erase(c.last(1)); - TESTEQUALS(c.last(1)->value, 0); - TESTEQUALS(c.last(5)->value, 0); - TESTEQUALS(c.last(47)->value, 2); + TESTEQUALS(c.last(1)->value(), 0); + TESTEQUALS(c.last(5)->value(), 0); + TESTEQUALS(c.last(47)->value(), 2); // should do nothing, since we delete all at > 99, // but the last element is at 10. should still be [-inf:0, 0:0, 10:2] c.erase_after(c.last(99)); - TESTEQUALS(c.last(47)->value, 2); + TESTEQUALS(c.last(47)->value(), 2); // now since 5 < 10, element with value 2 has to be gone // result should be [-inf:0, 0:0] c.erase_after(c.last(5)); - TESTEQUALS(c.last(47)->value, 0); + TESTEQUALS(c.last(47)->value(), 0); c.insert_overwrite(0, 42); - TESTEQUALS(c.last(100)->value, 42); - TESTEQUALS(c.last(100)->time, 0); + TESTEQUALS(c.last(100)->value(), 42); + TESTEQUALS(c.last(100)->time(), 0); // the curve now contains [-inf:0, 0:42] // let's change/add some more elements c.insert_overwrite(0, 10); - TESTEQUALS(c.last(100)->value, 10); + TESTEQUALS(c.last(100)->value(), 10); c.insert_after(0, 11); c.insert_after(0, 12); // now: [-inf:0, 0:10, 0:11, 0:12] - TESTEQUALS(c.last(0)->value, 12); - TESTEQUALS(c.last(10)->value, 12); + TESTEQUALS(c.last(0)->value(), 12); + TESTEQUALS(c.last(10)->value(), 12); c.insert_before(0, 2); // all the values at t=0 should be 2, 10, 11, 12 c.insert_after(1, 15); - TESTEQUALS(c.last(1)->value, 15); - TESTEQUALS(c.last(10)->value, 15); + TESTEQUALS(c.last(1)->value(), 15); + TESTEQUALS(c.last(10)->value(), 15); c.insert_overwrite(2, 20); - TESTEQUALS(c.last(1)->value, 15); - TESTEQUALS(c.last(2)->value, 20); - TESTEQUALS(c.last(10)->value, 20); + TESTEQUALS(c.last(1)->value(), 15); + TESTEQUALS(c.last(2)->value(), 20); + TESTEQUALS(c.last(10)->value(), 20); c.insert_before(3, 25); - TESTEQUALS(c.last(1)->value, 15); - TESTEQUALS(c.last(2)->value, 20); - TESTEQUALS(c.last(3)->value, 25); - TESTEQUALS(c.last(10)->value, 25); + TESTEQUALS(c.last(1)->value(), 15); + TESTEQUALS(c.last(2)->value(), 20); + TESTEQUALS(c.last(3)->value(), 25); + TESTEQUALS(c.last(10)->value(), 25); // now it should be [-inf: 0, 0: 2, 0: 10, 0: 11, 0: 12, 1: 15, 2: 20, // 3: 25] { auto it = c.begin(); - TESTEQUALS(it->time, time::TIME_MIN); - TESTEQUALS(it->value, 0); + TESTEQUALS(it->time(), time::TIME_MIN); + TESTEQUALS(it->value(), 0); - TESTEQUALS((++it)->time, 0); - TESTEQUALS(it->value, 2); + TESTEQUALS((++it)->time(), 0); + TESTEQUALS(it->value(), 2); - TESTEQUALS((++it)->time, 0); - TESTEQUALS(it->value, 10); + TESTEQUALS((++it)->time(), 0); + TESTEQUALS(it->value(), 10); - TESTEQUALS((++it)->time, 0); - TESTEQUALS(it->value, 11); + TESTEQUALS((++it)->time(), 0); + TESTEQUALS(it->value(), 11); - TESTEQUALS((++it)->time, 0); - TESTEQUALS(it->value, 12); + TESTEQUALS((++it)->time(), 0); + TESTEQUALS(it->value(), 12); - TESTEQUALS((++it)->time, 1); - TESTEQUALS(it->value, 15); + TESTEQUALS((++it)->time(), 1); + TESTEQUALS(it->value(), 15); - TESTEQUALS((++it)->time, 2); - TESTEQUALS(it->value, 20); + TESTEQUALS((++it)->time(), 2); + TESTEQUALS(it->value(), 20); - TESTEQUALS((++it)->time, 3); - TESTEQUALS(it->value, 25); + TESTEQUALS((++it)->time(), 3); + TESTEQUALS(it->value(), 25); } // TODO: test c.insert_overwrite and c.insert_after @@ -170,17 +170,17 @@ void curve_types() { KeyframeContainer c2; c2.sync(c, 1); // now c2 should be [-inf: 0, 1: 15, 2: 20, 3: 25] - TESTEQUALS(c2.last(0)->value, 0); - TESTEQUALS(c2.last(1)->value, 15); - TESTEQUALS(c2.last(2)->value, 20); - TESTEQUALS(c2.last(3)->value, 25); - TESTEQUALS(c2.last(10)->value, 25); + TESTEQUALS(c2.last(0)->value(), 0); + TESTEQUALS(c2.last(1)->value(), 15); + TESTEQUALS(c2.last(2)->value(), 20); + TESTEQUALS(c2.last(3)->value(), 25); + TESTEQUALS(c2.last(10)->value(), 25); TESTEQUALS(c2.size(), 4); c.clear(); // now it should be [-inf: 0] - TESTEQUALS(c.last(0)->value, 0); - TESTEQUALS(c.last(1)->value, 0); + TESTEQUALS(c.last(0)->value(), 0); + TESTEQUALS(c.last(1)->value(), 0); TESTEQUALS(c.size(), 1); } @@ -232,7 +232,7 @@ void curve_types() { TESTEQUALS(c.get(8), 4); } - //Check the discrete type + // Check the discrete type { auto f = std::make_shared(); Discrete c(f, 0); @@ -257,7 +257,7 @@ void curve_types() { TESTEQUALS(complex.get(10), "Test 10"); } - //Check the discrete mod type + // Check the discrete mod type { auto f = std::make_shared(); DiscreteMod c(f, 0); @@ -290,7 +290,7 @@ void curve_types() { TESTEQUALS(c.get_mod(15, 0), 0); } - //check set_last + // check set_last { auto f = std::make_shared(); Discrete c(f, 0);