-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassDiagram.cpp
53 lines (40 loc) · 1.21 KB
/
ClassDiagram.cpp
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
46
47
48
49
50
51
52
//
// Created by hegedus on 2017.12.14..
//
#include "ClassDiagram.h"
#include "Generalization.h"
ClassDiagram::ClassDiagram() {
initDotFile();
}
std::string ClassDiagram::getContent() {
for(auto c : diagram) {
c.second.write(classes_content);
}
for(auto const &r : relations) {
relations_content += r->write();
}
return content + classes_content + relations_content + "\n}";
}
void ClassDiagram::addClass(Class c) {
diagram[c.getName()] = c;
}
void ClassDiagram::addRelation(IRelation *relation) {
relations.push_back(relation);
}
void ClassDiagram::initDotFile() {
std::string type = "digraph G {\n";
std::string fontname = "\tfontname = \"Bitstream Vera Sans\"\n";
std::string fontsize = "\tfontsize = 8\n";
std::string node = "\n\n \tnode [\n\t" + fontname + "\t" + fontsize;
std::string shape = "\t\tshape = \"record\"\n\t]\n\n";
std::string edge = "\tedge [\n\t" + fontname + "\t" + fontsize + "\t]\n\n";
content = type + fontname + fontsize + node + shape + edge;
}
const Class& ClassDiagram::getClass(std::string const &name) {
return diagram[name];
}
ClassDiagram::~ClassDiagram() {
for(auto v : relations) {
delete v;
}
}