2016-01-17 01:24:35 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "storage/edge.hpp"
|
|
|
|
#include "storage/record_accessor.hpp"
|
2016-07-07 00:37:05 +08:00
|
|
|
#include "utils/assert.hpp"
|
|
|
|
#include "utils/reference_wrapper.hpp"
|
2016-01-17 01:24:35 +08:00
|
|
|
|
|
|
|
class Edges;
|
|
|
|
|
2016-08-08 16:32:34 +08:00
|
|
|
// TODO: Edge, Db, Edge::Accessor
|
2016-01-17 01:24:35 +08:00
|
|
|
class Edge::Accessor : public RecordAccessor<Edge, Edges, Edge::Accessor>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using RecordAccessor::RecordAccessor;
|
2016-03-13 03:16:19 +08:00
|
|
|
|
2016-07-07 00:37:05 +08:00
|
|
|
void edge_type(edge_type_ref_t edge_type)
|
2016-03-13 03:16:19 +08:00
|
|
|
{
|
2016-07-07 00:37:05 +08:00
|
|
|
this->record->data.edge_type = &edge_type.get();
|
2016-03-13 03:16:19 +08:00
|
|
|
}
|
|
|
|
|
2016-07-07 00:37:05 +08:00
|
|
|
edge_type_ref_t edge_type() const
|
2016-03-20 15:56:13 +08:00
|
|
|
{
|
2016-07-07 00:37:05 +08:00
|
|
|
runtime_assert(this->record->data.edge_type != nullptr,
|
|
|
|
"EdgeType is null");
|
|
|
|
return edge_type_ref_t(*this->record->data.edge_type);
|
2016-03-20 15:56:13 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 16:32:34 +08:00
|
|
|
// TODO: VertexAccessor
|
2016-07-07 00:37:05 +08:00
|
|
|
void from(VertexRecord *vertex_record)
|
2016-03-13 03:16:19 +08:00
|
|
|
{
|
|
|
|
this->record->data.from = vertex_record;
|
|
|
|
}
|
|
|
|
|
2016-07-07 00:37:05 +08:00
|
|
|
void to(VertexRecord *vertex_record)
|
2016-03-13 03:16:19 +08:00
|
|
|
{
|
|
|
|
this->record->data.to = vertex_record;
|
|
|
|
}
|
2016-07-03 08:02:42 +08:00
|
|
|
|
2016-08-08 04:19:04 +08:00
|
|
|
auto from() const { return this->record->data.from; }
|
2016-07-03 08:02:42 +08:00
|
|
|
|
2016-08-08 04:19:04 +08:00
|
|
|
auto to() const { return this->record->data.to; }
|
2016-01-17 01:24:35 +08:00
|
|
|
};
|