bakery  2.6
View.h
Go to the documentation of this file.
1 /*
2  * Copyright 2000 Murray Cumming
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 #ifndef BAKERY_VIEW_H
20 #define BAKERY_VIEW_H
21 
22 #include "ViewBase.h"
23 #include "../Document/Document.h"
24 #include <sigc++/sigc++.h>
25 
26 namespace Bakery
27 {
28 
32 template< class T_Document >
33 class View : public ViewBase
34 {
35 public:
36  View()
37  : m_pDocument(0)
38  {
39  }
40 
41  virtual ~View()
42  {
43  }
44 
46 
47  //typedef typename T_Document type_document;
48 
49  virtual T_Document* get_document()
50  {
51  return m_pDocument;
52  }
53 
54  virtual const T_Document* get_document() const
55  {
56  return m_pDocument;
57  }
58 
59  virtual void set_document(T_Document* pDocument)
60  {
61  m_pDocument = pDocument;
62  if(m_pDocument)
63  m_pDocument->signal_forget().connect( sigc::mem_fun(*this, &type_self::on_document_forget) );
64  }
65 
67  virtual void set_modified(bool val = true)
68  {
69  if(m_pDocument)
70  m_pDocument->set_modified(val);
71  }
72 
73 protected:
74 
76  {
77  //This should prevent some segfaults:
78  m_pDocument = 0;
79  }
80 
81  T_Document* m_pDocument;
82 };
83 
84 } //namespace
85 
86 #endif //BAKERY_VIEW_H
87