Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Algorithm.h
Go to the documentation of this file.
1 // $Id: Algorithm.h,v 1.20 2008/10/28 10:40:19 marcocle Exp $
2 // ============================================================================
3 // ============================================================================
4 #ifndef GAUDIPYTHON_ALGORITHM_H
5 #define GAUDIPYTHON_ALGORITHM_H
6 // ============================================================================
7 // Include Files
8 // ============================================================================
9 // Python
10 // ============================================================================
11 #include "Python.h"
12 // ============================================================================
13 // GaudiKernel
14 // ============================================================================
15 #include "GaudiKernel/Algorithm.h"
16 #include "GaudiKernel/Bootstrap.h"
17 // ============================================================================
18 // GaudiPython
19 // ============================================================================
21 // ============================================================================
22 
23 namespace GaudiPython
24 {
26  GAUDI_API StatusCode call_python_method ( PyObject* self , const char* method ) ;
27 }
28 
29 namespace GaudiPython
30 {
31 
36  {
37  public:
43  ( PyObject* self ,
44  const std::string& name ) ;
45  public:
47  StatusCode start () ;
48  StatusCode beginRun () ;
49  StatusCode endRun () ;
50  StatusCode execute () ;
51  StatusCode stop () ;
52  StatusCode finalize () ;
53  IAlgorithm* myself() { return this; }
54  private:
55  PyObject* m_self;
56  };
57  // ==========================================================================
64  template <class ALGORITHM>
65  class GAUDI_API PyAlg : public ALGORITHM
66  {
67  // ========================================================================
68  public:
69  // ========================================================================
74  PyAlg
75  ( PyObject* self ,
76  const std::string& name )
77  : ALGORITHM ( name , Gaudi::svcLocator() )
78  , m_self ( self )
79  {
80  // the printout of actual type for embedded algorithm has no sense
81  this -> setProperty ( "TypePrint" , "false" ) ;
82  this -> setProperty ( "StatPrint" , "true" ) ;
83  // The owner of the Algorithm is Python (as creator) therefore
84  // it should not be deleted by Gaudi (added an extra addRef()).
85  this -> addRef() ;
86  this -> addRef() ;
87  }
88  // ========================================================================
89  protected:
90  // ========================================================================
92  virtual ~PyAlg() {} // virtual destructor
94  PyObject* _obj() const { return m_self ; } // get the object
95  // ========================================================================
96  public:
97  // ========================================================================
99  { return GaudiPython::call_python_method ( m_self , "initialize" ) ; }
100  virtual StatusCode start ()
101  { return GaudiPython::call_python_method ( m_self , "start" ) ; }
102  virtual StatusCode beginRun ()
103  { return GaudiPython::call_python_method ( m_self , "beginRun" ) ; }
104  virtual StatusCode endRun ()
105  { return GaudiPython::call_python_method ( m_self , "endRun" ) ; }
106  virtual StatusCode execute ()
107  { return GaudiPython::call_python_method ( m_self , "execute" ) ; }
108  virtual StatusCode stop ()
109  { return GaudiPython::call_python_method ( m_self , "stop" ) ; }
110  virtual StatusCode finalize ()
111  { return GaudiPython::call_python_method ( m_self , "finalize" ) ; }
112  // ========================================================================
113  virtual IAlgorithm* ialgorithm () { return this ; }
114  virtual IProperty* iproperty () { return this ; }
115  // ========================================================================
116  // preserve the existing methods
117  virtual StatusCode initialize_ () { return ALGORITHM::initialize () ; }
118  virtual StatusCode finalize_ () { return ALGORITHM::finalize () ; }
119  // ========================================================================
120  private:
121  // ========================================================================
123  PyAlg() ; // the default constructor is disabled
125  PyAlg ( const PyAlg& ); // the copy constructor is disabled
127  PyAlg& operator=( const PyAlg& ) ; // the assignment operator is disabled
128  // ========================================================================
129  private:
130  // ========================================================================
132  PyObject* m_self; // "shadow" python class
133  // ========================================================================
134  } ;
135  // ==========================================================================
136 } // end of namespace GaudiPython
137 // ============================================================================
138 // The END
139 // ============================================================================
140 #endif // GAUDIPYTHON_ALGORITHM_H
141 // ============================================================================

Generated at Wed Dec 4 2013 14:33:08 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004