Commit efe5f363 authored by Mathieu Giraud's avatar Mathieu Giraud

core/output.{h,cpp}: SampleOutputVidjil, out(), with some polymorphism

See #3358.
parent 38931d16
......@@ -40,6 +40,14 @@ SampleOutput::SampleOutput(json init)
j = init;
}
SampleOutput::~SampleOutput()
{
}
void SampleOutput::out(ostream &s)
{
}
void SampleOutput::addClone(junction junction, CloneOutput *clone)
{
clones[junction] = clone;
......@@ -58,3 +66,17 @@ CloneOutput* SampleOutput::getClone(junction junction)
return clone;
}
}
void SampleOutputVidjil::out(ostream &s)
{
json j_clones;
for (auto it: clones)
j_clones.push_back(it.second->toJson());
j["clones"] = j_clones;
s << j.dump(2);
}
......@@ -36,11 +36,12 @@ public:
class SampleOutput : public Output
{
private:
protected:
map <junction, CloneOutput*> clones;
public:
SampleOutput(json init);
virtual ~SampleOutput();
void addClone(junction junction, CloneOutput *clone);
......@@ -48,6 +49,7 @@ public:
CloneOutput* getClone(junction junction);
json toJson();
void out(ostream &s);
};
......@@ -68,23 +70,14 @@ class CloneOutputFormatterJson(CloneOutputFormatter)
}
*/
/*
class SampleOutputFormatter
{
}
class SampleOutputFormatterCSV(SampleOutputFormatter)
// Native Json .vidjil format
// See vidjil-format.md
class SampleOutputVidjil : public SampleOutput
{
public:
void out(ostream &s);
};
}
class SampleOutputFormatterJson(SampleOutputFormatter)
{
}
*/
#endif
......@@ -1644,11 +1644,12 @@ int main (int argc, char **argv)
cout << endl;
}
//$ Output json
//$ Output .vidjil json
cout << " ==> " << f_json << "\t(data file for the web application)" << endl ;
ofstream out_json(f_json.c_str()) ;
SampleOutputVidjil *outputVidjil = static_cast<SampleOutputVidjil *>(output);
out_json << output.toJson().dump(2);
outputVidjil->out(out_json);
//$$ Clean
delete multigermline ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment