Skip to content

Commit

Permalink
Merge pull request #104 from wmtan/useSetFunctions
Browse files Browse the repository at this point in the history
Use set functions
  • Loading branch information
ktf committed Jul 16, 2013
2 parents 132fd59 + 3183a77 commit a396d4b
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 77 deletions.
34 changes: 17 additions & 17 deletions DataFormats/Provenance/interface/BranchDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,54 +82,54 @@ namespace edm {
std::string const& friendlyClassName() const {return friendlyClassName_;}
std::string const& productInstanceName() const {return productInstanceName_;}
bool produced() const {return transient_.produced_;}
bool& produced() {return transient_.produced_;}
void setProduced(bool isProduced) {transient_.produced_ = isProduced;}
bool present() const {return !transient_.dropped_;}
bool dropped() const {return transient_.dropped_;}
bool& dropped() {return transient_.dropped_;}
void setDropped(bool isDropped) {transient_.dropped_ = isDropped;}
bool onDemand() const {return transient_.onDemand_;}
bool& onDemand() {return transient_.onDemand_;}
void setOnDemand(bool isOnDemand) {transient_.onDemand_ = isOnDemand;}
bool transient() const {return transient_.transient_;}
bool& transient() {return transient_.transient_;}
void setTransient(bool isTransient) {transient_.transient_ = isTransient;}
TypeWithDict const& wrappedType() const {return transient_.wrappedType_;}
TypeWithDict& wrappedType() {return transient_.wrappedType_;}
void setWrappedType(TypeWithDict const& type) {transient_.wrappedType_ = type;}
TypeWithDict const& unwrappedType() const {return transient_.unwrappedType_;}
TypeWithDict& unwrappedType() {return transient_.unwrappedType_;}
void setUnwrappedType(TypeWithDict const& type) {transient_.unwrappedType_ = type;}
TypeID wrappedTypeID() const {return TypeID(transient_.wrappedType_.typeInfo());}
TypeID unwrappedTypeID() const {return TypeID(transient_.unwrappedType_.typeInfo());}
int splitLevel() const {return transient_.splitLevel_;}
int& splitLevel() {return transient_.splitLevel_;}
void setSplitLevel(int level) {transient_.splitLevel_ = level;}
int basketSize() const {return transient_.basketSize_;}
int& basketSize() {return transient_.basketSize_;}
void setBasketSize(int size) {transient_.basketSize_ = size;}

ParameterSetID const& parameterSetID() const {return transient_.parameterSetID_;}
std::string const& moduleName() const {return transient_.moduleName_;}

std::map<ProcessConfigurationID, ParameterSetID> const& parameterSetIDs() const {
return transient_.parameterSetIDs_;
}
std::map<ProcessConfigurationID, ParameterSetID>& parameterSetIDs() {
return transient_.parameterSetIDs_;
void insertParameterSetID(std::pair<ProcessConfigurationID, ParameterSetID> const& entry) {
transient_.parameterSetIDs_.insert(entry);
}
std::map<ProcessConfigurationID, std::string> const& moduleNames() const {
return transient_.moduleNames_;
}
std::map<ProcessConfigurationID, std::string>& moduleNames() {
return transient_.moduleNames_;
void insertModuleName(std::pair<ProcessConfigurationID, std::string> const& entry) {
transient_.moduleNames_.insert(entry);
}
ParameterSetID const& psetID() const;
bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
std::set<std::string> const& branchAliases() const {return branchAliases_;}
std::set<std::string>& branchAliases() {return branchAliases_;}
void insertBranchAlias(std::string const& alias) {
branchAliases_.insert(alias);
}
std::string const& branchName() const {return transient_.branchName_;}
std::string& branchName() {return transient_.branchName_;}
void clearBranchName() {transient_.branchName_.clear();}
BranchType const& branchType() const {return branchType_;}
std::string const& wrappedName() const {return transient_.wrappedName_;}
std::string& wrappedName() {return transient_.wrappedName_;}
void setWrappedName(std::string const& name) {transient_.wrappedName_ = name;}
WrapperInterfaceBase*& wrapperInterfaceBase() {return transient_.wrapperInterfaceBase_;}

WrapperInterfaceBase const* getInterface() const;
void setDropped() {dropped() = true;}
void setOnDemand() {onDemand() = true;}
void updateFriendlyClassName();

void initializeTransients() {transient_.reset();}
Expand Down
12 changes: 6 additions & 6 deletions DataFormats/Provenance/interface/ConstBranchDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ namespace edm {
std::string const& className() const {return ptr_->fullClassName();}
std::string const& friendlyClassName() const {return ptr_->friendlyClassName();}
std::string const& productInstanceName() const {return ptr_->productInstanceName();}
bool const& produced() const {return ptr_->produced();}
bool const& dropped() const {return ptr_->dropped();}
bool const& onDemand() const {return ptr_->onDemand();}
bool produced() const {return ptr_->produced();}
bool dropped() const {return ptr_->dropped();}
bool onDemand() const {return ptr_->onDemand();}
bool present() const {return ptr_->present();}
bool const& transient() const {return ptr_->transient();}
bool transient() const {return ptr_->transient();}
TypeWithDict const& wrappedType() const {return ptr_->wrappedType();}
TypeWithDict const& unwrappedType() const {return ptr_->unwrappedType();}
TypeID wrappedTypeID() const {return ptr_->wrappedTypeID();}
TypeID unwrappedTypeID() const {return ptr_->unwrappedTypeID();}
int const& splitLevel() const {return ptr_->splitLevel();}
int const& basketSize() const {return ptr_->basketSize();}
int splitLevel() const {return ptr_->splitLevel();}
int basketSize() const {return ptr_->basketSize();}

ParameterSetID const& parameterSetID() const {return ptr_->parameterSetID();}
std::map<ProcessConfigurationID, ParameterSetID> const& parameterSetIDs() const {return ptr_->parameterSetIDs();}
Expand Down
85 changes: 43 additions & 42 deletions DataFormats/Provenance/src/BranchDescription.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ namespace edm {
productInstanceName_(productInstanceName),
branchAliases_(aliases),
transient_() {
dropped() = false;
transient_.produced_ = produced,
onDemand() = false;
setDropped(false);
setProduced(produced);
setOnDemand(false);
transient_.moduleName_ = moduleName;
transient_.parameterSetID_ = parameterSetID;
unwrappedType() = theTypeWithDict;
setUnwrappedType(theTypeWithDict);
init();
}

Expand All @@ -97,12 +97,12 @@ namespace edm {
branchAliases_(aliasForBranch.branchAliases()),
aliasForBranchID_(aliasForBranch.branchID()),
transient_() {
dropped() = false;
transient_.produced_ = aliasForBranch.produced(),
onDemand() = aliasForBranch.onDemand();
setDropped(false);
setProduced(aliasForBranch.produced());
setOnDemand(aliasForBranch.onDemand());
transient_.moduleName_ = aliasForBranch.moduleName();
transient_.parameterSetID_ = aliasForBranch.parameterSetID();
unwrappedType() = aliasForBranch.unwrappedType();
setUnwrappedType(aliasForBranch.unwrappedType());
init();
}

Expand Down Expand Up @@ -136,21 +136,22 @@ namespace edm {
<< "' contains an underscore ('_'), which is illegal in a process name.\n";
}

branchName().reserve(friendlyClassName().size() +
moduleLabel().size() +
productInstanceName().size() +
processName().size() + 4);
branchName() += friendlyClassName();
branchName() += underscore;
branchName() += moduleLabel();
branchName() += underscore;
branchName() += productInstanceName();
branchName() += underscore;
branchName() += processName();
branchName() += period;
std::string& brName = transient_.branchName_;
brName.reserve(friendlyClassName().size() +
moduleLabel().size() +
productInstanceName().size() +
processName().size() + 4);
brName += friendlyClassName();
brName += underscore;
brName += moduleLabel();
brName += underscore;
brName += productInstanceName();
brName += underscore;
brName += processName();
brName += period;

if(!branchID_.isValid()) {
branchID_.setID(branchName());
branchID_.setID(brName);
}
}

Expand All @@ -162,50 +163,50 @@ namespace edm {

throwIfInvalid_();

wrappedName() = wrappedClassName(fullClassName());
setWrappedName(wrappedClassName(fullClassName()));

// unwrapped type.
unwrappedType() = TypeWithDict::byName(fullClassName());
setUnwrappedType(TypeWithDict::byName(fullClassName()));
if(!bool(unwrappedType())) {
splitLevel() = invalidSplitLevel;
basketSize() = invalidBasketSize;
transient() = false;
setSplitLevel(invalidSplitLevel);
setBasketSize(invalidBasketSize);
setTransient(false);
return;
}

wrappedType() = TypeWithDict::byName(wrappedName());
setWrappedType(TypeWithDict::byName(wrappedName()));
if(!bool(wrappedType())) {
splitLevel() = invalidSplitLevel;
basketSize() = invalidBasketSize;
setSplitLevel(invalidSplitLevel);
setBasketSize(invalidBasketSize);
return;
}
wrappedType().invokeByName(wrapperInterfaceBase(), "getInterface");
assert(wrapperInterfaceBase() != 0);
Reflex::PropertyList wp = Reflex::Type::ByTypeInfo(wrappedType().typeInfo()).Properties();
transient() = (wp.HasProperty("persistent") ? wp.PropertyAsString("persistent") == std::string("false") : false);
setTransient((wp.HasProperty("persistent") ? wp.PropertyAsString("persistent") == std::string("false") : false));
if(transient()) {
splitLevel() = invalidSplitLevel;
basketSize() = invalidBasketSize;
setSplitLevel(invalidSplitLevel);
setBasketSize(invalidBasketSize);
return;
}
if(wp.HasProperty("splitLevel")) {
splitLevel() = strtol(wp.PropertyAsString("splitLevel").c_str(), 0, 0);
setSplitLevel(strtol(wp.PropertyAsString("splitLevel").c_str(), 0, 0));
if(splitLevel() < 0) {
throw cms::Exception("IllegalSplitLevel") << "' An illegal ROOT split level of " <<
splitLevel() << " is specified for class " << wrappedName() << ".'\n";
}
++splitLevel(); //Compensate for wrapper
setSplitLevel(splitLevel() + 1); //Compensate for wrapper
} else {
splitLevel() = invalidSplitLevel;
setSplitLevel(invalidSplitLevel);
}
if(wp.HasProperty("basketSize")) {
basketSize() = strtol(wp.PropertyAsString("basketSize").c_str(), 0, 0);
setBasketSize(strtol(wp.PropertyAsString("basketSize").c_str(), 0, 0));
if(basketSize() <= 0) {
throw cms::Exception("IllegalBasketSize") << "' An illegal ROOT basket size of " <<
basketSize() << " is specified for class " << wrappedName() << "'.\n";
}
} else {
basketSize() = invalidBasketSize;
setBasketSize(invalidBasketSize);
}
}

Expand All @@ -223,11 +224,11 @@ namespace edm {

void
BranchDescription::merge(BranchDescription const& other) {
parameterSetIDs().insert(other.parameterSetIDs().begin(), other.parameterSetIDs().end());
moduleNames().insert(other.moduleNames().begin(), other.moduleNames().end());
transient_.parameterSetIDs_.insert(other.parameterSetIDs().begin(), other.parameterSetIDs().end());
transient_.moduleNames_.insert(other.moduleNames().begin(), other.moduleNames().end());
branchAliases_.insert(other.branchAliases().begin(), other.branchAliases().end());
if(splitLevel() == invalidSplitLevel) splitLevel() = other.splitLevel();
if(basketSize() == invalidBasketSize) basketSize() = other.basketSize();
if(splitLevel() == invalidSplitLevel) setSplitLevel(other.splitLevel());
if(basketSize() == invalidBasketSize) setBasketSize(other.basketSize());
}

void
Expand Down Expand Up @@ -273,7 +274,7 @@ namespace edm {
void
BranchDescription::updateFriendlyClassName() {
friendlyClassName_ = friendlyname::friendlyName(fullClassName());
branchName().clear();
clearBranchName();
initBranchName();
}

Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/src/ProductRegistryHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace edm {
iDesc.moduleName(),
iDesc.parameterSetID(),
type);
if (!p->branchAlias_.empty()) pdesc.branchAliases().insert(p->branchAlias_);
if (!p->branchAlias_.empty()) pdesc.insertBranchAlias(p->branchAlias_);
iReg.addProduct(pdesc, iIsListener);
}//for
}
Expand Down
6 changes: 3 additions & 3 deletions FWCore/Framework/src/ScheduleItems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace edm {

for(auto& item : preg_->productListUpdator()) {
BranchDescription& prod = item.second;
prod.onDemand() = false;
prod.produced() = false;
prod.setOnDemand(false);
prod.setProduced(false);
}

// Mark dropped branches as dropped in the product registry.
Expand All @@ -59,7 +59,7 @@ namespace edm {
for(auto& item : preg_->productListUpdator()) {
BranchDescription& prod = item.second;
if(keptBranches.find(prod.branchID()) == keptBranches.end()) {
prod.setDropped();
prod.setDropped(true);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/src/WorkerManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace edm {
if(prod.second.produced() &&
prod.second.branchType() == InEvent &&
unscheduledLabels.end() != unscheduledLabels.find(prod.second.moduleLabel())) {
prod.second.setOnDemand();
prod.second.setOnDemand(true);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions FWCore/ParameterSet/src/FillProductRegistryTransients.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ namespace edm {
if(okToRegister && !moduleParameterSet.isRegistered()) {
ParameterSet moduleParameterSetCopy = processParameterSet->getParameterSet(moduleLabel);
moduleParameterSetCopy.registerIt();
bd.parameterSetIDs().insert(std::make_pair(pcid, moduleParameterSetCopy.id()));
bd.insertParameterSetID(std::make_pair(pcid, moduleParameterSetCopy.id()));
} else {
bd.parameterSetIDs().insert(std::make_pair(pcid, moduleParameterSet.id()));
bd.insertParameterSetID(std::make_pair(pcid, moduleParameterSet.id()));
}
if(isTriggerResults) {
bd.moduleNames().insert(std::make_pair(pcid, triggerResultsInserter));
bd.insertModuleName(std::make_pair(pcid, triggerResultsInserter));
} else {
bd.moduleNames().insert(std::make_pair(pcid, moduleParameterSet.getParameter<std::string>("@module_type")));
bd.insertModuleName(std::make_pair(pcid, moduleParameterSet.getParameter<std::string>("@module_type")));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion FWCore/TFWLiteSelector/src/TFWLiteSelectorBasic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ TFWLiteSelectorBasic::setupNewFile(TFile& iFile) {
prod.init();
//NEED to do this and check to see if branch exists
if(m_->tree_->GetBranch(prod.branchName().c_str()) == 0) {
prod.setDropped();
prod.setDropped(true);
}

//std::cout << "id " << it->first << " branch " << it->second << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion IOPool/Input/src/PoolSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace edm {
//now make sure this is marked as not dropped else the product will not be 'get'table from the Event
iterator itFound = fullList.find(it->first);
if(itFound != fullList.end()) {
itFound->second.dropped()=false;
itFound->second.setDropped(false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion IOPool/Input/src/RootTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace edm {
RootTree::setPresence(BranchDescription& prod, std::string const& oldBranchName) {
assert(isValid());
if(tree_->GetBranch(oldBranchName.c_str()) == 0){
prod.setDropped();
prod.setDropped(true);
}
}

Expand Down

0 comments on commit a396d4b

Please sign in to comment.