Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "FWCore/Framework/interface/GenericObjectOwner.h"
00017 #include "FWCore/Framework/interface/EventPrincipal.h"
00018 #include "FWCore/Utilities/interface/WrappedClassName.h"
00019
00020 namespace edm {
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 GenericObjectOwner::~GenericObjectOwner()
00042 {
00043 if(m_ownData) {
00044 m_object.Destruct();
00045 }
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 void
00064 GenericObjectOwner::swap(GenericObjectOwner& iOther) {
00065 Reflex::Object old(m_object);
00066 m_object = iOther.m_object;
00067 iOther.m_object = m_object;
00068 }
00069
00070
00071
00072
00073 Reflex::Object
00074 GenericObjectOwner::object() const {
00075 return m_object;
00076 }
00077
00078
00079
00080
00081
00082 template <>
00083 OrphanHandle<GenericObjectOwner>
00084 Event::put<GenericObjectOwner>(std::auto_ptr<GenericObjectOwner> product, std::string const& productInstanceName)
00085 {
00086 if (product.get() == 0) {
00087 throw edm::Exception(edm::errors::NullPointerError)
00088 << "Event::put: A null auto_ptr was passed to 'put'.\n"
00089 << "The pointer is of type " << "GenericObjectOwner" << ".\n"
00090 << "The specified productInstanceName was '" << productInstanceName << "'.\n";
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 ConstBranchDescription const& desc =
00102 provRecorder_.getBranchDescription(TypeID(product->object().TypeOf().TypeInfo()), productInstanceName);
00103
00104 Reflex::Type const wrapperType=Reflex::Type::ByName(wrappedClassName(desc.fullClassName()));
00105 if(wrapperType == Reflex::Type() ) {
00106 throw edm::Exception(errors::DictionaryNotFound, "NoWrapperDictionary")
00107 << "Event::put: the class type '" << desc.fullClassName()
00108 << "' was passed to put but the Reflex dictionary for the required class '"
00109 << wrappedClassName(desc.fullClassName()) << "' could not be found./n"
00110 << "Please change the C++ package which contains the description of '" << desc.fullClassName()
00111 << "' so that the required class also has a dictionary autogenerated.";
00112 }
00113 std::vector<void*> args;
00114 args.reserve(1);
00115 args.push_back(product->object().Address());
00116
00117 std::string s("void(");
00118 s+=desc.fullClassName();
00119 s+="*)";
00120 Reflex::Type ptrT = Reflex::Type::ByName(s);
00121 Reflex::Object oWrapper(wrapperType.Construct(ptrT,args));
00122
00123 product.release();
00124
00125 static Reflex::Type s_edproductType(Reflex::Type::ByTypeInfo(typeid(EDProduct)));
00126 EDProduct *wp(reinterpret_cast<EDProduct*>(oWrapper.CastObject(s_edproductType).Address()));
00127 putProducts().push_back(std::make_pair(wp, &desc));
00128
00129
00130
00131
00132 return(OrphanHandle<GenericObjectOwner>(oWrapper.Get("obj"), eventPrincipal().branchIDToProductID(desc.branchID())));
00133 }
00134 }
00135