text: /**
    ******************************************************************************
    * This file is part of the TouchGFX 4.10.0 distribution.
    *
    * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
    * All rights reserved.</center></h2>
    *
    * This software component is licensed by ST under Ultimate Liberty license
    * SLA0044, the "License"; You may not use this file except in compliance with
    * the License. You may obtain a copy of the License at:
    *                             www.st.com/SLA0044
    *
    ******************************************************************************
    */
    
  
  #ifndef FRONTENDHEAP_HPP
  #define FRONTENDHEAP_HPP
  
  #include <common/Meta.hpp>
  #include <common/Partition.hpp>
  #include <mvp/MVPHeap.hpp>
  #include <touchgfx/transitions/NoTransition.hpp>
  #include <touchgfx/transitions/SlideTransition.hpp>
  #include <gui/common/FrontendApplication.hpp>
  #include <gui/model/Model.hpp>
  #include <gui/main_menu_screen/MainMenuAnimatingButtonsView.hpp>
  #include <gui/main_menu_screen/MainMenuPresenter.hpp>
  #include <gui/product_presenter_screen/ProductPresenterView.hpp>
  #include <gui/product_presenter_screen/ProductPresenterPresenter.hpp>
  #include <gui/game2D_screen/Game2DView.hpp>
  #include <gui/game2D_screen/Game2DPresenter.hpp>
  #include <gui/custom_controls_screen/CustomControlsView.hpp>
  #include <gui/custom_controls_screen/CustomControlsPresenter.hpp>
  #include <gui/graph_screen/GraphView.hpp>
  #include <gui/graph_screen/GraphPresenter.hpp>
  
  /**
   * This class provides the memory that shall be used for memory allocations
   * in the frontend. A single instance of the FrontendHeap is allocated once (in heap
   * memory), and all other frontend objects such as views, presenters and data model are
   * allocated within the scope of this FrontendHeap. As such, the RAM usage of the entire
   * user interface is sizeof(FrontendHeap).
   *
   * @note The FrontendHeap reserves memory for the most memory-consuming presenter and
   * view only. The largest of these classes are determined at compile-time using template
   * magic. As such, it is important to add all presenters, views and transitions to the
   * type lists in this class.
   *
   */
  class FrontendHeap : public MVPHeap
  {
  public:
      /**
       * A list of all view types. Must end with meta::Nil.
       * @note All view types used in the application MUST be added to this list!
       */
      typedef meta::TypeList< 
                              MainMenuAnimatingButtonsView,
                              meta::TypeList<ProductPresenterView,
                              meta::TypeList<Game2DView,
                              meta::TypeList<CustomControlsView,
                              meta::TypeList<GraphView,
                              meta::Nil
                              > > > > > ViewTypes;
  
      /**
       * Determine (compile time) the View type of largest size.
       */
      typedef meta::select_type_maxsize< ViewTypes >::type MaxViewType;
  
      /**
       * A list of all presenter types. Must end with meta::Nil.
       * @note All presenter types used in the application MUST be added to this list!
       */
      typedef meta::TypeList< MainMenuPresenter,
                              meta::TypeList<ProductPresenterPresenter,
                              meta::TypeList<Game2DPresenter,
                              meta::TypeList<CustomControlsPresenter,
                              meta::TypeList<GraphPresenter,
                              meta::Nil
                              > > > > > PresenterTypes;
  
      /**
       * Determine (compile time) the Presenter type of largest size.
       */
      typedef meta::select_type_maxsize< PresenterTypes >::type MaxPresenterType;
  
      /**
       * A list of all transition types. Must end with meta::Nil.
       * @note All transition types used in the application MUST be added to this list!
       */
      typedef meta::TypeList< NoTransition,
                              meta::Nil
                              > TransitionTypes;
  
      /**
       * Determine (compile time) the Transition type of largest size.
       */
      typedef meta::select_type_maxsize< TransitionTypes >::type MaxTransitionType;
  
      static FrontendHeap& getInstance()
      {
          static FrontendHeap instance;
          return instance;
      }
  
      Partition< PresenterTypes, 1 > presenters;
      Partition< ViewTypes, 1 > views;
      Partition< TransitionTypes, 1 > transitions;
      FrontendApplication app;
      Model model;
  private:
      FrontendHeap()
          : MVPHeap(presenters, views, transitions, app),
            presenters(),
            views(),
            transitions(),
            app(model, *this)
          {
              // Goto start screen
              app.gotoMainMenuAnimatingButtonsScreen();
              //app.gotoProductPresenterScreen();
              //app.gotoGame2048Screen();
              //app.gotoGame2DScreen();
              //app.gotoCustomControlsScreen();
              //app.gotoGraphScreen();
          }
  };
  
  #endif
  