FlexBook / Mbed 2 deprecated FlexBook171204a

Dependencies:   SDFileSystem app epson mbed msp430 pl tests

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers book.cpp Source File

book.cpp

00001 //
00002 // Filename: book.h
00003 //
00004 // Container for Flexbook pages.
00005 //
00006 
00007 #include "book.h"
00008 
00009 #include "log.h"
00010 #include "pagefactory.h"
00011 #include "page.h"
00012 
00013 #include <iostream>
00014 
00015 namespace Flexbook {
00016 
00017 Book::Book(PageFactory &thefactory)
00018 : factory(thefactory),
00019   pagetype(PageType_PageNull),
00020   page(nullptr)
00021 {
00022     Log("Creating Book");
00023 }
00024 
00025 Book::~Book()
00026 {
00027     Log("Deleting Book");
00028 }
00029 
00030 void Book::PageChange(PageType type)
00031 {
00032     Log("Page change");
00033     
00034     // Delete the old page.
00035     page.reset();
00036     pagetype = PageType_PageNull;
00037 
00038     // Create the new page and any of it's dependencies.
00039     page = factory.CreatePages(type);
00040     pagetype = type;
00041 }
00042 
00043 PageType Book::GetPageType() const
00044 {
00045     return pagetype;
00046 }
00047 
00048 void Book::HandleActions()
00049 {
00050     if(page.get())
00051         page->HandlePageActions();
00052 }
00053 
00054 } // End Flexbook namespace.
00055 
00056