| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# ConversionSvc.h

Go to the documentation of this file.

    00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/ConversionSvc.h,v 1.15 2007/06/01 17:24:21 marcocle Exp $
    00002 #ifndef GAUDIKERNEL_CONVERSIONSVC_H
    00003 #define GAUDIKERNEL_CONVERSIONSVC_H 1
    00004
    00005 // Include files
    00006 #include <vector>
    00007 #include <algorithm>
    00008 #include <functional>
    00009 #include "GaudiKernel/Kernel.h"
    00010 #include "GaudiKernel/Service.h"
    00011 #include "GaudiKernel/IConversionSvc.h"
    00012 #include "GaudiKernel/IAddressCreator.h"
    00013
    00014
    00046 class ConversionSvc  : public Service,
    00047                        virtual public IConversionSvc,
    00048                        virtual public IAddressCreator
    00049 {
    00050 public:
    00051   class WorkerEntry {
    00052   private:
    00053     CLID        m_class;
    00054     IConverter* m_converter;
    00055   public:
    00056     WorkerEntry(const CLID& cl, IConverter* cnv)
    00057       : m_class(cl), m_converter(cnv)       {
    00058     }
    00059     WorkerEntry(const WorkerEntry& copy)
    00060       : m_class(copy.m_class), m_converter(copy.m_converter)    {
    00061     }
    00062     WorkerEntry& operator = (const WorkerEntry& copy)   {
    00063       m_class     = copy.m_class;
    00064       m_converter = copy.m_converter;
    00065       return *this;
    00066     }
    00067     virtual ~WorkerEntry()  {
    00068     }
    00069     IConverter*     converter()  {
    00070       return m_converter;
    00071     }
    00072     const CLID&     clID()  const {
    00073       return m_class;
    00074     }
    00075   };
    00076   typedef std::vector<WorkerEntry> Workers;
    00077
    00078   class CnvTest : public std::unary_function<WorkerEntry, bool>   {
    00079   protected:
    00080     const CLID m_test;
    00081   public:
    00082     CnvTest(const CLID& test) : m_test(test)    {
    00083     }
    00084     virtual ~CnvTest()    {
    00085     }
    00086     bool operator()( const WorkerEntry& testee )  {
    00087         return (m_test == testee.clID()) ? true : false;
    00088     }
    00089   };
    00090
    00091 public:
    00092
    00094   virtual StatusCode initialize();
    00095
    00097   virtual StatusCode finalize();
    00098
    00100   virtual long repSvcType() const;
    00101
    00103   const CLID& objType() const;
    00104
    00109   virtual StatusCode setDataProvider(IDataProviderSvc* pService);
    00110
    00114   virtual IDataProviderSvc* dataProvider()  const;
    00115
    00117   virtual StatusCode setConversionSvc(IConversionSvc* svc);
    00118
    00120   virtual IConversionSvc* conversionSvc()    const;
    00121
    00123   virtual StatusCode setAddressCreator(IAddressCreator* creator);
    00124
    00126   virtual IAddressCreator* addressCreator()   const;
    00127
    00129   virtual StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
    00130
    00132   virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00133
    00135   virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
    00136
    00138   virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00139
    00141   virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
    00142
    00144   virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
    00145
    00147   virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
    00148
    00150   virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
    00151
    00153   virtual StatusCode addConverter(const CLID& clid);
    00154
    00156   virtual StatusCode addConverter(IConverter* pConverter);
    00157
    00159   virtual StatusCode removeConverter(const CLID& clid);
    00160
    00162   virtual IConverter* converter(const CLID& wanted);
    00163
    00165   virtual StatusCode connectOutput(const std::string& outputFile,
    00166                                    const std::string& openMode);
    00167
    00169   virtual StatusCode connectOutput(const std::string& output);
    00170
    00172   virtual StatusCode commitOutput(const std::string& output, bool do_commit);
    00173
    00175   virtual StatusCode createAddress( long svc_type,
    00176                                     const CLID& clid,
    00177                                     const std::string* par,
    00178                                     const unsigned long* ip,
    00179                                     IOpaqueAddress*& refpAddress);
    00180
    00182   virtual StatusCode convertAddress( const IOpaqueAddress* pAddress,
    00183                                      std::string& refAddress);
    00184
    00186   virtual StatusCode createAddress( long svc_type,
    00187                                     const CLID& clid,
    00188                                     const std::string& refAddress,
    00189                                     IOpaqueAddress*& refpAddress);
    00190
    00192   virtual StatusCode updateServiceState(IOpaqueAddress* pAddress);
    00193
    00195   ConversionSvc(const std::string& name, ISvcLocator* svc, long type);
    00196
    00198   virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface);
    00199
    00200 protected:
    00202   virtual ~ConversionSvc();
    00203
    00205   virtual IConverter* createConverter(long typ, const CLID& clid, const ICnvFactory* fac);
    00206
    00208   virtual StatusCode configureConverter(long typ, const CLID& clid, IConverter* cnv);
    00209
    00211   virtual StatusCode initializeConverter(long typ, const CLID& clid, IConverter* cnv);
    00212
    00214   virtual StatusCode activateConverter(long typ, const CLID& clid, IConverter* cnv);
    00215
    00217   virtual void loadConverter(DataObject* pObject);
    00218
    00220   virtual IAddressCreator* addressCreator()   {
    00221     return m_addressCreator;
    00222   }
    00223
    00224 protected:
    00225   StatusCode makeCall( int typ,
    00226                        bool ignore_add,
    00227                        bool ignore_obj,
    00228                        bool update,
    00229                        IOpaqueAddress*& pAddress,
    00230                        DataObject*& pObject);
    00231
    00233   IDataProviderSvc*   m_dataSvc;
    00235   IAddressCreator*    m_addressCreator;
    00237   long                m_type;
    00239   Workers*            m_workers;
    00240 };
    00241 #endif // GAUDIKERNEL_CONVERSIONSVC_H