df0bf6fa5f
DbAccessor: -Guarantees that access to Vertex and Edge is possible only through Vertex::Accessor and Edge::Accessor. -Guarantees that changing Vertex and Edge is possible only using Vertex::Accessor returned by vertex_insert() method and Edge::Accessor returned by edge_insert() method. -Offers CRUD for Vertex and Edge except iterating over all edges. Squashed commit messages: First step in database accessor refactoring done. It's compiling. All tests with exception of integration_querys pass Tests now initialize logging facilities. Refactored accessors. RecordAccessor now has 3 states. From,To,Out,In in there respecive Accessors return unfilled RecordAccessor. Added iterator classes into utils/itearator/.
49 lines
987 B
C++
49 lines
987 B
C++
#pragma once
|
|
|
|
#include "utils/option.hpp"
|
|
|
|
namespace iter
|
|
{
|
|
template <class T, class I, class A>
|
|
class Iter
|
|
{
|
|
public:
|
|
Iter() = delete;
|
|
|
|
Iter(A &&acc) : begin(std::move(acc.begin())), acc(std::forward<A>(acc)) {}
|
|
// Iter(const Iter &other) = delete;
|
|
// Iter(Iter &&other) :
|
|
// begin(std::move(other.begin)),end(std::move(other.end)) {};
|
|
|
|
auto next()
|
|
{
|
|
if (begin != acc.end()) {
|
|
auto ret = Option<T>(&(*(begin.operator->())));
|
|
begin++;
|
|
return ret;
|
|
} else {
|
|
return Option<T>();
|
|
}
|
|
}
|
|
|
|
private:
|
|
I begin;
|
|
A acc;
|
|
};
|
|
|
|
// TODO: Join to make functions into one
|
|
template <class A>
|
|
auto make_iter(A &&acc)
|
|
{
|
|
return Iter<decltype(&(*(acc.begin().operator->()))), decltype(acc.begin()),
|
|
A>(std::move(acc));
|
|
}
|
|
|
|
template <class A>
|
|
auto make_iter_ref(A &acc)
|
|
{
|
|
return Iter<decltype(&(*(acc.begin().operator->()))), decltype(acc.begin()),
|
|
A &>(acc);
|
|
}
|
|
}
|