Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace reflex #1601

Merged
merged 10 commits into from Nov 27, 2013
67 changes: 37 additions & 30 deletions DataFormats/Provenance/src/BranchDescription.cc
@@ -1,20 +1,22 @@
#include "DataFormats/Provenance/interface/BranchDescription.h"
#include "FWCore/Utilities/interface/Exception.h"

#include "DataFormats/Provenance/interface/WrapperInterfaceBase.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/FriendlyName.h"
#include "FWCore/Utilities/interface/FunctionWithDict.h"
#include "FWCore/Utilities/interface/TypeWithDict.h"
#include "FWCore/Utilities/interface/WrappedClassName.h"

#include "TClassAttributeMap.h"

#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ostream>
#include <sstream>
#include <cstdlib>

class TClass;
/*----------------------------------------------------------------------


----------------------------------------------------------------------*/

namespace edm {
BranchDescription::Transients::Transients() :
Expand Down Expand Up @@ -173,43 +175,47 @@ namespace edm {
return;
}

setWrappedType(TypeWithDict::byName(wrappedName()));
edm::TypeWithDict wrType(TypeWithDict::byName(wrappedName()));
setWrappedType(wrType);
if(!bool(wrappedType())) {
setSplitLevel(invalidSplitLevel);
setBasketSize(invalidBasketSize);
return;
}
#if 0
wrappedType().invokeByName(wrapperInterfaceBase(), "getInterface");
assert(wrapperInterfaceBase() != 0);
Reflex::PropertyList wp = Reflex::Type::ByTypeInfo(wrappedType().typeInfo()).Properties();
setTransient((wp.HasProperty("persistent") ? wp.PropertyAsString("persistent") == std::string("false") : false));
if(transient()) {
setSplitLevel(invalidSplitLevel);
setBasketSize(invalidBasketSize);
//edm::FunctionWithDict giFunc = wrType.FunctionMemberByName("getInterface");
//giFunc.Invoke(wrapperInterfaceBase());
edm::invokeByName(wrapperInterfaceBase(), wrType, "getInterface");
assert((wrapperInterfaceBase() != 0) && "BranchDescription::initFromDictionary(): "
"wrapperInterfaceBase() is nullptr!!");
if (wrapperInterfaceBase() == nullptr) {
fprintf(stderr, "BranchDescription::initFromDictionary(): "
"wrapperInterfaceBase() is nullptr!\n");
abort();
}
setTransient(false);
setSplitLevel(invalidSplitLevel);
setBasketSize(invalidBasketSize);
TClassAttributeMap* wp = wrappedType().getClass()->GetAttributeMap();
if (wp && wp->HasKey("persistent") && strcmp(wp->GetPropertyAsString("persistent"), "false")) {
// Set transient if persistent != "false".
setTransient(true);
return;
}
if(wp.HasProperty("splitLevel")) {
setSplitLevel(strtol(wp.PropertyAsString("splitLevel").c_str(), 0, 0));
if(splitLevel() < 0) {
if (wp && wp->HasKey("splitLevel")) {
setSplitLevel(strtol(wp->GetPropertyAsString("splitLevel"), 0, 0));
if (splitLevel() < 0) {
throw cms::Exception("IllegalSplitLevel") << "' An illegal ROOT split level of " <<
splitLevel() << " is specified for class " << wrappedName() << ".'\n";
splitLevel() << " is specified for class " << wrappedName() << ".'\n";
}
setSplitLevel(splitLevel() + 1); //Compensate for wrapper
} else {
setSplitLevel(invalidSplitLevel);
}
if(wp.HasProperty("basketSize")) {
setBasketSize(strtol(wp.PropertyAsString("basketSize").c_str(), 0, 0));
if(basketSize() <= 0) {
if (wp && wp->HasKey("basketSize")) {
setBasketSize(strtol(wp->GetPropertyAsString("basketSize"), 0, 0));
if (basketSize() <= 0) {
throw cms::Exception("IllegalBasketSize") << "' An illegal ROOT basket size of " <<
basketSize() << " is specified for class " << wrappedName() << "'.\n";
basketSize() << " is specified for class " << wrappedName() << "'.\n";
}
} else {
setBasketSize(invalidBasketSize);
}
#endif // 0
//--
}

void
Expand Down Expand Up @@ -342,4 +348,5 @@ namespace edm {
BranchDescription::getInterface() const {
return transient_.wrapperInterfaceBase_;
}
}
} // namespace edm

1 change: 1 addition & 0 deletions DataFormats/Provenance/src/classes.h
Expand Up @@ -31,6 +31,7 @@
#include "DataFormats/Provenance/interface/RunID.h"
#include "DataFormats/Provenance/interface/Timestamp.h"
#include "DataFormats/Provenance/interface/ESRecordAuxiliary.h"
#include "DataFormats/Provenance/interface/WrapperInterfaceBase.h"
#include "FWCore/Utilities/interface/typedefs.h"
#include <map>
#include <set>
Expand Down
1 change: 1 addition & 0 deletions DataFormats/Provenance/src/classes_def.xml
@@ -1,4 +1,5 @@
<lcgdict>
<class name="edm::WrapperInterfaceBase"/>
<class name="edm::ProductID" ClassVersion="11">
<version ClassVersion="11" checksum="3913437934"/>
<version ClassVersion="10" checksum="1501211476"/>
Expand Down
1 change: 1 addition & 0 deletions FWCore/Services/src/InitRootHandlers.cc
Expand Up @@ -234,6 +234,7 @@ namespace edm {
// Set ROOT parameters.
TTree::SetMaxTreeSize(kMaxLong64);
TH1::AddDirectory(kFALSE);
//G__SetCatchException(0);

// Set custom streamers
setRefCoreStreamer();
Expand Down
29 changes: 22 additions & 7 deletions FWCore/Utilities/interface/FunctionWithDict.h
Expand Up @@ -12,6 +12,9 @@ FunctionWithDict: A holder for a class member function
#include "TMethod.h"
#include "TMethodArg.h"

#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>

Expand Down Expand Up @@ -54,24 +57,36 @@ class FunctionWithDict {

namespace edm {

/// Call a static function of class T, derived from the type
/// of the return value, by name with no arguments.
/// Call a static function of class theType, with a return
/// value of type T, by name with no arguments.
template<typename T>
inline
void
invokeByName(T& retval, const std::string& name)
invokeByName(T& retval, const TypeWithDict& theType, const std::string& name)
{
TypeWithDict theType(typeid(T));
if (!bool(theType)) {
fprintf(stderr, "FunctionWithDict: invokeByName<%s>: "
"Passed type is invalid!\n", typeid(T).name());
abort();
}
FunctionWithDict func = theType.functionMemberByName(name);
if (!bool(func)) {
return;
fprintf(stderr, "FunctionWithDict: invokeByName<%s>: "
"Could not find function named '%s' in type '%s'\n",
typeid(T).name(), name.c_str(), theType.name().c_str());
abort();
}
if (func.functionParameterSize(true) != 0) {
// FIXME: We should throw or write an error message here!
fprintf(stderr, "FunctionWithDict: invokeByName<%s>: "
"function '%s' in type '%s' should have zero "
"parameters, but has %lu parameters instead!\n",
typeid(T).name(), name.c_str(), theType.name().c_str(),
func.functionParameterSize(true));
abort();
return;
}
ObjectWithDict retobj(typeid(T), &retval);
func.invoke(retobj);
func.invoke(&retobj);
}

} // namespace edm
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Utilities/src/TypeWithDict.cc
Expand Up @@ -287,7 +287,7 @@ TypeWithDict::
operator bool() const
{
if (*ti_ == typeid(void)) {
return true;
return false;
}
if (type_ == nullptr) {
// FIXME: Replace this with an exception!
Expand Down