-
Notifications
You must be signed in to change notification settings - Fork 3
/
AbstractStatCollector.cc
76 lines (53 loc) · 1.92 KB
/
AbstractStatCollector.cc
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
75
76
#include "AbstractStatCollector.h"
using namespace BamstatsAlive;
AbstractStatCollector::AbstractStatCollector() {
_children.clear();
}
AbstractStatCollector::~AbstractStatCollector() {
}
void AbstractStatCollector::addChild(AbstractStatCollector *child) {
// Make sure that the input is good
if(child == NULL) return;
// Make sure the input is not yet a child
StatCollectorPtrVec::const_iterator loc = std::find(_children.begin(), _children.end(), child);
if(loc != _children.end()) return;
// Insert the input to the end of the children list
_children.push_back(child);
}
void AbstractStatCollector::removeChild(AbstractStatCollector * child) {
// Make sure that the input is good
if(child == NULL) return;
// Make sure the input is a child
StatCollectorPtrVec::iterator loc = std::find(_children.begin(), _children.end(), child);
if(loc == _children.end()) return;
_children.erase(loc);
}
void AbstractStatCollector::processAlignment(const BamTools::BamAlignment& al, const BamTools::RefVector& refVector) {
this->processAlignmentImpl(al, refVector);
StatCollectorPtrVec::iterator iter;
for(iter = _children.begin(); iter != _children.end(); iter++) {
(*iter)->processAlignment(al, refVector);
}
}
json_t * AbstractStatCollector::appendJson(json_t * jsonRootObj) {
if(jsonRootObj == NULL)
jsonRootObj = json_object();
this->appendJsonImpl(jsonRootObj);
StatCollectorPtrVec::iterator iter;
for(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;
StatCollectorPtrVec::iterator iter;
for(iter = _children.begin(); iter != _children.end(); iter++) {
isChildrenSatisfied = isChildrenSatisfied && (*iter)->isSatisfied();
}
return isChildrenSatisfied;
}