Initial commit. FBReader 0.8.12
[lbook_fbreader.git] / fbreader / src / bookmodel / BookModel.h
blob82fea745cc85c88bcd522db55606a8d624a1450d
1 /*
2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #ifndef __BOOKMODEL_H__
21 #define __BOOKMODEL_H__
23 #include <map>
24 #include <string>
26 #include <ZLTextModel.h>
27 #include <ZLTextParagraph.h>
28 #include "../description/BookDescription.h"
30 class ZLImage;
32 class ContentsModel : public ZLTextTreeModel {
34 public:
35 void setReference(const ZLTextTreeParagraph *paragraph, int reference);
36 int reference(const ZLTextTreeParagraph *paragraph) const;
38 private:
39 std::map<const ZLTextTreeParagraph*,int> myReferenceByParagraph;
42 class BookModel {
44 public:
45 struct Label {
46 Label(shared_ptr<ZLTextModel> model, int paragraphNumber) : Model(model), ParagraphNumber(paragraphNumber) {}
48 const shared_ptr<ZLTextModel> Model;
49 const int ParagraphNumber;
52 public:
53 BookModel(const BookDescriptionPtr description);
54 ~BookModel();
56 const std::string &fileName() const;
58 shared_ptr<ZLTextModel> bookTextModel() const;
59 shared_ptr<ZLTextModel> contentsModel() const;
61 const ZLImageMap &imageMap() const;
62 Label label(const std::string &id) const;
64 const BookDescriptionPtr description() const;
66 private:
67 const BookDescriptionPtr myDescription;
68 shared_ptr<ZLTextModel> myBookTextModel;
69 shared_ptr<ZLTextModel> myContentsModel;
70 ZLImageMap myImages;
71 std::map<std::string,shared_ptr<ZLTextModel> > myFootnotes;
72 std::map<std::string,Label> myInternalHyperlinks;
74 friend class BookReader;
77 inline shared_ptr<ZLTextModel> BookModel::bookTextModel() const { return myBookTextModel; }
78 inline shared_ptr<ZLTextModel> BookModel::contentsModel() const { return myContentsModel; }
79 inline const ZLImageMap &BookModel::imageMap() const { return myImages; }
80 inline const BookDescriptionPtr BookModel::description() const { return myDescription; }
82 #endif /* __BOOKMODEL_H__ */