Blame view

epsilon-master/apps/apps_container_storage.cpp 1.06 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
  #include "apps_container_storage.h"
  
  #ifndef APPS_CONTAINER_SNAPSHOT_CONSTRUCTORS
  #error Missing snapshot constructors
  #endif
  
  #ifndef APPS_CONTAINER_SNAPSHOT_LIST
  #error Missing snapshot list
  #endif
  
  #ifndef APPS_CONTAINER_SNAPSHOT_COUNT
  #error Missing snapshot count
  #endif
  
  constexpr int k_numberOfCommonApps = 1+APPS_CONTAINER_SNAPSHOT_COUNT; // Take the Home app into account
  
  AppsContainerStorage * AppsContainerStorage::sharedContainer() {
    static AppsContainerStorage appsContainerStorage;
    return &appsContainerStorage;
  }
  
  AppsContainerStorage::AppsContainerStorage() :
    AppsContainer()
    APPS_CONTAINER_SNAPSHOT_CONSTRUCTORS
  {
  }
  
  int AppsContainerStorage::numberOfApps() {
    return k_numberOfCommonApps;
  }
  
  App::Snapshot * AppsContainerStorage::appSnapshotAtIndex(int index) {
    if (index < 0) {
      return nullptr;
    }
    App::Snapshot * snapshots[] = {
      homeAppSnapshot()
      APPS_CONTAINER_SNAPSHOT_LIST
    };
    assert(sizeof(snapshots)/sizeof(snapshots[0]) == k_numberOfCommonApps);
    assert(index >= 0 && index < k_numberOfCommonApps);
    return snapshots[index];
  }