| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# Property.cpp

Go to the documentation of this file.

    00001 // $Id: Property.cpp,v 1.24 2007/09/25 10:31:43 marcocle Exp $
    00002 // ============================================================================
    00003 // CVS tag $Name:  $, verison $Revision: 1.24 $
    00004 // ============================================================================
    00005 // Include files
    00006 // ============================================================================
    00007 // STD & STL
    00008 // ============================================================================
    00009 #include <iostream>
    00010 #include <stdexcept>
    00011 #include <vector>
    00012 #include <string>
    00013 #include <utility>
    00014 #include <map>
    00015 #include <algorithm>
    00016 #include <functional>
    00017 // ============================================================================
    00018 // GaudiKernel
    00019 // ============================================================================
    00020 #include "GaudiKernel/IProperty.h"
    00021 #include "GaudiKernel/SmartIF.h"
    00022 #include "GaudiKernel/Property.h"
    00023 #include "GaudiKernel/PropertyCallbackFunctor.h"
    00024 #include "GaudiKernel/GaudiHandle.h"
    00025 // ============================================================================
    00026 // Boost
    00027 // ============================================================================
    00028 #include "boost/algorithm/string/case_conv.hpp"
    00029 // ============================================================================
    00035 // ============================================================================
    00036 // The output operator for friendly printout
    00037 // ============================================================================
    00038 std::ostream& operator<<( std::ostream&   stream ,
    00039                           const Property& prop   )
    00040 { return prop.fillStream ( stream ) ; }
    00041 // ============================================================================
    00042 /*  constructor from the property name and the type
    00043  *  @param name proeprty name
    00044  *  @param type property C++/RTTI type
    00045  */
    00046 // ============================================================================
    00047 Property::Property
    00048 ( const std::type_info&  type ,
    00049   const std::string&     name )
    00050   : m_name            (  name )
    00051   , m_documentation   ( name )
    00052   , m_typeinfo        ( &type )
    00053   , m_readCallBack    (  0  )
    00054   , m_updateCallBack  (  0  )
    00055 {}
    00056 // ============================================================================
    00057 /*  constructor from the property name and the type
    00058  *  @param type property C++/RTTI type
    00059  *  @param name proeprty name
    00060  */
    00061 // ============================================================================
    00062 Property::Property
    00063 ( const std::string&     name ,
    00064   const std::type_info&  type )
    00065   : m_name            (  name )
    00066   , m_documentation   ( name )
    00067   , m_typeinfo        ( &type )
    00068   , m_readCallBack    (  0  )
    00069   , m_updateCallBack  (  0  )
    00070 {}
    00071 // ============================================================================
    00072 // copy contructor
    00073 // ============================================================================
    00074 Property::Property
    00075 ( const Property& right )
    00076   : m_name     ( right.m_name     )
    00077   , m_documentation ( right.m_documentation )
    00078   , m_typeinfo ( right.m_typeinfo )
    00079   , m_readCallBack   ( 0 )
    00080   , m_updateCallBack ( 0 )
    00081 {
    00082   if ( 0 != right.m_readCallBack   )
    00083   { m_readCallBack   = right.m_readCallBack   -> clone () ; }
    00084   if ( 0 != right.m_updateCallBack )
    00085   { m_updateCallBack = right.m_updateCallBack -> clone () ; }
    00086 }
    00087 // ============================================================================
    00088 // Assignement
    00089 // ============================================================================
    00090 Property& Property::operator=( const Property& right )
    00091 {
    00092   if ( &right == this ) { return *this ; }
    00093   //
    00094   m_name     = right.m_name ;
    00095   m_documentation = right.m_documentation ;
    00096   m_typeinfo = right.m_typeinfo ;
    00097   //
    00098   if ( 0 !=       m_readCallBack   )
    00099   { delete m_readCallBack   ; m_readCallBack   = 0 ; }
    00100   if ( 0 !=       m_updateCallBack )
    00101   { delete m_updateCallBack ; m_updateCallBack = 0 ; }
    00102   if ( 0 != right.m_readCallBack   )
    00103   { m_readCallBack   = right.m_readCallBack   -> clone () ; }
    00104   if ( 0 != right.m_updateCallBack )
    00105   { m_updateCallBack = right.m_updateCallBack -> clone () ; }
    00106   //
    00107   return *this ;
    00108 }
    00109 // ============================================================================
    00110 // virtual destructor
    00111 // ============================================================================
    00112 Property::~Property()
    00113 {
    00114   if ( 0 != m_readCallBack   )
    00115   { delete m_readCallBack    ; m_readCallBack    = 0 ; }
    00116   if ( 0 != m_updateCallBack )
    00117   { delete m_updateCallBack  ; m_updateCallBack  = 0 ; }
    00118 }
    00119 // ============================================================================
    00120 // Call-back functor at reading: the functor is ownered by property!
    00121 // ============================================================================
    00122 const PropertyCallbackFunctor* Property::readCallBack   () const
    00123 { return m_readCallBack ; }
    00124 // ============================================================================
    00125 // Call-back functor for update: the funtor is ownered by property!
    00126 // ============================================================================
    00127 const PropertyCallbackFunctor* Property::updateCallBack () const
    00128 { return m_updateCallBack ; }
    00129 // ============================================================================
    00130 // set new callback for reading
    00131 // ============================================================================
    00132 void  Property::declareReadHandler   ( PropertyCallbackFunctor* pf )
    00133 {
    00134   if ( 0 != m_readCallBack   )
    00135   { delete m_readCallBack    ; m_readCallBack    = 0 ; }
    00136   m_readCallBack = pf ;
    00137 }
    00138 // ============================================================================
    00139 // set new callback for update
    00140 // ============================================================================
    00141 void  Property::declareUpdateHandler ( PropertyCallbackFunctor* pf )
    00142 {
    00143   if ( 0 != m_updateCallBack   )
    00144   { delete m_updateCallBack    ; m_updateCallBack    = 0 ; }
    00145   m_updateCallBack = pf ;
    00146 }
    00147 // ============================================================================
    00148 // use the call-back function at reading
    00149 // ============================================================================
    00150 void Property::useReadHandler   () const
    00151 {
    00152   if ( 0 == m_readCallBack ) { return ; }               // RETURN
    00153   const Property& p = *this ;
    00154   PropertyCallbackFunctor* theCallBack = m_readCallBack;
    00155   // avoid infinite loop
    00156   m_readCallBack = 0;
    00157   (*theCallBack)( const_cast<Property&>(p) ) ;
    00158   m_readCallBack = theCallBack;
    00159 }
    00160 // ============================================================================
    00161 // use the call-back function at update
    00162 // ============================================================================
    00163 bool Property::useUpdateHandler ()
    00164 {
    00165   bool sc(true);
    00166   if ( 0 == m_updateCallBack ) { return sc; }  // RETURN
    00167   PropertyCallbackFunctor* theCallBack = m_updateCallBack;
    00168   // avoid infinite loop
    00169   m_updateCallBack = 0;
    00170   try {
    00171     (*theCallBack)( *this ) ;
    00172   } catch(...) {
    00173     sc = false;
    00174   }
    00175   m_updateCallBack = theCallBack;
    00176   return sc;
    00177 }
    00178 // ============================================================================
    00179 // the printout of the property value
    00180 // ============================================================================
    00181 std::ostream&
    00182 Property::fillStream ( std::ostream& stream ) const
    00183 { return stream << " '" <<name() << "':" << toString() ; }
    00184 // ============================================================================
    00185 /*  simple function which check the existence of the property with
    00186  *  the given name.
    00187  *
    00188  *  @code
    00189  *
    00190  *  IInterface* p = .
    00191  *
    00192  *  const bool = hasProperty( p , "Context" ) ;
    00193  *
    00194  *  @endcode
    00195  *
    00196  *  @param  p    pointer to IInterface   object (any component)
    00197  *  @param  name property name (case insensitive)
    00198  *  @return true if "p" has a property with such name
    00199  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00200  *  @date   2006-09-09
    00201  */
    00202 // ============================================================================
    00203 bool Gaudi::Utils::hasProperty
    00204 ( const IInterface*  p    ,
    00205   const std::string& name )
    00206 {
    00207   // trivial check
    00208   if ( 0 ==  p ) { return false ; }                                // RETURN
    00209   // gelegate to another method
    00210   return 0 != getProperty ( p , name ) ;
    00211 }
    00212 // ============================================================================
    00213 /*  simple function which check the existence of the property with
    00214  *  the given name.
    00215  *
    00216  *  @code
    00217  *
    00218  *  const IProperty* p = ... ;
    00219  *
    00220  *  const bool = hasProperty( p , "Context" ) ;
    00221  *
    00222  *  @endcode
    00223  *
    00224  *  @param  p    pointer to IProperty object
    00225  *  @param  name property name (case insensitive)
    00226  *  @return true if "p" has a property with such name
    00227  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00228  *  @date   2006-09-09
    00229  */
    00230 // ============================================================================
    00231 bool Gaudi::Utils::hasProperty
    00232 ( const IProperty*   p    ,
    00233   const std::string& name )
    00234 {
    00235   if ( 0 == p ) { return false ; }
    00236   // delegate the actual work to another method ;
    00237   return 0 != getProperty ( p , name ) ;
    00238 }
    00239 // ============================================================================
    00240 //
    00241 // GaudiHandleProperty implementation
    00242 //
    00243 GaudiHandleProperty::GaudiHandleProperty
    00244 ( const std::string& name, GaudiHandleBase& ref )
    00245   : Property( name, typeid( GaudiHandleBase ) ), m_pValue( &ref )
    00246 {
    00247   m_pValue->setPropertyName( name );
    00248 }
    00249
    00250 bool GaudiHandleProperty::setValue( const GaudiHandleBase& value ) {
    00251   m_pValue->setTypeAndName( value.typeAndName() );
    00252   return useUpdateHandler();
    00253 }
    00254
    00255 std::string GaudiHandleProperty::toString( ) const {
    00256   useReadHandler();
    00257   return m_pValue->typeAndName();
    00258 }
    00259
    00260 StatusCode GaudiHandleProperty::fromString( const std::string& s) {
    00261   m_pValue->setTypeAndName( s );
    00262   return useUpdateHandler()?StatusCode::SUCCESS:StatusCode::FAILURE;
    00263 }
    00264
    00265
    00266 //
    00267 // GaudiHandlePropertyArray implementation
    00268 //
    00269 GaudiHandleArrayProperty::GaudiHandleArrayProperty( const std::string& name, GaudiHandleArrayBase& ref )
    00270   : Property( name, typeid( GaudiHandleArrayBase ) ), m_pValue( &ref )
    00271 {
    00272   m_pValue->setPropertyName( name );
    00273 }
    00274
    00275 bool GaudiHandleArrayProperty::setValue( const GaudiHandleArrayBase& value ) {
    00276   m_pValue->setTypesAndNames( value.typesAndNames() );
    00277   return useUpdateHandler();
    00278 }
    00279
    00280 std::string GaudiHandleArrayProperty::toString() const {
    00281   // treat as if a StringArrayProperty
    00282   useReadHandler();
    00283   return Gaudi::Utils::toString( m_pValue->typesAndNames() );
    00284 }
    00285
    00286 StatusCode GaudiHandleArrayProperty::fromString( const std::string& source ) {
    00287   // treat as if a StringArrayProperty
    00288   std::vector< std::string > tmp;
    00289   StatusCode sc = Gaudi::Parsers::parse ( tmp , source );
    00290   if ( sc.isFailure() ) return sc;
    00291   if ( !m_pValue->setTypesAndNames( tmp ) ) return StatusCode::FAILURE;
    00292   return useUpdateHandler()?StatusCode::SUCCESS:StatusCode::FAILURE;
    00293 }
    00294
    00295
    00296
    00297 // ============================================================================
    00298 namespace
    00299 {
    00300   // get the property by name (case insensitive)
    00301   struct _ByName_ : public std::unary_function<const Property*,bool>
    00302   {
    00304     _ByName_ ( const std::string& name )
    00305       : m_name ( boost::algorithm::to_lower_copy( name ) ) {}
    00307     bool operator () ( const Property* p ) const
    00308     {
    00309       if ( 0 == p ) { return false ; }
    00310       return m_name == boost::algorithm::to_lower_copy( p->name() ) ;
    00311     } ;
    00312   protected:
    00313     _ByName_();
    00314   private:
    00315     std::string m_name ;
    00316   } ;
    00317 }
    00318 // ============================================================================
    00319 /*  simple function which gets the property with given name
    00320  *  from the component
    00321  *
    00322  *  @code
    00323  *
    00324  *  const IProperty* p = ... ;
    00325  *
    00326  *  const Property* pro = getProperty( p , "Context" ) ;
    00327  *
    00328  *  @endcode
    00329  *
    00330  *  @param  p    pointer to IProperty object
    00331  *  @param  name property name (case insensitive)
    00332  *  @return property with the given name (if exists), NULL otherwise
    00333  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00334  *  @date   2006-09-09
    00335  */
    00336 // ============================================================================
    00337 Property* Gaudi::Utils::getProperty
    00338 ( const IProperty*   p    ,
    00339   const std::string& name )
    00340 {
    00341   // trivial check
    00342   if ( 0 == p      ) { return 0 ; }                          // RETURN
    00343   // get all properties
    00344   typedef std::vector<Property*> List ;
    00345   const List& lst = p->getProperties() ;
    00346   if ( lst.empty() ) { return 0 ; }                          // RETURN
    00347   // comparison criteria:
    00348   List::const_iterator ifound =
    00349     std::find_if ( lst.begin() , lst.end() , _ByName_( name ) ) ;
    00350   if ( lst.end() == ifound ) { return 0 ; }                  // RETURN
    00351   // OK
    00352   return *ifound ;
    00353 }
    00354 // ============================================================================
    00355 /*  simple function which gets the property with given name
    00356  *  from the component
    00357  *
    00358  *  @code
    00359  *
    00360  *  const IInterface* p = ... ;
    00361  *
    00362  *  const Property* pro = getProperty( p , "Context" ) ;
    00363  *
    00364  *  @endcode
    00365  *
    00366  *  @param  p    pointer to IInterface object
    00367  *  @param  name property name (case insensitive)
    00368  *  @return property with the given name (if exists), NULL otherwise
    00369  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00370  *  @date   2006-09-09
    00371  */
    00372 // ============================================================================
    00373 Property* Gaudi::Utils::getProperty
    00374 ( const IInterface*   p , const std::string& name )
    00375 {
    00376   // trivial check
    00377   if ( 0 ==  p        ) { return 0 ; }                                // RETURN
    00378   // remove const-qualifier
    00379   IInterface* _i = const_cast<IInterface*>( p ) ;
    00380   if ( 0 == _i        ) { return 0 ; }                                // RETURN
    00381   SmartIF<IProperty> property ( _i ) ;
    00382   if ( !property      ) { return 0 ; }                                // RETURN
    00383   return getProperty ( property , name ) ;
    00384 }
    00385 // ============================================================================
    00386 /*  check  the property by name from  the list of the properties
    00387  *
    00388  *  @code
    00389  *
    00390  *   IJobOptionsSvc* svc = ... ;
    00391  *
    00392  *   const std::string client = ... ;
    00393  *
    00394  *  // get the property:
    00395  *  bool context =
    00396  *      hasProperty ( svc->getProperties( client ) , "Context" )
    00397  *
    00398  *  @endcode
    00399  *
    00400  *  @see IJobOptionsSvc
    00401  *
    00402  *  @param  p    list of properties
    00403  *  @param  name property name (case insensitive)
    00404  *  @return true if the property exists
    00405  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00406  *  @date   2006-09-09
    00407  */
    00408 // ============================================================================
    00409 bool Gaudi::Utils::hasProperty
    00410 ( const std::vector<const Property*>* p    ,
    00411   const std::string&                  name )
    00412 {
    00413   // delegate to another method
    00414   return 0 != getProperty ( p , name ) ;
    00415 }
    00416 // ============================================================================
    00417 /*  get the property by name from  the list of the properties
    00418  *
    00419  *  @code
    00420  *
    00421  *   IJobOptionsSvc* svc = ... ;
    00422  *
    00423  *   const std::string client = ... ;
    00424  *
    00425  *  // get the property:
    00426  *  const Property* context =
    00427  *      getProperty ( svc->getProperties( client ) , "Context" )
    00428  *
    00429  *  @endcode
    00430  *
    00431  *  @see IJobOptionsSvc
    00432  *
    00433  *  @param  p    list of properties
    00434  *  @param  name property name (case insensitive)
    00435  *  @return property with the given name (if exists), NULL otherwise
    00436  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00437  *  @date   2006-09-09
    00438  */
    00439 // ============================================================================
    00440 const Property* Gaudi::Utils::getProperty
    00441 ( const std::vector<const Property*>* p    ,
    00442   const std::string&                  name )
    00443 {
    00444   // trivial check
    00445   if ( 0 == p             ) { return 0 ; }                 // RETURN
    00446   std::vector<const Property*>::const_iterator ifound =
    00447     std::find_if ( p->begin() , p->end() , _ByName_( name ) ) ;
    00448   if ( p->end() == ifound ) { return 0 ; }                 // RETURN
    00449   // OK
    00450   return *ifound ;
    00451 }
    00452 // ============================================================================
    00453 /* the full specialization of the
    00454  *  method setProperty( IProperty, std::string, const TYPE&)
    00455  *  for C-strings
    00456  *
    00457  *  @param component component which needs to be configured
    00458  *  @param name      name of the property
    00459  *  @param value     value of the property
    00460  *  @param doc       the new documentation string
    00461  *
    00462  *  @see IProperty
    00463  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00464  *  @date 2007-05-13
    00465  */
    00466 // ============================================================================
    00467 StatusCode Gaudi::Utils::setProperty
    00468 ( IProperty*         component ,
    00469   const std::string& name      ,
    00470   const char*        value     ,
    00471   const std::string& doc       )
    00472 {
    00473   const std::string val = std::string( value ) ;
    00474   return Gaudi::Utils::setProperty ( component , name , val , doc ) ;
    00475 }
    00476 // ============================================================================
    00477 /* the full specialization of the
    00478  * method Gaudi::Utils::setProperty( IProperty, std::string, const TYPE&)
    00479  * for standard strings
    00480  *
    00481  *  @param component component which needs to be configured
    00482  *  @param name      name of the property
    00483  *  @param value     value of the property
    00484  *
    00485  *  @see IProperty
    00486  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00487  *  @date 2007-05-13
    00488  */
    00489 // ============================================================================
    00490 StatusCode Gaudi::Utils::setProperty
    00491 ( IProperty*         component ,
    00492   const std::string& name      ,
    00493   const std::string& value     ,
    00494   const std::string& doc       )
    00495 {
    00496   if ( 0 == component ) { return StatusCode::FAILURE ; }   // RETURN
    00497   if ( !hasProperty ( component , name ) ) { return StatusCode::FAILURE ; }
    00498   StatusCode sc = component -> setProperty ( name , value ) ;
    00499   if ( !doc.empty() )
    00500   {
    00501     Property* p = getProperty( component , name ) ;
    00502     if ( 0 != p ) { p -> setDocumentation ( doc ) ; }
    00503   }
    00504   sc.ignore() ;
    00505   return sc ;
    00506 }
    00507 // ============================================================================
    00508 /*  simple function to set the property of the given object from another
    00509  *  property
    00510  *
    00511  *  @code
    00512  *
    00513  *  IProperty* component = ... ;
    00514  *
    00515  *  const Property* prop = ... ;
    00516  *  StatusCode sc = setProperty ( component , "Data" ,  prop  ) ;
    00517  *
    00518  *  @endcode
    00519  *
    00520  * @param component component which needs to be configured
    00521  * @param name      name of the property
    00522  * @param property  the property
    00523  * @param doc       the new documentation string
    00524  *
    00525  * @see IProperty
    00526  * @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00527  * @date 2007-05-13
    00528  */
    00529 // ============================================================================
    00530 StatusCode Gaudi::Utils::setProperty
    00531 ( IProperty*         component ,
    00532   const std::string& name      ,
    00533   const Property*    property  ,
    00534   const std::string& doc       )
    00535 {
    00536   if ( 0 == component || 0 == property   ) { return StatusCode::FAILURE ; }
    00537   if ( !hasProperty ( component , name ) ) { return StatusCode::FAILURE ; }
    00538   Property* p = getProperty ( component , name ) ;
    00539   if ( 0 == p                            ) { return StatusCode::FAILURE ; }
    00540   if ( !p->assign ( *property )          ) { return StatusCode::FAILURE ; }
    00541   if ( !doc.empty()  ) { p->setDocumentation( doc ) ; }
    00542   return StatusCode::SUCCESS ;
    00543 }
    00544 // ============================================================================
    00545 /* simple function to set the property of the given object from another
    00546  *  property
    00547  *
    00548  *  @code
    00549  *
    00550  *  IProperty* component = ... ;
    00551  *
    00552  *  const Property& prop = ... ;
    00553  *  StatusCode sc = setProperty ( component , "Data" ,  prop  ) ;
    00554  *
    00555  *  @endcode
    00556  *
    00557  * @param component component which needs to be configured
    00558  * @param name      name of the property
    00559  * @param property  the property
    00560  * @param doc       the new documentation string
    00561  *
    00562  * @see IProperty
    00563  * @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00564  * @date 2007-05-13
    00565  */
    00566 // ============================================================================
    00567 StatusCode Gaudi::Utils::setProperty
    00568 ( IProperty*         component ,
    00569   const std::string& name      ,
    00570   const Property&    property  ,
    00571   const std::string& doc       )
    00572 { return setProperty ( component , name , &property , doc ) ; }
    00573 // ============================================================================
    00574 /*  the full specialization of the
    00575  *  method setProperty( IInterface , std::string, const TYPE&)
    00576  *  for standard strings
    00577  *
    00578  *  @param component component which needs to be configured
    00579  *  @param name      name of the property
    00580  *  @param value     value of the property
    00581  *  @param doc       the new documentation string
    00582  *
    00583  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00584  *  @date 2007-05-13
    00585  */
    00586 // ============================================================================
    00587 StatusCode Gaudi::Utils::setProperty
    00588 ( IInterface*        component ,
    00589   const std::string& name      ,
    00590   const std::string& value     ,
    00591   const std::string& doc       )
    00592 {
    00593   if ( 0 == component ) { return StatusCode::FAILURE ; }
    00594   SmartIF<IProperty> property ( component ) ;
    00595   if ( !property      ) { return StatusCode::FAILURE ; }
    00596   return setProperty ( property , name , value , doc ) ;
    00597 }
    00598 // ============================================================================
    00599 /*  the full specialization of the
    00600  *  method setProperty( IInterface , std::string, const TYPE&)
    00601  *  for C-strings
    00602  *
    00603  *  @param component component which needs to be configured
    00604  *  @param name      name of the property
    00605  *  @param value     value of the property
    00606  *  @param doc       the new documentation string
    00607  *
    00608  *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00609  *  @date 2007-05-13
    00610  */
    00611 // ============================================================================
    00612 StatusCode Gaudi::Utils::setProperty
    00613 ( IInterface*        component ,
    00614   const std::string& name      ,
    00615   const char*        value     ,
    00616   const std::string& doc       )
    00617 {
    00618   const std::string val = std::string( value ) ;
    00619   return setProperty ( component , name , val , doc ) ;
    00620 }
    00621 // ============================================================================
    00622 /*  simple function to set the property of the given object from another
    00623  *  property
    00624  *
    00625  *  @code
    00626  *
    00627  *  IInterface* component = ... ;
    00628  *
    00629  *  const Property* prop = ... ;
    00630  *  StatusCode sc = setProperty ( component , "Data" ,  prop  ) ;
    00631  *
    00632  *  @endcode
    00633  *
    00634  * @param component component which needs to be configured
    00635  * @param name      name of the property
    00636  * @param property  the property
    00637  * @param doc       the new documentation string
    00638  *
    00639  * @see IProperty
    00640  * @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00641  * @date 2007-05-13
    00642  */
    00643 // ============================================================================
    00644 StatusCode Gaudi::Utils::setProperty
    00645 ( IInterface*        component ,
    00646   const std::string& name      ,
    00647   const Property*    property  ,
    00648   const std::string& doc       )
    00649 {
    00650   if ( 0 == component ) { return StatusCode::FAILURE ; }
    00651   SmartIF<IProperty> prop  ( component ) ;
    00652   if ( !prop          ) { return StatusCode::FAILURE ; }
    00653   return setProperty ( prop  , name , property , doc ) ;
    00654 }
    00655 // ============================================================================
    00656 /*  simple function to set the property of the given object from another
    00657  *  property
    00658  *
    00659  *  @code
    00660  *
    00661  *  IInterface* component = ... ;
    00662  *
    00663  *  const Property& prop = ... ;
    00664  *  StatusCode sc = setProperty ( component , "Data" ,  prop  ) ;
    00665  *
    00666  *  @endcode
    00667  *
    00668  * @param component component which needs to be configured
    00669  * @param name      name of the property
    00670  * @param property  the property
    00671  * @param doc       the new documentation string
    00672  *
    00673  * @see IProperty
    00674  * @author Vanya BELYAEV ibelyaev@physics.syr.edu
    00675  * @date 2007-05-13
    00676  */
    00677 // ============================================================================
    00678 StatusCode Gaudi::Utils::setProperty
    00679 ( IInterface*        component ,
    00680   const std::string& name      ,
    00681   const Property&    property  ,
    00682   const std::string& doc       )
    00683 { return setProperty ( component , name , &property , doc ) ; }
    00684 // ============================================================================
    00685
    00686
    00687
    00688
    00689
    00690 // ============================================================================
    00691 // The END
    00692 // ============================================================================
    00693