callback.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.5 $
00012 
00013   License
00014    OSB rating and billing library for communication networks
00015    Copyright (C) 2004, 2005, 2006  OSB systems
00016 
00017    This file may be distributed and/or modify under the terms of the
00018    GNU General Public License (GPL) as published by the Free Software
00019    Foundation which is provided in the file LICENSE.GPL included in the
00020    packaging of this file.
00021 
00022    The file is distributed in the hope that it will be useful, but WITHOUT
00023    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025    for more details.
00026 
00027    Holders of a OSB Commercial License may use this file under the terms
00028    and conditions of this commercial license.
00029  */
00030 #ifndef _CALLBACK_H_
00031 #define _CALLBACK_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <memory>
00037 
00038 // + libraries
00039 
00040 // + local headers
00041 
00042 // + class declarations
00043 
00044 // ************************************************************************
00045 // namespace extensions
00046 namespace OSB_LIB {
00047 
00048 // ************************************************************************
00049 // forward declarations
00050 
00051 // ************************************************************************
00052 // type definitions
00053 
00054 // ************************************************************************
00055 // class definitions
00059     class CallBack {
00060     public:
00067         typedef std::auto_ptr<CallBack> AutoPtr;
00068     public:
00070         inline CallBack();
00072         inline virtual ~CallBack();
00078         inline AutoPtr clone() const;
00079     public:
00086         virtual void operator()() const = 0;
00113         template<typename T> T* isa(T*& ptr);
00115         template<typename T> const T* isa(const T*& ptr) const;
00116     protected:
00118         inline CallBack(const CallBack& rhs);
00120         inline CallBack& operator=(const CallBack& rhs);
00121     private:
00127         virtual CallBack* cloneP() const = 0;
00128     };                                  // class CallBack
00129 }                                       // namespace OSB_LIB
00130 
00131 // ************************************************************************
00132 // inline definitions
00133 namespace OSB_LIB {
00134     // ********************************************************************
00135     // class CallBack
00136     CallBack::CallBack()
00137     {
00138     }
00139 
00140     CallBack::~CallBack()
00141     {
00142     }
00143 
00144     CallBack::AutoPtr CallBack::clone() const
00145     {
00146         return AutoPtr(cloneP());
00147     }
00148 
00149     CallBack::CallBack(const CallBack&)
00150     {
00151     }
00152 
00153     CallBack& CallBack::operator=(const CallBack&)
00154     {
00155         return *this;
00156     }
00157 
00158     template<typename T>
00159     T* CallBack::isa(T*& ptr)
00160     {
00161         ptr = dynamic_cast<T*>(this);
00162         return ptr;
00163     }
00164 
00165     template<typename T>
00166     const T* CallBack::isa(const T*& ptr) const
00167     {
00168         ptr = dynamic_cast<const T*>(this);
00169         return ptr;
00170     }
00171 }                                       // namespace OSB_LIB
00172 #endif                                  // #ifndef _CALLBACK_H_

Generated on Sat Sep 2 14:06:32 2006 for OSB Library by  doxygen 1.4.7