Files
Upsilon/apps/shared/function.h
Émilie Feral ba7d740a10 [apps/sequence][apps/graph] CRC should be called on sizes multiple of 4
Change-Id: I4a55c14e1418f730051252cabef324833279747f
2017-05-24 14:38:32 +02:00

48 lines
1.5 KiB
C++

#ifndef SHARED_FUNCTION_H
#define SHARED_FUNCTION_H
#include <poincare.h>
#include <kandinsky.h>
#include <escher.h>
namespace Shared {
class Function {
public:
Function(const char * name = nullptr, KDColor color = KDColorBlack);
virtual ~Function(); // Delete expression and layout, if needed
Function& operator=(const Function& other);
Function& operator=(Function&& other) = delete;
Function(const Function& other) = delete;
Function(Function&& other) = delete;
virtual uint32_t checksum();
const char * text() const;
const char * name() const;
KDColor color() const { return m_color; }
Poincare::Expression * expression() const;
Poincare::ExpressionLayout * layout();
virtual bool isDefined();
bool isActive();
void setActive(bool active);
virtual bool isEmpty();
virtual void setContent(const char * c);
void setColor(KDColor m_color);
virtual float evaluateAtAbscissa(float x, Poincare::Context * context) const;
virtual void tidy();
protected:
mutable Poincare::Expression * m_expression;
private:
constexpr static size_t k_dataLengthInBytes = TextField::maxBufferSize()*sizeof(char)+2;
static_assert((k_dataLengthInBytes & 0x3) == 0, "The function data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4
virtual char symbol() const = 0;
char m_text[TextField::maxBufferSize()];
const char * m_name;
KDColor m_color;
Poincare::ExpressionLayout * m_layout;
bool m_active;
};
}
#endif