mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
We memoize the checksum of the x first models, and we check that one of these models is still present when the graph view appears. If so, we do not reload the range, other wise we reload it. Scenario: f(t) = [t^2 t+1] in parametric Display the graph f(x) = 1 on ]-inf;0] g(x) = 2 on [0;inf[ Display the graph -> the range did not change
34 lines
1.0 KiB
C++
34 lines
1.0 KiB
C++
#ifndef SHARED_FUNCTION_STORE_H
|
|
#define SHARED_FUNCTION_STORE_H
|
|
|
|
#include "function.h"
|
|
#include "expression_model_store.h"
|
|
#include <stdint.h>
|
|
|
|
namespace Shared {
|
|
|
|
// FunctionStore stores functions and gives them a color.
|
|
|
|
class FunctionStore : public ExpressionModelStore {
|
|
public:
|
|
FunctionStore() : ExpressionModelStore() {}
|
|
uint32_t storeChecksum();
|
|
uint32_t storeChecksumAtIndex(size_t i);
|
|
int numberOfActiveFunctions() const {
|
|
return numberOfModelsSatisfyingTest(&isFunctionActive, nullptr);
|
|
}
|
|
Ion::Storage::Record activeRecordAtIndex(int i) const {
|
|
return recordSatisfyingTestAtIndex(i, &isFunctionActive, nullptr);
|
|
}
|
|
ExpiringPointer<Function> modelForRecord(Ion::Storage::Record record) const { return ExpiringPointer<Function>(static_cast<Function *>(privateModelForRecord(record))); }
|
|
protected:
|
|
static bool isFunctionActive(ExpressionModelHandle * model, void * context) {
|
|
// An active function must be defined
|
|
return isModelDefined(model, context) && static_cast<Function *>(model)->isActive();
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|