Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

View.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2000 Murray Cumming
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the Free
00016  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 #ifndef BAKERY_VIEW_H
00020 #define BAKERY_VIEW_H
00021 
00022 #include "ViewBase.h"
00023 #include "../Document/Document.h"
00024 #include <sigc++/sigc++.h>
00025 
00026 namespace Bakery
00027 {
00028 
00032 template< class T_Document >
00033 class View : public ViewBase
00034 {
00035 public: 
00036   View()
00037   : m_pDocument(0)
00038   {
00039   }
00040 
00041   virtual ~View()
00042   {
00043   }
00044 
00045   typedef View<T_Document> type_self;
00046 
00047   //typedef typename T_Document type_document;
00048 
00049   virtual T_Document* get_document()
00050   {
00051     return m_pDocument;
00052   }
00053 
00054   virtual const T_Document* get_document() const
00055   {
00056     return m_pDocument;
00057   }
00058 
00059   virtual void set_document(T_Document* pDocument)
00060   {
00061     m_pDocument = pDocument;
00062     if(m_pDocument)
00063       m_pDocument->signal_forget().connect( sigc::mem_fun(*this, &type_self::on_document_forget) );
00064   }
00065 
00067   virtual void set_modified(bool val = true)
00068   {
00069     if(m_pDocument)
00070       m_pDocument->set_modified(val);
00071   }
00072 
00073 protected:
00074 
00075   void on_document_forget()
00076   {
00077     //This should prevent some segfaults:
00078     m_pDocument = 0;
00079   }
00080   
00081   T_Document* m_pDocument;
00082 };
00083 
00084 } //namespace
00085 
00086 #endif //BAKERY_VIEW_H
00087 

Generated on Tue Jan 4 19:00:08 2005 for bakery by  doxygen 1.3.9.1