CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Fireworks/Core/src/FWItemSingleAccessor.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWItemSingleAccessor
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Sat Oct 18 11:36:44 EDT 2008
00011 // $Id: FWItemSingleAccessor.cc,v 1.5 2010/07/23 16:02:54 eulisse Exp $
00012 //
00013 
00014 // system include files
00015 #include <assert.h>
00016 #include "Reflex/Object.h"
00017 
00018 // user include files
00019 #include "Fireworks/Core/src/FWItemSingleAccessor.h"
00020 
00021 
00022 //
00023 // constants, enums and typedefs
00024 //
00025 
00026 //
00027 // static data member definitions
00028 //
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 FWItemSingleAccessor::FWItemSingleAccessor(const TClass* iClass) :
00034    m_type(iClass), m_data(0)
00035 {
00036 }
00037 
00038 // FWItemSingleAccessor::FWItemSingleAccessor(const FWItemSingleAccessor& rhs)
00039 // {
00040 //    // do actual copying here;
00041 // }
00042 
00043 FWItemSingleAccessor::~FWItemSingleAccessor()
00044 {
00045 }
00046 
00047 //
00048 // assignment operators
00049 //
00050 // const FWItemSingleAccessor& FWItemSingleAccessor::operator=(const FWItemSingleAccessor& rhs)
00051 // {
00052 //   //An exception safe implementation is
00053 //   FWItemSingleAccessor temp(rhs);
00054 //   swap(rhs);
00055 //
00056 //   return *this;
00057 // }
00058 
00059 //
00060 // member functions
00061 //
00062 void
00063 FWItemSingleAccessor::setData(const ROOT::Reflex::Object& product)
00064 {
00065    if (product.Address() == 0)
00066    {
00067       reset();
00068       return;
00069    }
00070    
00071    using ROOT::Reflex::Object;
00072    
00073    if(product.TypeOf().IsTypedef())
00074       m_data = Object(product.TypeOf().ToType(), product.Address()).Address();
00075    else
00076       m_data = product.Address();
00077    assert(0!=m_data);
00078 }
00079 
00080 void
00081 FWItemSingleAccessor::reset()
00082 {
00083    m_data = 0;
00084 }
00085 
00086 //
00087 // const member functions
00088 //
00089 const void*
00090 FWItemSingleAccessor::modelData(int iIndex) const
00091 {
00092    if(0==iIndex) {
00093       return m_data;
00094    }
00095    return 0;
00096 }
00097 
00098 const void*
00099 FWItemSingleAccessor::data() const
00100 {
00101    return m_data;
00102 }
00103 
00104 unsigned int
00105 FWItemSingleAccessor::size() const
00106 {
00107    return 0 == m_data ? 0 : 1;
00108 }
00109 
00110 const TClass*
00111 FWItemSingleAccessor::modelType() const
00112 {
00113    return m_type;
00114 }
00115 
00116 const TClass*
00117 FWItemSingleAccessor::type() const
00118 {
00119    return m_type;
00120 }
00121 
00122 bool
00123 FWItemSingleAccessor::isCollection() const
00124 {
00125    return false;
00126 }
00127 
00128 //
00129 // static member functions
00130 //