[apps/graph/cartesian_function_store] Define activeRecordOfTypeAtIndex

This commit is contained in:
Ruben Dashyan
2019-08-22 16:38:29 +02:00
parent 826e2c7aaf
commit 35ee467965
2 changed files with 28 additions and 0 deletions

View File

@@ -9,6 +9,32 @@ using namespace Shared;
namespace Graph {
int CartesianFunctionStore::numberOfActiveFunctionsOfType(CartesianFunction::PlotType plotType) const {
int count = 0;
for (int i = 0; i < numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = activeRecordAtIndex(i);
ExpiringPointer<CartesianFunction> function = modelForRecord(record);
count += (plotType == function->plotType());
}
return count;
}
Ion::Storage::Record CartesianFunctionStore::activeRecordOfTypeAtIndex(CartesianFunction::PlotType plotType, int index) const {
int count = 0;
Ion::Storage::Record record;
for (int i = 0; i < numberOfActiveFunctions(); i++) {
record = activeRecordAtIndex(i);
ExpiringPointer<CartesianFunction> function = modelForRecord(record);
if (plotType == function->plotType()) {
if (count == index) {
break;
}
count++;
}
}
return record;
}
Ion::Storage::Record::ErrorStatus CartesianFunctionStore::addEmptyModel() {
Ion::Storage::Record::ErrorStatus error;
CartesianFunction newModel = CartesianFunction::NewModel(&error);