Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pimpl_ptr.hh

Go to the documentation of this file.
00001 // $Id: pimpl_ptr.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2010
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_senf_Utils_pimpl_ptr_
00027 #define HH_SENF_senf_Utils_pimpl_ptr_ 1
00028 
00029 // Custom includes
00030 #include <algorithm>
00031 #include <boost/ptr_container/clone_allocator.hpp>
00032 
00033 //#include "pimpl_ptr.mpp"
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 namespace senf
00037 {
00038 
00039     template<typename T, class CloneAllocator=boost::heap_clone_allocator>
00040     class pimpl_ptr
00041     {
00042         typedef void (*Deleter)(T* p);
00043         typedef T* (*Copier)(const T* p);
00044 
00045     public:
00046         explicit pimpl_ptr(T* pointee);
00047         pimpl_ptr(const pimpl_ptr & rhs);
00048         ~pimpl_ptr() throw();
00049 
00050         const T* get() const throw();
00051         T* get() throw();
00052 
00053         const T* operator->() const throw();
00054         T* operator->() throw();
00055 
00056         const T& operator*() const throw();
00057         T& operator*() throw();
00058 
00059         void swap(pimpl_ptr& with) throw();
00060 
00061         pimpl_ptr & operator=(const pimpl_ptr & rhs);
00062 
00063     private:
00064         static Copier doCopy_;
00065         static Deleter doDelete_;
00066         T* p;
00067 
00068         static void myDeleteFn(T* p);
00069         static T* myCopyFn(const T* p);
00070     };
00071 
00072 }
00073 
00074 namespace std
00075 {
00076     template<class T, class CloneAllocator>
00077     void swap(senf::pimpl_ptr<T,CloneAllocator>& lhs, senf::pimpl_ptr<T,CloneAllocator>& rhs)
00078         throw();
00079 }
00080 
00081 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00082 //#include "pimpl_ptr.cci"
00083 //#include "pimpl_ptr.ct"
00084 #include "pimpl_ptr.cti"
00085 #endif
00086 
00087 
00088 // Local Variables:
00089 // mode: c++
00090 // fill-column: 100
00091 // comment-column: 40
00092 // c-file-style: "senf"
00093 // indent-tabs-mode: nil
00094 // ispell-local-dictionary: "american"
00095 // compile-command: "scons -u test"
00096 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research