/// Removes all scatterers.
void CompositeBraggScatterer::removeAllScatterers() {
  while (nScatterers() > 0) {
    removeScattererImplementation(0);
  }

  redeclareProperties();
}
/// Removes the i-th scatterer from the composite or throws an std::out_of_range
/// exception.
void CompositeBraggScatterer::removeScatterer(size_t i) {
  if (i >= nScatterers()) {
    throw std::out_of_range("Index is out of range.");
  }

  m_scatterers.erase(m_scatterers.begin() + i);

  redeclareProperties();
}
/// Clears all scatterers and assigns clones of the supplied ones.
void CompositeBraggScatterer::setScatterers(
    const std::vector<BraggScatterer_sptr> &scatterers) {
  removeAllScatterers();

  for (const auto &scatterer : scatterers) {
    addScattererImplementation(scatterer);
  }

  redeclareProperties();
}
/// Clones the supplied scatterer, assigns the internal space group and unit
/// cell to the clone and adds it to the composite.
void
CompositeBraggScatterer::addScatterer(const BraggScatterer_sptr &scatterer) {
  if (!scatterer) {
    throw std::invalid_argument("Cannot process null-scatterer.");
  }

  BraggScatterer_sptr localScatterer = scatterer->clone();

  m_scatterers.push_back(localScatterer);

  redeclareProperties();
}
/// Removes the i-th scatterer from the composite or throws an std::out_of_range
/// exception.
void CompositeBraggScatterer::removeScatterer(size_t i) {
  removeScattererImplementation(i);

  redeclareProperties();
}
/// Clones the supplied scatterer, assigns the internal space group and unit
/// cell to the clone and adds it to the composite.
void CompositeBraggScatterer::addScatterer(
    const BraggScatterer_sptr &scatterer) {
  addScattererImplementation(scatterer);
  redeclareProperties();
}