Files
Upsilon/apps/graph/storage_cartesian_function_store.cpp
Émilie Feral c70278941a [graph] Do not keep a function pointer as member variable but a record.
Indeed, function pointers can become invalid at any point...
2018-11-23 12:04:02 +01:00

29 lines
851 B
C++

#include "storage_cartesian_function_store.h"
extern "C" {
#include <assert.h>
#include <stddef.h>
}
#include <ion.h>
using namespace Shared;
namespace Graph {
Ion::Storage::Record::ErrorStatus StorageCartesianFunctionStore::addEmptyModel() {
Ion::Storage::Record::ErrorStatus error;
StorageCartesianFunction newModel = StorageCartesianFunction::NewModel(&error);
return error;
}
void StorageCartesianFunctionStore::setMemoizedModelAtIndex(int cacheIndex, Ion::Storage::Record record) const {
assert(cacheIndex >= 0 && cacheIndex < k_maxNumberOfMemoizedModels);
m_functions[cacheIndex] = StorageCartesianFunction(record);
}
StorageExpressionModel * StorageCartesianFunctionStore::memoizedModelAtIndex(int cacheIndex) const {
assert(cacheIndex >= 0 && cacheIndex < k_maxNumberOfMemoizedModels);
return &m_functions[cacheIndex];
}
}