Package de.maramuse.soundcomp.parser

Source Code of de.maramuse.soundcomp.parser.TestHelper

/*
* Copyright 2011 Jan Schmidt-Reinisch
*
* SoundComp - a sound processing library
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; in version 2.1
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

/**
* this class allows test case access to certain package visible methods and classes - so
* we don't have to make them world public.
*/
package de.maramuse.soundcomp.parser;

import de.maramuse.soundcomp.parser.math.Plus;

public class TestHelper {
  /**
   * creates a simple process reference to a process with a single input and output.
   * The refType is the name of the underlying process type.
   * The refName is the name of the reference itself.
   * @param processName
   * @param refType
   * @return a new process reference
   */
  public static ProcessRef createTestProcessRef(String refName, String refType){
  ProcessRef ref=new ProcessRef(refType);
  ref.setLocalName(new Element(refName));
  return ref;
  }
 
  /**
   * creates a simple single-input, single-output process.
   * the output is named "output", the input is named "input".
   * The single-process subprocess list included in this process
   *  shall make this process map a simple "output=input+1" equation.
   * The output equation in the main process just subtracts this 1 again, so the overall
   *  effect of this process should be just forwarding input to output
   * @return a new Process
   */
  public static Process createProcess(){
  Process subprocess=new Process();
  Plus subplus=new Plus("subplus");
  Number number=new Number(1);
  subplus.append(number);
  subplus.append(new Element("input_sub"));
  subprocess.setInputs(new NameList(new Element("input_sub")));
  ConnectionList suboutputs=new ConnectionList();
  Connection subconn=new Connection(subplus, "out", "output_sub");
  suboutputs.append(subconn);
  subprocess.setOutputs(suboutputs);
  subprocess.setName(new Element("subprocess"));
  InputAssignment subipa=new InputAssignment(new Equals("="));
  subipa.setInputName("input_sub");
  subipa.setFormula(new Element("input_sub"));
  InputAssignments subipas=new InputAssignments(subipa);
  ProcessRef subsubreference=new ProcessRef("subsub");
  subsubreference.setLocalName(new Element("mysubplus"));
  subsubreference.setElementType("subplus");
  subsubreference.setInputAssignments(subipas);
 
 
  Process process=new Process();
  Processes processes=new Processes("processes");
  ProcessRef subreference=new ProcessRef("sub");
  subreference.setElementType("subprocess");
  subreference.setLocalName(new Element("mysubprocess"));
  processes.append(subreference);
  process.setElements(processes);
  process.setInputs(new NameList(new Element("input")));
  // no variables
  ConnectionList outputs=new ConnectionList();
  Connection conn=new Connection(new ConnectionPoint("mysubprocess", "out"), "output");
  InputAssignment ipa=new InputAssignment(new Equals("="));
  ipa.setInputName("input_sub");
  Plus plus=new Plus("+2");
  plus.append(new Number(0));
  plus.append(new Element("input"));
  ipa.setFormula(plus);
  InputAssignments ipas=new InputAssignments(ipa);
  subreference.setInputAssignments(ipas);
  outputs.append(conn);
  process.setOutputs(outputs);
  return process;
  }
}
TOP

Related Classes of de.maramuse.soundcomp.parser.TestHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.