Ejemplo n.º 1
0
int CompModelPlugin::removeCollectedElements(set<SBase*>* removed, set<SBase*>* toremove)
{
  while (toremove->size() > 0) {
    SBase* removeme = *(toremove->begin());
    if (removed->insert(removeme).second == true) {
      //Need to remove the element.
      List* children = removeme->getAllElements();
      for (unsigned int el=0; el<children->getSize(); el++) {
        SBase* element = static_cast<SBase*>(children->get(el));
        removed->insert(element);
      }
      CompBase::removeFromParentAndPorts(removeme, removed);
    }
    toremove->erase(removeme);
  }
  return LIBSBML_OPERATION_SUCCESS;
}
Ejemplo n.º 2
0
List*
ListOf::getAllElements()
{
  List* ret = new List();
  List* sublist = NULL;
  for (unsigned int i = 0; i < size(); i++) {
    SBase* obj = get(i);
    ret->add(obj);
    sublist = obj->getAllElements();
    ret->transferFrom(sublist);
    delete sublist;
  }
  sublist = getAllElementsFromPlugins();
  ret->transferFrom(sublist);
  delete sublist;
  return ret;
}
Ejemplo n.º 3
0
List*
ListOf::getAllElements(ElementFilter *filter)
{
  List* ret = new List();
  List* sublist = NULL;
  for (unsigned int i = 0; i < size(); i++) {
    SBase* obj = get(i);
    if (filter == NULL || filter->filter(obj))
      ret->add(obj);
    sublist = obj->getAllElements(filter);
    ret->transferFrom(sublist);
    delete sublist;
  }

  ADD_FILTERED_FROM_PLUGIN(ret, sublist, filter);

  return ret;
}