Exemplo n.º 1
0
  /**
   * returns a flat list of Choicepoint scopes for a {@link SubStateTrPointTerminal}
   *
   * @param ct - the transition endpoint or terminal
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_ChoicepointTerminal_cp(ChoicepointTerminal ct, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    // first state in container hierarchy
    StateGraph parent = getStateGraph(ct);

    // collect choicepoints of my parent
    if (parent != null)
      for (ChoicePoint cp : parent.getChPoints()) {
        scopes.add(EObjectDescription.create(cp.getName(), cp));
      }

    // if my parent is a refined state we also add its base state contents
    if (parent.eContainer() instanceof RefinedState) {
      parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph();
      if (parent != null)
        for (ChoicePoint cp : parent.getChPoints()) {
          scopes.add(EObjectDescription.create(cp.getName(), cp));
        }
    } else if (parent.eContainer() instanceof ActorClass) {
      ActorClass ac = (ActorClass) parent.eContainer();
      if (ac.getBase() != null) {
        for (ChoicePoint cp : ac.getBase().getStateMachine().getChPoints()) {
          scopes.add(EObjectDescription.create(cp.getName(), cp));
        }
      }
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
Exemplo n.º 2
0
  private IScope getStateScopes(EObject obj) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    // first state in container hierarchy
    StateGraph parent = getStateGraph(obj);

    // collect states of my parent
    if (parent != null) {
      for (State s : parent.getStates()) {
        BaseState bs = getBaseState(s);
        scopes.add(EObjectDescription.create(bs.getName(), bs));
      }

      // if my parent is a refined state we also add its base state contents
      if (parent.eContainer() instanceof RefinedState) {
        parent = ((RefinedState) parent.eContainer()).getBase().getSubgraph();
        if (parent != null)
          for (State s : parent.getStates()) {
            BaseState bs = getBaseState(s);
            scopes.add(EObjectDescription.create(bs.getName(), bs));
          }
      } else if (parent.eContainer() instanceof ActorClass) {
        ActorClass ac = (ActorClass) parent.eContainer();
        if (ac.getBase() != null) {
          for (State s : ac.getBase().getStateMachine().getStates()) {
            BaseState bs = getBaseState(s);
            scopes.add(EObjectDescription.create(bs.getName(), bs));
          }
        }
      }
    }
    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
Exemplo n.º 3
0
  /**
   * returns a flat list of BaseState scopes for a {@link RefinedState}
   *
   * @param rs - the refined state
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_RefinedState_base(RefinedState rs, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(rs);
    LinkedList<BaseState> states = new LinkedList<BaseState>();
    collectAllStates(ac.getBase(), states);
    for (BaseState bs : states) {
      scopes.add(EObjectDescription.create(getStatePath(bs), bs));
    }
    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
Exemplo n.º 4
0
 /**
  * return a list of base classes of an {@link ActorClass}, parent classes first. The list includes
  * the class itself
  *
  * @param ac
  * @return
  */
 private LinkedList<ActorClass> getBaseClasses(ActorClass ac) {
   LinkedList<ActorClass> classes = new LinkedList<ActorClass>();
   if (ac != null) {
     classes.addFirst(ac);
     while (ac.getBase() != null) {
       ac = ac.getBase();
       classes.addFirst(ac);
     }
   }
   return classes;
 }
Exemplo n.º 5
0
 /**
  * recursively collect all {@link BaseState}s of an actor class in a list
  *
  * @param ac
  * @param states
  */
 private void collectAllStates(ActorClass ac, LinkedList<BaseState> states) {
   while (ac != null) {
     collectStates(ac.getStateMachine(), states);
     ac = ac.getBase();
   }
 }