2015-11-22 02:16:19 +08:00
|
|
|
#pragma once
|
2015-07-07 22:18:26 +08:00
|
|
|
|
2015-12-06 23:37:42 +08:00
|
|
|
#include "mvcc/record.hpp"
|
2016-11-29 11:08:08 +08:00
|
|
|
#include "storage/label/labels_writer.hpp"
|
|
|
|
#include "storage/model/properties/json_writer.hpp"
|
2016-08-15 07:09:58 +08:00
|
|
|
#include "storage/model/vertex_model.hpp"
|
2016-11-29 11:08:08 +08:00
|
|
|
#include "utils/handle_write.hpp"
|
|
|
|
#include "utils/string_buffer.hpp"
|
2015-07-07 22:18:26 +08:00
|
|
|
|
2015-12-06 23:37:42 +08:00
|
|
|
class Vertex : public mvcc::Record<Vertex>
|
2015-07-07 22:18:26 +08:00
|
|
|
{
|
2016-11-29 11:08:08 +08:00
|
|
|
using buffer_t = utils::StringBuffer;
|
|
|
|
using props_writer_t = JsonWriter<buffer_t>;
|
|
|
|
using labels_writer_t = LabelsWriter<buffer_t>;
|
|
|
|
|
2015-12-06 23:37:42 +08:00
|
|
|
public:
|
2016-01-02 19:20:51 +08:00
|
|
|
class Accessor;
|
|
|
|
|
2015-12-06 23:37:42 +08:00
|
|
|
Vertex() = default;
|
2016-08-15 07:09:58 +08:00
|
|
|
Vertex(const VertexModel &data) : data(data) {}
|
|
|
|
Vertex(VertexModel &&data) : data(std::move(data)) {}
|
2015-12-06 23:37:42 +08:00
|
|
|
|
2016-08-15 07:09:58 +08:00
|
|
|
Vertex(const Vertex &) = delete;
|
2016-11-29 11:08:08 +08:00
|
|
|
Vertex(Vertex &&) = delete;
|
2015-12-06 23:37:42 +08:00
|
|
|
|
2016-08-15 07:09:58 +08:00
|
|
|
Vertex &operator=(const Vertex &) = delete;
|
|
|
|
Vertex &operator=(Vertex &&) = delete;
|
2015-12-06 23:37:42 +08:00
|
|
|
|
|
|
|
VertexModel data;
|
2015-10-08 06:58:29 +08:00
|
|
|
|
2016-11-29 11:08:08 +08:00
|
|
|
template <typename Stream>
|
|
|
|
void stream_repr(Stream &stream) const
|
|
|
|
{
|
|
|
|
auto props = handle_write<buffer_t, props_writer_t>(data.props);
|
|
|
|
auto labels = handle_write<buffer_t, labels_writer_t>(data.labels);
|
|
|
|
|
|
|
|
stream << "Vertex(cre = " << tx.cre() << ", "
|
|
|
|
<< "exp = " << tx.exp() << ", "
|
|
|
|
<< "props = " << props.str() << ", "
|
|
|
|
<< "labels = " << labels.str() << ")";
|
|
|
|
}
|
|
|
|
};
|