Using boost::scoped_ptr for pimpl/rep for some filters
authorAdam Dickmeiss <adam@indexdata.dk>
Sat, 29 Oct 2005 15:54:29 +0000 (15:54 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sat, 29 Oct 2005 15:54:29 +0000 (15:54 +0000)
src/filter_backend_test.cpp
src/filter_backend_test.hpp
src/filter_virt_db.cpp
src/filter_virt_db.hpp
src/filter_z3950_client.cpp
src/filter_z3950_client.hpp

index bab4687..bec5daf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_backend_test.cpp,v 1.5 2005-10-26 18:53:49 adam Exp $
+/* $Id: filter_backend_test.cpp,v 1.6 2005-10-29 15:54:29 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -41,13 +41,11 @@ namespace yp2 {
     }
 }
 
-yf::Backend_test::Backend_test() {
-    m_p = new Backend_test::Rep;
+yf::Backend_test::Backend_test() : m_p(new Backend_test::Rep) {
     m_p->m_support_named_result_sets = false;
 }
 
 yf::Backend_test::~Backend_test() {
-    delete m_p;
 }
 
 void yf::Backend_test::process(Package &package) const
index da10262..0b2b757 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_backend_test.hpp,v 1.1 2005-10-25 11:48:30 adam Exp $
+/* $Id: filter_backend_test.hpp,v 1.2 2005-10-29 15:54:29 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -9,6 +9,7 @@
 
 #include <stdexcept>
 #include <list>
+#include <boost/scoped_ptr.hpp>
 
 #include "filter.hpp"
 
@@ -21,7 +22,7 @@ namespace yp2 {
             Backend_test();
             void process(yp2::Package & package) const;
         private:
-            Rep *m_p;
+            boost::scoped_ptr<Rep> m_p;
         };
     }
 }
index 9f8fe00..2ea70c4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_virt_db.cpp,v 1.9 2005-10-26 18:53:49 adam Exp $
+/* $Id: filter_virt_db.cpp,v 1.10 2005-10-29 15:54:29 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -107,12 +107,11 @@ yf::Virt_db_session::Virt_db_session(yp2::Session &id,
 
 }
 
-yf::Virt_db::Virt_db() {
-    m_p = new Virt_db::Rep;
+yf::Virt_db::Virt_db() : m_p(new Virt_db::Rep)
+{
 }
 
 yf::Virt_db::~Virt_db() {
-    delete m_p;
 }
 
 void yf::Virt_db::Rep::release_session(Package &package)
index cd06081..9c4f41e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_virt_db.hpp,v 1.1 2005-10-24 14:33:30 adam Exp $
+/* $Id: filter_virt_db.hpp,v 1.2 2005-10-29 15:54:29 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -9,6 +9,7 @@
 
 #include <stdexcept>
 #include <list>
+#include <boost/scoped_ptr.hpp>
 
 #include "filter.hpp"
 
@@ -22,7 +23,7 @@ namespace yp2 {
             void process(yp2::Package & package) const;
             void add_map_db2vhost(std::string db, std::string vhost);
         private:
-            Rep *m_p;
+            boost::scoped_ptr<Rep> m_p;
         };
     }
 }
index 8a5c30c..95207d9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_z3950_client.cpp,v 1.5 2005-10-25 21:32:01 adam Exp $
+/* $Id: filter_z3950_client.cpp,v 1.6 2005-10-29 15:54:29 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -31,7 +31,7 @@ namespace yf = yp2::filter;
 namespace yp2 {
     namespace filter {
         class Z3950Client::Assoc : public yazpp_1::Z_Assoc{
-            friend class Pimpl;
+            friend class Rep;
         public:
             Assoc(yazpp_1::SocketManager *socket_manager,
                   yazpp_1::IPDU_Observable *PDU_Observable,
@@ -54,7 +54,7 @@ namespace yp2 {
             std::string m_host;
         };
 
-        class Z3950Client::Pimpl {
+        class Z3950Client::Rep {
         public:
             boost::mutex m_mutex;
             std::map<yp2::Session,Z3950Client::Assoc *> m_clients;
@@ -144,15 +144,14 @@ yazpp_1::IPDU_Observer *yf::Z3950Client::Assoc::sessionNotify(
 }
 
 
-yf::Z3950Client::Z3950Client() {
-    m_p = new yf::Z3950Client::Pimpl;
+yf::Z3950Client::Z3950Client() :  m_p(new yf::Z3950Client::Rep)
+{
 }
 
 yf::Z3950Client::~Z3950Client() {
-    delete m_p;
 }
 
-yf::Z3950Client::Assoc *yf::Z3950Client::Pimpl::get_assoc(Package &package) 
+yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package) 
 {
     // only one thread messes with the clients list at a time
     boost::mutex::scoped_lock lock(m_mutex);
@@ -218,7 +217,7 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Pimpl::get_assoc(Package &package)
     return as;
 }
 
-void yf::Z3950Client::Pimpl::send_and_receive(Package &package,
+void yf::Z3950Client::Rep::send_and_receive(Package &package,
                                               yf::Z3950Client::Assoc *c)
 {
     Z_GDU *gdu = package.request().get();
@@ -253,7 +252,7 @@ void yf::Z3950Client::Pimpl::send_and_receive(Package &package,
         ;
 }
 
-void yf::Z3950Client::Pimpl::release_assoc(Package &package,
+void yf::Z3950Client::Rep::release_assoc(Package &package,
                                            yf::Z3950Client::Assoc *c)
 {
     if (package.session().is_closed())
index 4a6f161..2f8fbb5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: filter_z3950_client.hpp,v 1.1 2005-10-16 16:05:44 adam Exp $
+/* $Id: filter_z3950_client.hpp,v 1.2 2005-10-29 15:54:29 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -9,20 +9,21 @@
 
 #include <stdexcept>
 #include <list>
+#include <boost/scoped_ptr.hpp>
 
 #include "filter.hpp"
 
 namespace yp2 {
     namespace filter {
         class Z3950Client : public Base {
-            class Pimpl;
+            class Rep;
             class Assoc;
         public:
             ~Z3950Client();
             Z3950Client();
             void process(yp2::Package & package) const;
         private:
-            Pimpl *m_p;
+            boost::scoped_ptr<Rep> m_p;
         };
     }
 }