-
Notifications
You must be signed in to change notification settings - Fork 5
/
AbstractStatCollector.cpp
74 lines (50 loc) · 1.74 KB
/
AbstractStatCollector.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "AbstractStatCollector.h"
using namespace VcfStatsAlive;
AbstractStatCollector::AbstractStatCollector(const std::string* sampleName) {
_children.clear();
}
AbstractStatCollector::~AbstractStatCollector() {
}
void AbstractStatCollector::addChild(StatCollectorPtr child) {
// Make sure that the input is good
if(child.get() == nullptr) return;
// Make sure the input is not yet a child
auto loc = std::find(_children.cbegin(), _children.cend(), child);
if(loc != _children.cend()) return;
// Insert the input to the end of the children list
_children.push_back(child);
}
void AbstractStatCollector::removeChild(StatCollectorPtr child) {
// Make sure that the input is good
if(child.get() == nullptr) return;
// Make sure the input is a child
auto loc = std::find(_children.begin(), _children.end(), child);
if(loc == _children.end()) return;
_children.erase(loc);
}
void AbstractStatCollector::processVariant(bcf_hdr_t* hdr, bcf1_t* var) {
this->processVariantImpl(hdr, var);
for(auto iter = _children.begin(); iter != _children.end(); iter++) {
(*iter)->processVariant(hdr, var);
}
}
json_t * AbstractStatCollector::appendJson(json_t * jsonRootObj) {
if(jsonRootObj == NULL)
return NULL;
this->appendJsonImpl(jsonRootObj);
for(auto iter = _children.begin(); iter != _children.end(); iter++) {
(*iter)->appendJson(jsonRootObj);
}
return jsonRootObj;
}
bool AbstractStatCollector::isSatisfiedImpl() {
return false;
}
bool AbstractStatCollector::isSatisfied() {
if (not this->isSatisfiedImpl()) return false;
bool isChildrenSatisfied = true;
for(auto iter = _children.begin(); iter != _children.end(); iter++) {
isChildrenSatisfied = isChildrenSatisfied && (*iter)->isSatisfied();
}
return isChildrenSatisfied;
}