CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Fireworks/Core/src/FWItemRandomAccessor.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWItemRandomAccessor
00005 //
00006 // Implementation:
00007 //    A generic helper class which can be used to create
00008 //    a specialized FWItemAccessorBase plugin for
00009 //    all the classes that expose a std::vector like interface.
00010 //
00011 // Original Author:  Giulio Eulisse
00012 //         Created:  Thu Feb 18 15:19:44 EDT 2008
00013 // $Id: FWItemRandomAccessor.cc,v 1.3 2010/07/23 16:02:54 eulisse Exp $
00014 //
00015 
00016 // system include files
00017 #include <assert.h>
00018 #include "TClass.h"
00019 
00020 // user include files
00021 #include "Fireworks/Core/interface/FWItemRandomAccessor.h"
00022 
00023 // forward declarations
00024 
00025 FWItemRandomAccessorBase::FWItemRandomAccessorBase(const TClass *type, const type_info &modelTypeName)
00026 :m_type(type),
00027  m_modelType(TClass::GetClass(modelTypeName)),
00028  m_data(0)
00029 {
00030 }
00031 
00032 // FWItemRandomAccessor::FWItemRandomAccessor(const FWItemRandomAccessor& rhs)
00033 // {
00034 //    // do actual copying here;
00035 // }
00036 
00037 FWItemRandomAccessorBase::~FWItemRandomAccessorBase()
00038 {
00039 }
00040 
00041 //
00042 // assignment operators
00043 //
00044 // const FWItemRandomAccessor& FWItemRandomAccessor::operator=(const FWItemRandomAccessor& rhs)
00045 // {
00046 //   //An exception safe implementation is
00047 //   FWItemRandomAccessor temp(rhs);
00048 //   swap(rhs);
00049 //
00050 //   return *this;
00051 // }
00052 
00053 //
00054 // member functions
00055 //
00056 void
00057 FWItemRandomAccessorBase::setData(const ROOT::Reflex::Object& product)
00058 {
00059    if (product.Address() == 0)
00060    {
00061       reset();
00062       return;
00063    }
00064    
00065    using ROOT::Reflex::Object;
00066    if(product.TypeOf().IsTypedef())
00067       m_data = Object(product.TypeOf().ToType(),product.Address()).Address();
00068    else
00069       m_data = product.Address();
00070    assert(0!=m_data);
00071 }
00072 
00073 void
00074 FWItemRandomAccessorBase::reset()
00075 {
00076    m_data = 0;
00077 }
00078 
00079 //
00080 // const member functions
00081 //
00082 const void*
00083 FWItemRandomAccessorBase::data() const
00084 {
00085    return m_data;
00086 }
00087 
00088 void*
00089 FWItemRandomAccessorBase::getDataPtr() const
00090 {
00091    return m_data;
00092 }
00093 
00094 const TClass*
00095 FWItemRandomAccessorBase::type() const
00096 {
00097    return m_type;
00098 }
00099 
00100 const TClass*
00101 FWItemRandomAccessorBase::modelType() const
00102 {
00103    assert(m_modelType);
00104    return m_modelType; 
00105 }
00106 
00107 bool
00108 FWItemRandomAccessorBase::isCollection() const
00109 {
00110    return true;
00111 }
00112 //
00113 // static member functions
00114 //