X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2Fpimpl_ptr.hh;fp=senf%2FUtils%2Fpimpl_ptr.hh;h=43ef8fb86380b5d53e55c0a6070deeca72bdfb68;hb=7c7bdbf90e2ff5a93f6e92b3c2f3e62cba74ac24;hp=0000000000000000000000000000000000000000;hpb=aa4bfb511acb198a278caafc193ac67a9c322a13;p=senf.git diff --git a/senf/Utils/pimpl_ptr.hh b/senf/Utils/pimpl_ptr.hh new file mode 100644 index 0000000..43ef8fb --- /dev/null +++ b/senf/Utils/pimpl_ptr.hh @@ -0,0 +1,96 @@ +// $Id$ +// +// Copyright (C) 2010 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief pimpl_ptr public header */ + +#ifndef HH_SENF_senf_Utils_pimpl_ptr_ +#define HH_SENF_senf_Utils_pimpl_ptr_ 1 + +// Custom includes +#include +#include + +//#include "pimpl_ptr.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf +{ + + template + class pimpl_ptr + { + typedef void (*Deleter)(T* p); + typedef T* (*Copier)(const T* p); + + public: + explicit pimpl_ptr(T* pointee); + pimpl_ptr(const pimpl_ptr & rhs); + ~pimpl_ptr() throw(); + + const T* get() const throw(); + T* get() throw(); + + const T* operator->() const throw(); + T* operator->() throw(); + + const T& operator*() const throw(); + T& operator*() throw(); + + void swap(pimpl_ptr& with) throw(); + + pimpl_ptr & operator=(const pimpl_ptr & rhs); + + private: + static Copier doCopy_; + static Deleter doDelete_; + T* p; + + static void myDeleteFn(T* p); + static T* myCopyFn(const T* p); + }; + +} + +namespace std +{ + template + void swap(senf::pimpl_ptr& lhs, senf::pimpl_ptr& rhs) + throw(); +} + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "pimpl_ptr.cci" +//#include "pimpl_ptr.ct" +#include "pimpl_ptr.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: