00001
00002
00003
00004
00005
00006
00007
00008
00009 """
00010 Helper module for decoration on LHCb::Inpector class
00011
00012 >>> import LHCbKernel.Inspector
00013
00014 >>> from GaudiPython.Bindings import gbl as cpp # get the global namespace
00015 >>> Inspector = cpp.LHCb.Inspector # get the LHCb::Inspector class
00016
00017
00018 >>> i = Inspector( [ 'InputSelection' , 'OutputSelection'] ) # create the instance
00019
00020 >>> from GaudiPython.Bindings import AppMgr
00021 >>> gaudi = AppMgr() # Application Manager
00022
00023 Inspect the certain algorithm:
00024
00025 >>> alg = gaudi.algorithm( 'AlgName') # get the algorithm
00026 >>> i << alg # use the inspector
00027
00028 Inspect the certain service:
00029
00030 >>> svc = gaudi.service ( 'SvcName' ) # get the service
00031 >>> i << svc # use the inspector
00032
00033 Inspect the tool
00034
00035 >>> tool = gaudi.tool('ToolName' ) # get the tool
00036 >>> i << tool
00037
00038 Inspect the generic component:
00039
00040
00041 >>> cmp = gaudi.property('ComponentName' ) # get the component
00042 >>> i << cmp # inspect the component
00043
00044 Inspect the whole application
00045
00046 >>> i << gaudi # inspect the application
00047
00048 """
00049
00050 __author__ = "Vanya BELYAEV Ivan.BElyaev@nikhef.nl"
00051
00052
00053 from GaudiPython.Bindings import gbl as _cpp
00054
00055 _Inspector = _cpp.LHCb.Inspector
00056
00057
00058 def _new_shift_ ( self , obj ) :
00059 """
00060 Helper function for inspection of variosu objects:
00061
00062 >>> obj = ... # get the object
00063 >>> ins << obj # inspect it uinsg the inspector
00064
00065 """
00066 iobj = None
00067 if hasattr ( obj , '_isvc' ) and obj._isvc : iobj = obj._isvc
00068 elif hasattr ( obj , '_ialg' ) and obj._ialg : iobj = obj._ialg
00069 elif hasattr ( obj , '_ip' ) and obj._ip : iobj = obj._ip
00070
00071 if not iobj :
00072 raise AttributeError, ' cannot find proper valid interface for %s'%obj
00073
00074 lines = self.inspect ( iobj ).split ('\n')
00075 for line in lines : print line
00076
00077 return self
00078
00079
00080 _new_shift_.__doc__ += '\n' + _cpp.LHCb.Inspector.inspect.__doc__
00081
00082
00083
00084 _old_init_ = _Inspector.__init__
00085
00086
00087 def _new_init_ ( self ,
00088 props ,
00089 members = ( 'Members' , 'TopAlg' ) ) :
00090 """
00091
00092 New (python-oriented) constructor:
00093
00094 >>> int = Inspector ( ['OutputLevel', 'InputSelection'] )
00095
00096
00097 """
00098 if type(props) is str : props = (props,)
00099 if type(props) is list or type(props) is tuple :
00100 _vct = _cpp.std.vector('std::string')()
00101 for p in props : _vct.push_back ( p )
00102 props = _vct
00103
00104 if type(members) is str : members = (members,)
00105 if type(members) is list or type(members) is tuple :
00106 _vct = _cpp.std.vector('std::string')()
00107 for p in members : _vct.push_back ( p )
00108 members = _vct
00109 return _old_init_ ( self , props , members )
00110
00111
00112 _new_init_.__doc__ += '\n' + _old_init_.__doc__
00113
00114 _Inspector.__init__ = _new_init_
00115 _Inspector.__lshift__ = _new_shift_
00116
00117