2015-11-22 02:16:19 +08:00
|
|
|
#pragma once
|
2015-07-07 22:18:26 +08:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2015-10-14 02:32:54 +08:00
|
|
|
#include "model/properties/jsonwriter.hpp"
|
2015-09-13 17:34:17 +08:00
|
|
|
#include "model/record.hpp"
|
2015-07-07 22:18:26 +08:00
|
|
|
#include "edge.hpp"
|
|
|
|
|
2015-07-31 18:31:08 +08:00
|
|
|
struct Vertex : public Record<Vertex>
|
2015-07-07 22:18:26 +08:00
|
|
|
{
|
2015-08-30 07:12:46 +08:00
|
|
|
std::vector<Edge*> in;
|
2015-07-31 18:31:08 +08:00
|
|
|
std::vector<Edge*> out;
|
2015-07-07 22:18:26 +08:00
|
|
|
};
|
|
|
|
|
2015-10-08 06:58:29 +08:00
|
|
|
inline std::ostream& operator<<(std::ostream& stream, Vertex& record)
|
|
|
|
{
|
2015-10-14 02:32:54 +08:00
|
|
|
StringBuffer buffer;
|
|
|
|
JsonWriter<StringBuffer> writer(buffer);
|
|
|
|
|
|
|
|
// dump properties in this buffer
|
|
|
|
record.properties.accept(writer);
|
2015-10-14 02:44:14 +08:00
|
|
|
writer.finish();
|
2015-10-08 06:58:29 +08:00
|
|
|
|
|
|
|
return stream << "Vertex"
|
|
|
|
<< "(xmin = " << record.tx.min()
|
|
|
|
<< ", xmax = " << record.tx.max()
|
2015-10-14 02:32:54 +08:00
|
|
|
<< "): " << buffer.str();
|
2015-10-08 06:58:29 +08:00
|
|
|
}
|
2015-11-05 07:46:13 +08:00
|
|
|
|
|
|
|
// TODO: find more appropriate place for this
|
|
|
|
inline std::string properties_to_string(Vertex* vertex)
|
|
|
|
{
|
|
|
|
// make a string buffer
|
|
|
|
StringBuffer buffer;
|
|
|
|
JsonWriter<StringBuffer> writer(buffer);
|
|
|
|
|
|
|
|
// dump properties in this buffer
|
|
|
|
vertex->properties.accept(writer);
|
|
|
|
writer.finish();
|
|
|
|
|
|
|
|
// respond to the use with the buffer
|
|
|
|
return std::move(buffer.str());
|
|
|
|
}
|