コード例 #1
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * 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);
  }
コード例 #2
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  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);
  }
コード例 #3
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
  /**
   * 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);
  }
コード例 #4
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
 /**
  * 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;
 }
コード例 #5
0
ファイル: RoomScopeProvider.java プロジェクト: hckkid/eTrice
 /**
  * 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();
   }
 }