Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50972 - sandbox/thread_safe_signals/trunk/libs/signals2/example
From: fmhess_at_[hidden]
Date: 2009-02-02 14:48:14


Author: fmhess
Date: 2009-02-02 14:48:14 EST (Mon, 02 Feb 2009)
New Revision: 50972
URL: http://svn.boost.org/trac/boost/changeset/50972

Log:
Got rid of View base class.

Text files modified:
   sandbox/thread_safe_signals/trunk/libs/signals2/example/doc_view.cpp | 46 ++++++++++++++++++---------------------
   1 files changed, 21 insertions(+), 25 deletions(-)

Modified: sandbox/thread_safe_signals/trunk/libs/signals2/example/doc_view.cpp
==============================================================================
--- sandbox/thread_safe_signals/trunk/libs/signals2/example/doc_view.cpp (original)
+++ sandbox/thread_safe_signals/trunk/libs/signals2/example/doc_view.cpp 2009-02-02 14:48:14 EST (Mon, 02 Feb 2009)
@@ -1,5 +1,6 @@
 // Document/View sample for Boost.Signals
 // Copyright Keith MacDonald 2005.
+// Copyright Frank Mori Hess 2009.
 //
 // Use, modification and
 // distribution is subject to the Boost Software License, Version
@@ -44,50 +45,42 @@
     std::string m_text;
 };
 
-class View
+class TextView
 {
 public:
- View(Document& m)
- : m_document(m)
+ TextView(Document& doc): m_document(doc)
     {
- m_connection = m_document.connect(boost::bind(&View::refresh, this));
+ m_connection = m_document.connect(boost::bind(&TextView::refresh, this));
     }
 
- virtual ~View()
+ ~TextView()
     {
         m_connection.disconnect();
     }
 
- virtual void refresh() const = 0;
-
-protected:
- Document& m_document;
-
+ void refresh() const
+ {
+ std::cout << "TextView: " << m_document.getText() << std::endl;
+ }
 private:
+ Document& m_document;
     boost::signals2::connection m_connection;
 };
 
-class TextView : public View
+class HexView
 {
 public:
- TextView(Document& doc)
- : View(doc)
- {}
-
- virtual void refresh() const
+ HexView(Document& doc): m_document(doc)
     {
- std::cout << "TextView: " << m_document.getText() << std::endl;
+ m_connection = m_document.connect(boost::bind(&HexView::refresh, this));
     }
-};
 
-class HexView : public View
-{
-public:
- HexView(Document& doc)
- : View(doc)
- {}
+ ~HexView()
+ {
+ m_connection.disconnect();
+ }
 
- virtual void refresh() const
+ void refresh() const
     {
         const std::string& s = m_document.getText();
 
@@ -98,6 +91,9 @@
 
         std::cout << std::endl;
     }
+private:
+ Document& m_document;
+ boost::signals2::connection m_connection;
 };
 
 int main(int argc, char* argv[])


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk