| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# PropertyCallbackFunctor.h

Go to the documentation of this file.

    00001 /**********************************************************
    00002  * $Workfile: $
    00003  * $Revision: 1.2 $
    00004  * $Date: 2006/06/06 16:16:23 $
    00005  * $Author: hmd $
    00006  * $Archive: $
    00007  *
    00008  * Component Comment
    00009  * Copyright Notice
    00010  **********************************************************/
    00011
    00012 #ifndef INCLUDED_PROPERTYCALLBACKFUNCTOR_H
    00013 #define INCLUDED_PROPERTYCALLBACKFUNCTOR_H
    00014
    00015 #include "GaudiKernel/Kernel.h"
    00016
    00017 /****************************
    00018  * C++ DECLARATION SECTION
    00019  *   Base Classes Sub-section
    00020  ****************************/
    00021
    00022 /* Standard C++ Class Headers */
    00023
    00024 /* Application C++ Class Headers */
    00025
    00026 /*************************************
    00027  * C++ DECLARATION SECTION
    00028  *   Collaborating Classes Sub-section
    00029  *************************************/
    00030
    00031 /* Standard C++ Class Declarations */
    00032
    00033 /* Application C++ Class Declarations */
    00034 class Property;
    00035
    00036
    00037 /*******************************
    00038  * CLASS DECLARATION SECTION
    00039  *   Class Interface Sub-section
    00040  *******************************/
    00041
    00042 class GAUDI_API PropertyCallbackFunctor {
    00043
    00045 /* Static Members */
    00047
    00048 public:
    00049 // Data and Function Members for Collaborators.
    00050     // Data members
    00051     static const PropertyCallbackFunctor* const nullPropertyCallbackFunctorPointer;
    00053 /* Instance Members */
    00055
    00056 public:
    00057
    00058   // Data and Function Members for Collaborators.
    00059
    00060   // Constructors - None, abstract base class
    00061   // Destructor
    00062   virtual ~PropertyCallbackFunctor() {}
    00063
    00064   // Operators
    00065   virtual void operator() ( Property& ) const = 0;
    00066
    00067   virtual PropertyCallbackFunctor* clone() const = 0 ;
    00068
    00069 };
    00070
    00071 class PropertyCallbackPointerFunctor : public PropertyCallbackFunctor {
    00072
    00074 /* Static Members */
    00076
    00077 public:
    00078 // Data and Function Members for Collaborators.
    00079
    00080     // Typedefs, consts, and enums
    00081     typedef void ( * PtrToCallbackFunction ) ( Property& );
    00082
    00084 /* Instance Members */
    00086
    00087 public:
    00088   // Data and Function Members for Collaborators.
    00089
    00090   // Constructors
    00091   explicit PropertyCallbackPointerFunctor( PtrToCallbackFunction pCF )
    00092     : m_pCF( pCF ) { }
    00093   // Destructor - Compiler generated version will be Ok
    00094
    00095   // Operators
    00096   virtual void operator() ( Property& prop ) const
    00097   { m_pCF( prop ); }
    00098
    00099   virtual PropertyCallbackPointerFunctor* clone() const
    00100   { return new PropertyCallbackPointerFunctor(*this); } ;
    00101
    00102 private:
    00103 // Data and Function Members for This Class Implementation.
    00104
    00105     // Data members
    00106     PtrToCallbackFunction       m_pCF;
    00107
    00108 };
    00109
    00110
    00111 template< class T >
    00112 class PropertyCallbackMemberFunctor : public PropertyCallbackFunctor {
    00113
    00115 /* Static Members */
    00117
    00118 public:
    00119 // Data and Function Members for Collaborators.
    00120
    00121     // Typedefs, consts, and enums
    00122     typedef void ( T::* PtrToCallbackMember ) ( Property& );
    00123
    00125 /* Instance Members */
    00127
    00128 public:
    00129   // Data and Function Members for Collaborators.
    00130
    00131   // Constructors
    00132   explicit PropertyCallbackMemberFunctor( PtrToCallbackMember pCM, T* instance )
    00133     : m_pCM( pCM ), m_instance( instance ) { }
    00134   // Destructor - Compiler generated version will be Ok
    00135
    00136   // Operators
    00137   virtual void operator() ( Property& prop ) const
    00138   { ( m_instance->*m_pCM )( prop ); }
    00139
    00140   virtual  PropertyCallbackMemberFunctor* clone() const
    00141   { return new PropertyCallbackMemberFunctor(*this); }
    00142
    00143 private:
    00144 // Data and Function Members for This Class Implementation.
    00145
    00146     // Data members
    00147     PtrToCallbackMember m_pCM;
    00148     T*                  m_instance;
    00149
    00150 };
    00151
    00152 #endif  // INCLUDED_PROPERTYCALLBACKFUNCTOR_H