collection_proxy progress added test frame

This commit is contained in:
sascha 2026-06-26 15:52:53 +02:00
parent 47fd6d68e4
commit 1b98eb4019
3 changed files with 28 additions and 21 deletions

View File

@ -24,7 +24,9 @@ struct relation_iterator_traits;
template < typename Type, typename OwnerType >
struct relation_iterator_traits<relation<OwnerType, Type>> {
static Type& value(relation<OwnerType, Type>& re) {
return re.relation().value();
}
};
template<typename Type, typename RelationType = Type>
@ -33,6 +35,7 @@ public:
using value_type = Type;
using reference = Type&;
using pointer = Type*;
using relation_type = RelationType;
using iterator_category = std::forward_iterator_tag;
collection_proxy_iterator() = default;
@ -52,6 +55,9 @@ public:
return !operator==(other);
}
relation_type& relation() {
return *it_;
}
private:
typename std::vector<RelationType>::iterator it_;
};
@ -70,13 +76,10 @@ public:
virtual iterator begin() = 0;
virtual iterator end() = 0;
virtual const_iterator begin() const = 0;
virtual const_iterator end() const = 0;
[[nodiscard]] virtual size_t size() const = 0;
[[nodiscard]] virtual bool empty() const = 0;
// virtual collection_proxy_iterator<Type> begin() = 0;
// virtual collection_proxy_iterator<Type> end() = 0;
[[nodiscard]] virtual size_t size() = 0;
[[nodiscard]] virtual bool empty() = 0;
[[nodiscard]] virtual const utils::identifier& owner_id() const = 0;
protected:
@ -117,23 +120,19 @@ public:
return items_.end();
}
const_iterator begin() const override {
void push_back(const value_type& value) override {
resolve();
return items_.begin();
items_.push_back(value);
}
[[nodiscard]] size_t size() override {
resolve();
return items_.size();
}
[[nodiscard]] bool empty() override {
resolve();
return items_.empty();
}
const_iterator end() const override {
resolve();
return items_.end();
}
// const std::vector<Type>& items() const {
// resolve();
// return items_;
// }
// std::vector<Type>& items() {
// resolve();
// return items_;
// }
private:
void resolve() {
if (loaded_) {

View File

@ -5,6 +5,7 @@ list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
add_executable(CoreTests
../backends/SchemaFixture.hpp
logger/LoggerTest.cpp
object/CollectionTest.cpp
object/ObjectCacheTest.cpp
object/ObjectTest.cpp
object/PrimaryKeyResolverTest.cpp

View File

@ -0,0 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include "matador/object/collection.hpp"
#include "matador/object/object.hpp"
TEST_CASE("Test collection", "[collection]") {
}