Numworks Epsilon  1.4.1
Graphing Calculator Operating System
function_store.cpp
Go to the documentation of this file.
1 #include "function_store.h"
2 #include <assert.h>
3 
4 namespace Shared {
5 
7  m_numberOfFunctions(0)
8 {
9 }
10 
12  assert(i>=0 && i<m_numberOfFunctions);
13  int index = 0;
14  for (int k = 0; k < m_numberOfFunctions; k++) {
15  Function * function = functionAtIndex(k);
16  if (function->isActive() && function->isDefined()) {
17  if (i == index) {
18  return function;
19  }
20  index++;
21  }
22  }
23  assert(false);
24  return nullptr;
25 }
26 
28  assert(i>=0 && i<m_numberOfFunctions);
29  int index = 0;
30  for (int k = 0; k < m_numberOfFunctions; k++) {
31  if (functionAtIndex(k)->isDefined()) {
32  if (i == index) {
33  return functionAtIndex(k);
34  }
35  index++;
36  }
37  }
38  assert(false);
39  return nullptr;
40 }
41 
43  return m_numberOfFunctions;
44 }
45 
47  int result = 0;
48  for (int i = 0; i < m_numberOfFunctions; i++) {
49  Function * function = functionAtIndex(i);
50  if (function->isDefined() && function->isActive()) {
51  result++;
52  }
53  }
54  return result;
55 }
56 
58  int result = 0;
59  for (int i = 0; i < m_numberOfFunctions; i++) {
60  if (functionAtIndex(i)->isDefined()) {
61  result++;
62  }
63  }
64  return result;
65 }
66 
68  for (int i = 0; i < m_numberOfFunctions; i++) {
69  functionAtIndex(i)->tidy();
70  }
71 }
72 
73 }
#define assert(e)
Definition: assert.h:9
virtual void tidy()
Definition: function.cpp:115
virtual Function * functionAtIndex(int i)=0
virtual Function * definedFunctionAtIndex(int i)
virtual Function * activeFunctionAtIndex(int i)