Math2mat
|
00001 /****************************************************************************** 00002 * GenericOperation 00003 ****************************************************************************** 00004 * Auteur : Trolliet Gregory 00005 * Date : 12 novembre 2009 00006 * Description : Generic operation 00007 ******************************************************************************/ 00008 package m2m.backend.structure; 00009 00010 public class GenericOperation extends Operation { 00011 00012 00013 public String getXmlTagName() { 00014 return "GenericOperation"; 00015 } 00016 00017 public GenericOperation() { 00018 super("",true); 00019 } 00020 public GenericOperation(String name) { 00021 super(name, true); 00022 } 00023 00024 @Override 00025 public void copyTo(Element e,Function newFunc) { 00026 GenericOperation newElement=(GenericOperation)e; 00027 super.copyTo(newElement,newFunc); 00028 } 00029 00030 @Override 00031 public Element copy(Function newFunc) { 00032 GenericOperation newElement=new GenericOperation(this.name); 00033 this.copyTo(newElement,newFunc); 00034 return newElement; 00035 } 00036 00037 @Override 00038 public String toOctave(int level) { 00039 String s = new String(); 00040 s += tab(level); 00041 if (this.output != null & !this.output.isEmpty()) { 00042 if (this.output.firstElement() instanceof Variable 00043 & !this.output.firstElement().getName().isEmpty()) { 00044 00045 s += this.output.firstElement().getName(); 00046 } 00047 } 00048 s += " = " + this.opName + "("; 00049 boolean first = true; 00050 for (Element e : this.input) { 00051 if (first) { 00052 first = false; 00053 } else { 00054 s += ", "; 00055 } 00056 if (e instanceof Variable) { 00057 if (e.getName().isEmpty()) { 00058 s += ((Variable) e).getVal(); 00059 } else { 00060 s += e.getName(); 00061 } 00062 } 00063 } 00064 s += ")" + ((this.monitor) ? "" : ";"); 00065 return s; 00066 } 00067 }