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
6
FunctionStore::FunctionStore
() :
7
m_numberOfFunctions(0)
8
{
9
}
10
11
Function
*
FunctionStore::activeFunctionAtIndex
(
int
i) {
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
27
Function
*
FunctionStore::definedFunctionAtIndex
(
int
i) {
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
42
int
FunctionStore::numberOfFunctions
() {
43
return
m_numberOfFunctions
;
44
}
45
46
int
FunctionStore::numberOfActiveFunctions
() {
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
57
int
FunctionStore::numberOfDefinedFunctions
() {
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
67
void
FunctionStore::tidy
() {
68
for
(
int
i = 0; i <
m_numberOfFunctions
; i++) {
69
functionAtIndex
(i)->
tidy
();
70
}
71
}
72
73
}
Shared
Definition:
banner_view.cpp:5
assert
#define assert(e)
Definition:
assert.h:9
Shared::Function::tidy
virtual void tidy()
Definition:
function.cpp:115
Shared::FunctionStore::tidy
void tidy()
Definition:
function_store.cpp:67
Shared::Function
Definition:
function.h:10
Shared::FunctionStore::numberOfFunctions
int numberOfFunctions()
Definition:
function_store.cpp:42
Shared::FunctionStore::functionAtIndex
virtual Function * functionAtIndex(int i)=0
assert.h
Shared::FunctionStore::definedFunctionAtIndex
virtual Function * definedFunctionAtIndex(int i)
Definition:
function_store.cpp:27
Shared::FunctionStore::m_numberOfFunctions
int m_numberOfFunctions
Definition:
function_store.h:31
Shared::FunctionStore::FunctionStore
FunctionStore()
Definition:
function_store.cpp:6
Shared::FunctionStore::activeFunctionAtIndex
virtual Function * activeFunctionAtIndex(int i)
Definition:
function_store.cpp:11
Shared::FunctionStore::numberOfActiveFunctions
int numberOfActiveFunctions()
Definition:
function_store.cpp:46
Shared::FunctionStore::numberOfDefinedFunctions
int numberOfDefinedFunctions()
Definition:
function_store.cpp:57
function_store.h
epsilon
apps
shared
function_store.cpp
Generated by
1.8.14