コード例 #1
0
/**
Return a collection of all referenced workspaces on demand.
*/
SetPeaksWorkspaces CompositePeaksPresenter::presentedWorkspaces() const {
  SetPeaksWorkspaces allWorkspaces;
  for (auto it = m_subjects.begin(); it != m_subjects.end(); ++it) {
    auto workspacesToAppend = (*it)->presentedWorkspaces();
    allWorkspaces.insert(workspacesToAppend.begin(), workspacesToAppend.end());
  }
  return allWorkspaces;
}
コード例 #2
0
/**
 * Determine if the contents of the other presenter are different from this one.
 * @param other
 * @return
 */
bool ConcretePeaksPresenter::contentsDifferent(
    const PeaksPresenter *other) const {
  const SetPeaksWorkspaces otherWorkspaces = other->presentedWorkspaces();

  // Look for this workspace in the others workspace list.
  auto iterator = otherWorkspaces.find(this->m_peaksWS);

  const bool different = (iterator == otherWorkspaces.end());
  return different;
}
コード例 #3
0
/**
 * @brief Determine wheter the workspace contents is different with another
 * presenter.
 * @param other
 * @return
 */
bool CompositePeaksPresenter::contentsDifferent(
    PeaksPresenter const *const other) const {
  /*
   What we are doing here is looking through all workspaces associated with the
   incoming presenter
   and seeing if ANY of the exising subjects of this composite is already
   presenting one of these workspaces.
   ONLY if there is no intesection between the two sets will we allow addition.
   */
  const SetPeaksWorkspaces otherWorkspaces = other->presentedWorkspaces();
  const SetPeaksWorkspaces existingWorkspaces = this->presentedWorkspaces();

  SetPeaksWorkspaces difference;
  std::set_difference(existingWorkspaces.begin(), existingWorkspaces.end(),
                      otherWorkspaces.begin(), otherWorkspaces.end(),
                      std::inserter(difference, difference.end()));

  // Is the candidate set the same as the difference set (i.e. no intesection)
  // and also non-zero in size
  const bool different = (difference.size() == existingWorkspaces.size());
  return different;
}
コード例 #4
0
/**
 @return a reference to the held peaks workspace.
 */
SetPeaksWorkspaces ConcretePeaksPresenter::presentedWorkspaces() const {
  // There is only one workspace to return.
  SetPeaksWorkspaces workspaces;
  workspaces.insert(m_peaksWS);
  return workspaces;
}