Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

PropertyMgr.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiKernel/GaudiKernel/PropertyMgr.h,v 1.1.1.1 2001/04/18 18:14:18 tlindner Exp $
00002 #ifndef GAUDIKERNEL_PROPERTYMGR_H
00003 #define GAUDIKERNEL_PROPERTYMGR_H
00004 
00005 // Include files
00006 #include "GaudiKernel/Property.h"
00007 #include "GaudiKernel/IProperty.h"
00008 
00009 #include <iostream>
00010 #include <vector>
00011 
00020 class PropertyMgr : virtual public IProperty { 
00021 public:
00023         PropertyMgr();
00024         virtual ~PropertyMgr();
00025 
00027   template< class ValueType >
00028   void declareProperty( const std::string& name, ValueType& referencedVariable ) {
00029     PropertyRef* p = new SimplePropertyRef< ValueType > ( name, referencedVariable );
00030     m_properties.push_back( p );
00031     m_isOwned.push_back( true );
00032   }
00033         
00034 // VILE HACK - CTDay. Macro to deal with the lack of partial
00035 //   template specialization in compilers; must use
00036 //   complete specialization to obtain better template
00037 //   match than that provided by generic template above.
00038 //   Conversion from SimpleProperty to Property is NOT
00039 //   allowed when doing overload resolution of templated
00040 //   functions with deduced template parameters, as here.
00041 //   Also, the need for specializations to be in scope means
00042 //   that every client must bear this burden.
00043 
00044 #undef  TEMPLATESPECIAL
00045 #undef  TEMPLATETYPE
00046 #undef  DECLARESIMPLEPROPERTY
00047 #ifdef sun
00048   #define TEMPLATESPECIAL // template<>
00049   #define TEMPLATETYPE(TYPENAME) <TYPENAME##Property>
00050 #else
00051   #if defined (__GNUC__) && ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95 )
00052     #define TEMPLATESPECIAL // template<>
00053   #else
00054     #define TEMPLATESPECIAL template<>
00055   #endif
00056   #define TEMPLATETYPE(TYPENAME)
00057 #endif
00058 #define DECLARESIMPLEPROPERTY(TYPENAME) \
00059     TEMPLATESPECIAL \
00060     void declareProperty TEMPLATETYPE(TYPENAME)( const std::string& name, TYPENAME##Property& p ) { \
00061         p.setName ( name ); \
00062         m_properties.push_back( &p ); \
00063         m_isOwned.push_back( false ); \
00064     }
00065 
00066     DECLARESIMPLEPROPERTY(Boolean)
00067     DECLARESIMPLEPROPERTY(Char)
00068     DECLARESIMPLEPROPERTY(SignedChar)
00069     DECLARESIMPLEPROPERTY(UnsignedChar)
00070     DECLARESIMPLEPROPERTY(Short)
00071     DECLARESIMPLEPROPERTY(UnsignedShort)
00072     DECLARESIMPLEPROPERTY(Integer)
00073     DECLARESIMPLEPROPERTY(UnsignedInteger)
00074     DECLARESIMPLEPROPERTY(Long)
00075     DECLARESIMPLEPROPERTY(UnsignedLong)
00076     DECLARESIMPLEPROPERTY(Float)
00077     DECLARESIMPLEPROPERTY(Double)
00078     DECLARESIMPLEPROPERTY(LongDouble)
00079     DECLARESIMPLEPROPERTY(String)
00080 
00081     DECLARESIMPLEPROPERTY(BooleanArray)
00082     DECLARESIMPLEPROPERTY(CharArray)
00083     DECLARESIMPLEPROPERTY(SignedCharArray)
00084     DECLARESIMPLEPROPERTY(UnsignedCharArray)
00085     DECLARESIMPLEPROPERTY(ShortArray)
00086     DECLARESIMPLEPROPERTY(UnsignedShortArray)
00087     DECLARESIMPLEPROPERTY(IntegerArray)
00088     DECLARESIMPLEPROPERTY(UnsignedIntegerArray)
00089     DECLARESIMPLEPROPERTY(LongArray)
00090     DECLARESIMPLEPROPERTY(UnsignedLongArray)
00091     DECLARESIMPLEPROPERTY(FloatArray)
00092     DECLARESIMPLEPROPERTY(DoubleArray)
00093     DECLARESIMPLEPROPERTY(LongDoubleArray)
00094     DECLARESIMPLEPROPERTY(StringArray)
00095 #undef DECLARESIMPLEPROPERTY
00096         
00097         // IProperty implementation
00098         StatusCode setProperty(const Property& p);
00099     StatusCode setProperty( std::istream& s );
00100     StatusCode setProperty( const std::string& n, const std::string& v);
00101         StatusCode getProperty(Property* p) const;
00102     const Property& getProperty( const std::string& name) const;
00103     StatusCode getProperty( const std::string& n, std::string& v ) const;
00104     const std::vector<Property*>& getProperties( ) const;
00105 
00106         // IInterface implementation
00107         StatusCode queryInterface(const IID& riid, void** ppvInterface);
00108         unsigned long addRef();
00109         unsigned long release();
00110 
00111 private:
00112   typedef std::vector< PropertyRef* > PropertyCollectionType;
00113   PropertyCollectionType    m_properties;
00114   std::vector<bool>         m_isOwned;
00115 };
00116 
00117 #endif // JOBOPTIONSSVC_PROPERTYMGR_H
00118 

Generated at Wed Nov 21 12:22:05 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000