CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HistoryAppender.cc
Go to the documentation of this file.
5 
6 #include <string>
7 
8 namespace edm {
9 
11  previous_(historyMap_.end()) {
12  }
13 
14  CachedHistory const&
16  ProcessConfiguration const& pc) {
17 
18  if (previous_ != historyMap_.end() && inputPHID == previous_->first) return previous_->second;
19 
20  HistoryMap::iterator iter = historyMap_.find(inputPHID);
21  if (iter != historyMap_.end()) return iter->second;
22 
24 
25  ProcessHistory const* inputProcessHistory = &emptyHistory_;
26 
27  if (inputPHID.isValid()) {
28  inputProcessHistory = registry->getMapped(inputPHID);
29  if (inputProcessHistory == 0) {
31  << "HistoryAppender::appendToProcessHistory\n"
32  << "Input ProcessHistory not found in registry\n"
33  << "Contact a Framework developer\n";
34  }
35  }
36 
37  ProcessHistory newProcessHistory;
38  newProcessHistory = *inputProcessHistory;
39  checkProcessHistory(newProcessHistory, pc);
40  newProcessHistory.push_back(pc);
41  registry->insertMapped(newProcessHistory);
42  ProcessHistoryID newProcessHistoryID = newProcessHistory.id();
43  CachedHistory newValue(inputProcessHistory,
44  registry->getMapped(newProcessHistoryID),
45  newProcessHistoryID);
46  std::pair<ProcessHistoryID, CachedHistory> newEntry(inputPHID, newValue);
47  std::pair<HistoryMap::iterator, bool> result = historyMap_.insert(newEntry);
48  previous_ = result.first;
49  return result.first->second;
50  }
51 
52  void
54  ProcessConfiguration const& pc) const {
55  std::string const& processName = pc.processName();
56  for (ProcessHistory::const_iterator it = ph.begin(), itEnd = ph.end(); it != itEnd; ++it) {
57  if (processName == it->processName()) {
58  throw edm::Exception(errors::Configuration, "Duplicate Process.")
59  << "The process name " << processName << " was already in the ProcessHistory.\n"
60  << "Please modify the configuration file to use a distinct process name.\n";
61  }
62  }
63  }
64 }
collection_type::const_iterator const_iterator
const_iterator begin() const
static ThreadSafeRegistry * instance()
CachedHistory const & appendToProcessHistory(ProcessHistoryID const &inputPHID, ProcessConfiguration const &pc)
std::string const & processName() const
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:38
HistoryMap::const_iterator previous_
void push_back(const_reference t)
void checkProcessHistory(ProcessHistory const &ph, ProcessConfiguration const &pc) const
const_iterator end() const
bool isValid() const
Definition: Hash.h:146
static Interceptor::Registry registry("Interceptor")
ProcessHistoryID id() const
ProcessHistory emptyHistory_