ModuleModelHandler() {

    mModuleModel = new ModuleModel();
    mModuleModel.setSimulation(true);

    mList = new ArrayList<Module>();
  }
 public void endInteraction() {
   if (mCID == null || mCMP == null)
     throw new RuntimeException("An interaction clause is ending without" + "initlization");
   mCID.addInteraction(mCIDFP, mCIDTP, mCIDCount, mCIDCount);
   mModuleModel.getModuleExchangeMap().put(mCMP, mCID);
   mCID = null;
   mCMP = null;
 }
  public void endModule() {
    if (mCMFake == null)
      throw new RuntimeException("A module clause is ending without" + "initialization.");
    Module mReal;
    if (mModuleModel.getModuleMap().get(mCMFake.getName()) != null) {
      mReal = mModuleModel.getModuleMap().get(mCMFake.getName());
    } else mReal = new Module(mCMFake);

    // partitionIds are equal to 1 or 2 in the current module model. We decrease the Id by one, in
    // order
    // to properly assign the values for the partition Ids to the array of values in the modules.
    mReal.setExecutionCost(mCMFake.getExecutionCost(), mCMFake.getPartitionId() - 1);
    mReal.setExecutionCount(mCMFake.getExecutionCount(), mCMFake.getPartitionId() - 1);
    mReal.setPartitionId(-1);

    mModuleModel.getModuleMap().put(mReal.getName(), mReal);

    mList.add(mCMFake);

    mCMFake = null;
  }
  public void startInteraction(String m1, String m2) {
    if (mCMP != null) throw new RuntimeException("Module pair is already initialized");

    mCMP = new ModulePair(mModuleModel.getModuleMap().get(m1), mModuleModel.getModuleMap().get(m2));
    mCID = new InteractionData();
  }
 public void setModelName(String name) {
   mModuleModel.setName(name);
 }