Blame view

build1/epsilon-master/apps/shared/expression_model.h 1.61 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  #ifndef SHARED_EXPRESSION_MODEL_H
  #define SHARED_EXPRESSION_MODEL_H
  
  #include <poincare.h>
  #include <kandinsky.h>
  #include <escher.h>
  
  namespace Shared {
  
  class ExpressionModel {
  public:
    ExpressionModel();
    virtual ~ExpressionModel(); // Delete expression and layout, if needed
    ExpressionModel& operator=(const ExpressionModel& other);
    ExpressionModel& operator=(ExpressionModel&& other) = delete;
    ExpressionModel(const ExpressionModel& other) = delete;
    ExpressionModel(ExpressionModel&& other) = delete;
    const char * text() const;
    Poincare::Expression * expression(Poincare::Context * context) const;
    Poincare::ExpressionLayout * layout();
    /* Here, isDefined is the exact contrary of isEmpty. However, for Sequence
     * inheriting from ExpressionModel, isEmpty and isDefined have not exactly
     * opposite meaning. For instance, u(n+1)=u(n) & u(0) = ... is not empty and
     * not defined. We thus have to keep both methods. */
    virtual bool isDefined();
    virtual bool isEmpty();
    virtual bool shouldBeClearedBeforeRemove() {
      return !isEmpty();
    }
    virtual void setContent(const char * c);
    virtual void tidy();
    constexpr static int k_expressionBufferSize = TextField::maxBufferSize();
  private:
    constexpr static size_t k_dataLengthInBytes = (TextField::maxBufferSize())*sizeof(char);
    static_assert((k_dataLengthInBytes & 0x3) == 0, "The expression model data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4
    char m_text[k_expressionBufferSize];
    mutable Poincare::Expression * m_expression;
    mutable Poincare::ExpressionLayout * m_layout;
  };
  
  }
  
  #endif