-
Notifications
You must be signed in to change notification settings - Fork 5
/
DumperManager.hpp
45 lines (37 loc) · 1.1 KB
/
DumperManager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef __DUMPERMANAGER__
#define __DUMPERMANAGER__
#include "GraphvizDumper.hpp"
class DumperManager
{
public:
DumperManager(IGraphDB* graphdb)
: __graphdb(graphdb)
{
this->__dumpers["graphviz"] = new GraphvizDumper();
}
~DumperManager()
{}
std::string operator()(std::string const& graph_name, std::string const& dumper_name, Protocol::error_code& error_code) const
{
if (this->__exists(dumper_name) == false)
{
error_code = Protocol::DOESNT_EXIST;
return std::string("");
}
error_code = Protocol::OK;
Graph* current = this->__graphdb->get(graph_name, error_code);
if (error_code != Protocol::OK)
return std::string("");
return (*this->__dumpers.at(dumper_name))(current, error_code);
}
private:
DumperManager(const DumperManager&);
DumperManager& operator=(const DumperManager&);
bool __exists(std::string const& dumper_name) const
{
return (this->__dumpers.find(dumper_name) != this->__dumpers.end());
}
IGraphDB* __graphdb;
std::map<std::string, ADumper const*> __dumpers;
};
#endif /* __DUMPERMANAGER__ */