[apps/graph] Add methods to find active functions in function store

Change-Id: Ibe7242b945160b8917421186d061c46301bb004d
This commit is contained in:
Émilie Feral
2016-10-07 14:08:09 +02:00
parent 22271b1f74
commit bda1982db0
2 changed files with 27 additions and 0 deletions

View File

@@ -17,6 +17,21 @@ Graph::Function * Graph::FunctionStore::functionAtIndex(int i) {
return &m_functions[i];
}
Graph::Function * Graph::FunctionStore::activeFunctionAtIndex(int i) {
assert(i>=0 && i<m_numberOfFunctions);
int index = 0;
for (int k = 0; k < m_numberOfFunctions; k++) {
if (m_functions[k].isActive()) {
if (i == index) {
return &m_functions[k];
}
index++;
}
}
assert(false);
return nullptr;
}
Graph::Function * Graph::FunctionStore::addEmptyFunction() {
assert(m_numberOfFunctions < k_maxNumberOfFunctions);
const char * name = firstAvailableName();
@@ -44,6 +59,16 @@ int Graph::FunctionStore::numberOfFunctions() {
return m_numberOfFunctions;
}
int Graph::FunctionStore::numberOfActiveFunctions() {
int result = 0;
for (int i = 0; i < m_numberOfFunctions; i++) {
if (m_functions[i].isActive()) {
result++;
}
}
return result;
}
const char * Graph::FunctionStore::firstAvailableName() {
for (int k = 0; k < k_maxNumberOfFunctions; k++) {
int j = 0;