Hypercube is designed to be easily extensible to handle additional input/output file formats. To add an extension (provider), the following steps must be done:
hypercube.pro
and
hypercube-cli.pro
.inputProviders
or
outputProviders
array in IO/modules.cpp
#include "IO/io.h" class MyInputProvider: public InputProvider { public: virtual Error readGraph(Graph *graph, const char *fileName) = 0; virtual void setInputEncoding(Encoding *encoding); };
The input provider interface consists of a single required method -
readGraph()
and a optional method,
setInputEncoding()
. The readGraph() implementation has to
construct the graph graph
from the input file
fileName
.
Adding vertexes and edges to the graph is done using the
addVertex()
and addEdge()
methods of the
Graph
class. For setting vertex/edge attributes see the
Vertex
and Edge
classes.
The optional setInputEncoding()
method sets the input file
encoding given by the user (intended for formats without encoding info).
#include "IO/io.h" class MyOutputProvider: public OutputProvider { public: virtual Error writeGraph(Graph *graph, const char *fileName) = 0; virtual const char* type() = 0; virtual const char* description() = 0; };
The type()
and description()
methods describe the
output provider for the user. For example for a
PDF output provider,
type()
would return "pdf" and description()
"Portable Document Format".
The writeGraph()
method implements the graph export itself. See
the Graph
class for how to iterate through the vertexes/edges and
the Vertex
and Edge
classes for available vertex/edge
attributes.