CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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.6 2013/02/10 22:12:04 wmtan 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 edm::ObjectWithDict& product)
00058 {
00059    if (product.address() == 0)
00060    {
00061       reset();
00062       return;
00063    }
00064    
00065    m_data = product.address();
00066    assert(0!=m_data);
00067 }
00068 
00069 void
00070 FWItemRandomAccessorBase::reset()
00071 {
00072    m_data = 0;
00073 }
00074 
00075 //
00076 // const member functions
00077 //
00078 const void*
00079 FWItemRandomAccessorBase::data() const
00080 {
00081    return m_data;
00082 }
00083 
00084 void*
00085 FWItemRandomAccessorBase::getDataPtr() const
00086 {
00087    return m_data;
00088 }
00089 
00090 const TClass*
00091 FWItemRandomAccessorBase::type() const
00092 {
00093    return m_type;
00094 }
00095 
00096 const TClass*
00097 FWItemRandomAccessorBase::modelType() const
00098 {
00099    assert(m_modelType);
00100    return m_modelType; 
00101 }
00102 
00103 bool
00104 FWItemRandomAccessorBase::isCollection() const
00105 {
00106    return true;
00107 }
00108 //
00109 // static member functions
00110 //