mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 07:40:42 +01:00
[apps/graph] implement add and remove functions in function store
Change-Id: Iabbe9a83f575a81081999d65e6faedbc05476626
This commit is contained in:
@@ -3,10 +3,8 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
constexpr int numberOfDefaultColors = 3;
|
||||
constexpr KDColor defaultColors[numberOfDefaultColors] = {
|
||||
KDColorRed, KDColorGreen, KDColorBlue
|
||||
};
|
||||
constexpr int Graph::FunctionStore::numberOfDefaultColors;
|
||||
constexpr KDColor Graph::FunctionStore::defaultColors[numberOfDefaultColors];
|
||||
|
||||
Graph::FunctionStore::FunctionStore() :
|
||||
m_numberOfFunctions(0)
|
||||
@@ -18,10 +16,21 @@ Graph::Function * Graph::FunctionStore::functionAtIndex(int i) {
|
||||
return &m_functions[i];
|
||||
}
|
||||
|
||||
void Graph::FunctionStore::pushFunction(const char * functionText) {
|
||||
void Graph::FunctionStore::addFunction(Function * f) {
|
||||
assert(m_numberOfFunctions < k_maxNumberOfFunctions);
|
||||
m_functions[m_numberOfFunctions] = Function(functionText, defaultColors[m_numberOfFunctions%numberOfDefaultColors]);
|
||||
m_numberOfFunctions++;
|
||||
m_functions[m_numberOfFunctions++] = (*f);
|
||||
}
|
||||
|
||||
void Graph::FunctionStore::removeFunction(Function * f) {
|
||||
int i = 0;
|
||||
while (&m_functions[i] != f && i < m_numberOfFunctions) {
|
||||
i++;
|
||||
}
|
||||
assert(i>=0 && i<m_numberOfFunctions);
|
||||
m_numberOfFunctions--;
|
||||
for (int j = i; j<m_numberOfFunctions; j++) {
|
||||
m_functions[j] = m_functions[j+1];
|
||||
}
|
||||
}
|
||||
|
||||
int Graph::FunctionStore::numberOfFunctions() {
|
||||
|
||||
Reference in New Issue
Block a user