diff --git a/apps/graph/function_store.cpp b/apps/graph/function_store.cpp index 5f33d0122..67f05b7b0 100644 --- a/apps/graph/function_store.cpp +++ b/apps/graph/function_store.cpp @@ -3,10 +3,8 @@ extern "C" { #include } -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