Blame view

build4/epsilon-master/apps/sequence/sequence_store.cpp 1.14 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
  #include "sequence_store.h"
  extern "C" {
  #include <assert.h>
  #include <stddef.h>
  }
  #include <ion.h>
  
  namespace Sequence {
  
  constexpr const char * SequenceStore::k_sequenceNames[MaxNumberOfSequences];
  
  uint32_t SequenceStore::storeChecksum() {
    size_t dataLengthInBytes = MaxNumberOfSequences*sizeof(uint32_t);
    assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
    uint32_t checksums[MaxNumberOfSequences];
    for (int i = 0; i < MaxNumberOfSequences; i++) {
      checksums[i] = m_sequences[i].checksum();
    }
    return Ion::crc32((uint32_t *)checksums, dataLengthInBytes/sizeof(uint32_t));
  }
  
  char SequenceStore::symbol() const {
    return 'n';
  }
  
  Sequence * SequenceStore::emptyModel() {
    static Sequence addedSequence("", KDColorBlack);
    addedSequence = Sequence(firstAvailableName(), firstAvailableColor());
    return &addedSequence;
  }
  
  Sequence * SequenceStore::nullModel() {
    static Sequence emptyFunction("", KDColorBlack);
    return &emptyFunction;
  }
  
  void SequenceStore::setModelAtIndex(Shared::ExpressionModel * f, int i) {
    assert(i>=0 && i<m_numberOfModels);
    m_sequences[i] = *(static_cast<Sequence *>(f));
  }
  
  }