Numworks Epsilon  1.4.1
Graphing Calculator Operating System
function.h
Go to the documentation of this file.
1 #ifndef SHARED_FUNCTION_H
2 #define SHARED_FUNCTION_H
3 
4 #include <poincare.h>
5 #include <kandinsky.h>
6 #include <escher.h>
7 
8 namespace Shared {
9 
10 class Function {
11 public:
12  Function(const char * name = nullptr, KDColor color = KDColorBlack);
13  virtual ~Function(); // Delete expression and layout, if needed
14  Function& operator=(const Function& other);
15  Function& operator=(Function&& other) = delete;
16  Function(const Function& other) = delete;
17  Function(Function&& other) = delete;
18  virtual uint32_t checksum();
19  const char * text() const;
20  const char * name() const;
21  KDColor color() const { return m_color; }
24  virtual bool isDefined();
25  bool isActive();
26  void setActive(bool active);
27  virtual bool isEmpty();
28  virtual void setContent(const char * c);
29  void setColor(KDColor m_color);
30  virtual float evaluateAtAbscissa(float x, Poincare::Context * context) const {
31  return templatedApproximateAtAbscissa(x, context);
32  }
33  virtual double evaluateAtAbscissa(double x, Poincare::Context * context) const {
34  return templatedApproximateAtAbscissa(x, context);
35  }
36  virtual double sumBetweenBounds(double start, double end, Poincare::Context * context) const = 0;
37  virtual void tidy();
38 private:
39  constexpr static size_t k_dataLengthInBytes = (TextField::maxBufferSize()+2)*sizeof(char)+2;
40  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
41  template<typename T> T templatedApproximateAtAbscissa(T x, Poincare::Context * context) const;
42  virtual char symbol() const = 0;
43  mutable Poincare::Expression * m_expression;
44  char m_text[TextField::maxBufferSize()];
45  const char * m_name;
46  KDColor m_color;
47  Poincare::ExpressionLayout * m_layout;
48  bool m_active;
49 };
50 
51 }
52 
53 #endif
virtual void setContent(const char *c)
Definition: function.cpp:37
void setColor(KDColor m_color)
Definition: function.cpp:49
static constexpr int maxBufferSize()
Definition: text_field.h:23
virtual void tidy()
Definition: function.cpp:115
const char * text() const
Definition: function.cpp:64
#define T(x)
Definition: events.cpp:26
KDColor color() const
Definition: function.h:21
virtual double sumBetweenBounds(double start, double end, Poincare::Context *context) const =0
virtual double evaluateAtAbscissa(double x, Poincare::Context *context) const
Definition: function.h:33
virtual bool isEmpty()
Definition: function.cpp:102
Poincare::Expression * expression(Poincare::Context *context) const
Definition: function.cpp:72
c(generic_all_nodes)
void setActive(bool active)
Definition: function.cpp:98
virtual uint32_t checksum()
Definition: function.cpp:29
unsigned int uint32_t
Definition: stdint.h:6
const char * name() const
Definition: function.cpp:68
constexpr KDColor KDColorBlack
Definition: color.h:41
Poincare::ExpressionLayout * layout()
Definition: function.cpp:79
virtual bool isDefined()
Definition: function.cpp:90
void start()
Definition: rt0.cpp:31
Function(const char *name=nullptr, KDColor color=KDColorBlack)
Definition: function.cpp:10
Definition: color.h:6
virtual float evaluateAtAbscissa(float x, Poincare::Context *context) const
Definition: function.h:30
Function & operator=(const Function &other)
Definition: function.cpp:20
virtual ~Function()
Definition: function.cpp:53