コード例 #1
0
 @Override
 public IList<ISpecies> getMicroSpecies() {
   final IList<ISpecies> retVal = GamaListFactory.create(Types.SPECIES);
   retVal.addAll(microSpecies.values());
   final ISpecies parentSpecies = this.getParentSpecies();
   if (parentSpecies != null) {
     retVal.addAll(parentSpecies.getMicroSpecies());
   }
   return retVal;
 }
コード例 #2
0
 @Override
 public boolean extendsSpecies(final ISpecies s) {
   ISpecies parent = getParentSpecies();
   if (parent == null) {
     return false;
   }
   if (parent == s) {
     return true;
   }
   return parent.extendsSpecies(s);
 }
コード例 #3
0
 @Override
 public IList<ISpecies> getSubSpecies(final IScope scope) {
   IList<ISpecies> subspecies = GamaListFactory.create(Types.SPECIES);
   GamlModelSpecies model = (GamlModelSpecies) scope.getModel().getSpecies();
   for (ISpecies s : model.getAllSpecies().values()) {
     if (s.getParentSpecies() == this) {
       subspecies.add(s);
     }
   }
   return subspecies;
 }
コード例 #4
0
  @Override
  public List<ISpecies> getSelfWithParents() {
    final List<ISpecies> retVal = new ArrayList<ISpecies>();
    retVal.add(this);
    ISpecies currentParent = this.getParentSpecies();
    while (currentParent != null) {
      retVal.add(currentParent);
      currentParent = currentParent.getParentSpecies();
    }

    return retVal;
  }
コード例 #5
0
 /**
  * Returns a micro-species with the specified name or null otherwise.
  *
  * @param microSpeciesName
  * @return a species or null
  */
 @Override
 public ISpecies getMicroSpecies(final String microSpeciesName) {
   final ISpecies retVal = microSpecies.get(microSpeciesName);
   if (retVal != null) {
     return retVal;
   }
   final ISpecies parentSpecies = this.getParentSpecies();
   if (parentSpecies != null) {
     return parentSpecies.getMicroSpecies(microSpeciesName);
   }
   return null;
 }
コード例 #6
0
 @Override
 public ISpecies getParentSpecies() {
   if (parentSpecies == null) {
     final TypeDescription parentSpecDesc = getDescription().getParent();
     // Takes care of invalid species (see Issue 711)
     if (parentSpecDesc == null || parentSpecDesc == getDescription()) {
       return null;
     }
     ISpecies currentMacroSpec = this.getMacroSpecies();
     while (currentMacroSpec != null && parentSpecies == null) {
       parentSpecies = currentMacroSpec.getMicroSpecies(parentSpecDesc.getName());
       currentMacroSpec = currentMacroSpec.getMacroSpecies();
     }
   }
   return parentSpecies;
 }
コード例 #7
0
 @Override
 public void setChildren(final List<? extends ISymbol> children) {
   // First we verify the control architecture
   final IArchitecture control = getArchitecture();
   if (control == null) {
     throw GamaRuntimeException.error(
         "The control of species " + description.getName() + " cannot be computed");
   }
   // Then we classify the children in their categories
   for (final ISymbol s : children) {
     if (s instanceof ISpecies) {
       final ISpecies oneMicroSpecies = (ISpecies) s;
       oneMicroSpecies.setMacroSpecies(this);
       microSpecies.put(oneMicroSpecies.getName(), oneMicroSpecies);
     } else if (s instanceof IVariable) {
       variables.put(s.getName(), (IVariable) s);
     } else if (s instanceof AspectStatement) {
       aspects.put(s.getName(), (AspectStatement) s);
     } else if (s instanceof ActionStatement) {
       if (!s.getDescription().isBuiltIn()) {
         String name = s.getName();
         if (name.equals(initActionName)) {
           isInitOverriden = true;
         } else if (name.equals(stepActionName)) {
           isStepOverriden = true;
         }
       }
       actions.put(s.getName(), (ActionStatement) s);
     } else if (s instanceof UserCommandStatement) {
       userCommands.put(s.getName(), (UserCommandStatement) s);
     } else if (s instanceof IStatement) {
       behaviors.add((IStatement) s); // reflexes, states or tasks
     }
   }
   control.setChildren(behaviors);
   control.verifyBehaviors(this);
 }
コード例 #8
0
 @Override
 public boolean isPeer(final ISpecies other) {
   return other != null && other.getMacroSpecies().equals(this.getMacroSpecies());
 }
コード例 #9
0
 @Override
 public boolean hasMicroSpecies() {
   final ISpecies parentSpecies = this.getParentSpecies();
   return !microSpecies.isEmpty()
       || (parentSpecies != null ? parentSpecies.hasMicroSpecies() : false);
 }
コード例 #10
0
 @Override
 public boolean containMicroSpecies(final ISpecies species) {
   final ISpecies parentSpecies = this.getParentSpecies();
   return microSpecies.values().contains(species)
       || (parentSpecies != null ? parentSpecies.containMicroSpecies(species) : false);
 }