Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

PropertyWithValue< TYPE > Class Template Reference

#include <Property.h>

Inheritance diagram for PropertyWithValue< TYPE >:

Inheritance graph
[legend]
Collaboration diagram for PropertyWithValue< TYPE >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<class TYPE>
class PropertyWithValue< TYPE >

Helper intermediate class which represent partly implemented property with value of concrete type.

Author:
Vanya BELYAEV ibelyaev@physics.syr.edu
Date:
2006-02-27

Definition at line 145 of file Property.h.


Public Member Functions

 operator const TYPE & () const
const TYPE & value () const
 get the access to the storage
virtual bool setValue (const TYPE &value)=0
virtual bool assign (const Property &source)
 get the value from another property
virtual bool load (Property &dest) const
 set value for another property
virtual StatusCode fromString (const std::string &s)
 string -> value
virtual std::string toString () const
 value -> string

Protected Member Functions

 PropertyWithValue (const std::string &name, TYPE *value, const bool owner)
 the constructor with property name and value
 PropertyWithValue (const PropertyWithValue &rhs)
 copy constructor (don't let the compiler generate a buggy one)
template<class OTHER>
 PropertyWithValue (const PropertyWithValue< OTHER > &right)
 copy constructor from any other type
virtual ~PropertyWithValue ()
 virtual destructor
PropertyWithValueoperator= (const TYPE &value)
 assignement operator
PropertyWithValueoperator= (const PropertyWithValue &rhs)
template<class OTHER>
PropertyWithValueoperator= (const PropertyWithValue< OTHER > &right)
void i_set (const TYPE &value)
TYPE * i_get () const

Private Attributes

TYPE * m_value
bool m_own

Constructor & Destructor Documentation

template<class TYPE>
PropertyWithValue< TYPE >::PropertyWithValue ( const std::string name,
TYPE *  value,
const bool  owner 
) [inline, protected]

the constructor with property name and value

Definition at line 194 of file Property.h.

00197   : Property ( typeid( TYPE ) , name )
00198   , m_value  ( value )
00199   , m_own    ( own   )
00200 {}

template<class TYPE>
PropertyWithValue< TYPE >::PropertyWithValue ( const PropertyWithValue< TYPE > &  rhs  )  [inline, protected]

copy constructor (don't let the compiler generate a buggy one)

Definition at line 206 of file Property.h.

00207   : Property( right         )
00208   , m_value ( right.m_value )
00209   , m_own   ( right.m_own   )
00210 { if ( m_own ) { m_value = new TYPE(right.value()) ; } }

template<class TYPE>
template<class OTHER>
PropertyWithValue< TYPE >::PropertyWithValue ( const PropertyWithValue< OTHER > &  right  )  [inline, protected]

copy constructor from any other type

Definition at line 217 of file Property.h.

00218   : Property( right         )
00219   , m_value ( right.m_value )
00220   , m_own   ( right.m_own   )
00221 { if ( m_own ) { m_value = new TYPE(right.value()) ; } }

template<class TYPE>
PropertyWithValue< TYPE >::~PropertyWithValue (  )  [inline, protected, virtual]

virtual destructor

Definition at line 226 of file Property.h.

00227 { if ( m_own ) { delete m_value ; } ;  m_value = 0 ; }


Member Function Documentation

template<class TYPE>
PropertyWithValue< TYPE > & PropertyWithValue< TYPE >::operator= ( const TYPE &  value  )  [inline, protected]

template<class TYPE>
PropertyWithValue< TYPE > & PropertyWithValue< TYPE >::operator= ( const PropertyWithValue< TYPE > &  rhs  )  [inline, protected]

Definition at line 321 of file Property.h.

00322 {
00323   // assign the base class
00324   Property::operator=( right ) ;
00325   // assign the value
00326   PropertyWithValue<TYPE>::operator=( right.value() ) ;
00327   return *this ;
00328 }

template<class TYPE>
template<class OTHER>
PropertyWithValue< TYPE > & PropertyWithValue< TYPE >::operator= ( const PropertyWithValue< OTHER > &  right  )  [inline, protected]

template<class TYPE>
PropertyWithValue< TYPE >::operator const TYPE & (  )  const [inline]

Definition at line 169 of file Property.h.

00169 { return value() ;}

template<class TYPE>
const TYPE & PropertyWithValue< TYPE >::value (  )  const [inline]

get the access to the storage

Definition at line 303 of file Property.h.

00304 { useReadHandler() ; return *m_value ; }

template<class TYPE>
virtual bool PropertyWithValue< TYPE >::setValue ( const TYPE &  value  )  [pure virtual]

template<class TYPE>
bool PropertyWithValue< TYPE >::assign ( const Property source  )  [inline, virtual]

get the value from another property

implementation of Property::assign

Implements Property.

Definition at line 244 of file Property.h.

00245 {
00246   // 1) Is the property of "the same" type?
00247   const PropertyWithValue<TYPE>* p =
00248     dynamic_cast<const PropertyWithValue<TYPE>*>       ( &source ) ;
00249   if ( 0 != p ) { return setValue ( p->value() ) ; }       // RETURN
00250   // 2) Else use the string representation
00251   return this->fromString( source.toString() ).isSuccess() ;
00252 }

template<class TYPE>
bool PropertyWithValue< TYPE >::load ( Property dest  )  const [inline, virtual]

set value for another property

implementation of Property::load

Implements Property.

Definition at line 258 of file Property.h.

00259 {
00260   // gelegate to the 'opposite' method ;
00261   return dest.assign( *this ) ;
00262 }

template<class TYPE>
StatusCode PropertyWithValue< TYPE >::fromString ( const std::string s  )  [inline, virtual]

string -> value

Implementation of PropertyWithValue::fromString.

Implements Property.

Definition at line 278 of file Property.h.

00279 {
00280   TYPE tmp ;
00281   StatusCode sc = Gaudi::Parsers::parse ( tmp , source ) ;
00282   if ( sc.isFailure() ) { return sc ; }
00283   return setValue ( tmp ) ? StatusCode::SUCCESS : StatusCode::FAILURE ;
00284 }

template<class TYPE>
std::string PropertyWithValue< TYPE >::toString (  )  const [inline, virtual]

value -> string

Implementation of PropertyWithValue::toString.

Implements Property.

Definition at line 268 of file Property.h.

00269 {
00270   useReadHandler();
00271   return Gaudi::Utils::toString( *m_value ) ;
00272 }

template<class TYPE>
void PropertyWithValue< TYPE >::i_set ( const TYPE &  value  )  [inline, protected]

Definition at line 310 of file Property.h.

00310 { *m_value = value ; }

template<class TYPE>
TYPE * PropertyWithValue< TYPE >::i_get (  )  const [inline, protected]

Definition at line 315 of file Property.h.

00315 { return m_value ; }


Member Data Documentation

template<class TYPE>
TYPE* PropertyWithValue< TYPE >::m_value [private]

Definition at line 186 of file Property.h.

template<class TYPE>
bool PropertyWithValue< TYPE >::m_own [private]

Definition at line 187 of file Property.h.


The documentation for this class was generated from the following file:

Generated at Mon Sep 7 18:21:52 2009 for Gaudi Framework, version v21r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004