From 98588d8959c738733ab8ac2cbaca09e46d6abb4f Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr>
Date: Fri, 29 May 2009 09:36:05 +0000
Subject: [PATCH] HashCode on TML specifications

---
 Makefile                                      | 30 ++++++++++---------
 src/tmltranslator/TMLArchitecture.java        | 18 +++++++++++
 src/tmltranslator/TMLMapping.java             | 18 +++++++++++
 .../TMLMappingTextSpecification.java          |  2 ++
 src/tmltranslator/TMLModeling.java            | 20 ++++++++++++-
 5 files changed, 73 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index 455c19ff80..4abedcc026 100755
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,7 @@ documentation:
 	$(JAVADOC) $(CLASSPATH) $(TTOOL_SRC) -d $(TTOOL_DOC_HTML) $(TTOOL_SRC)/*.java $(TTOOL_SRC)/*/*.java $(TTOOL_SRC)/*/*/*.java $(TTOOL_SRC)/fr/inria/oasis/vercors/cttool/model/*.java
 
 release: jttooljar launcher tiftranslator tmltranslator remotesimulator ttooljar_std stdrelease 
-	echo release done
+	@echo release done
 
 ########## RELEASE
 stdrelease:
@@ -117,19 +117,21 @@ stdrelease:
 	cd $(TTOOL_MODELING); cp $(RELEASE_STD_FILES_LIB) $(TTOOL_TARGET)/lib
 	cp $(TTOOL_DOC)/README_lib $(TTOOL_TARGET)/lib
 # simulators
-	mkdir -p $(TTOOL_TARGET)/simulators/version1/src_simulator
-	mkdir -p $(TTOOL_TARGET)/simulators/version1/lib
-	cp  $(TTOOL_SIMULATORS)/systemc1/Makefile $(TTOOL_TARGET)/simulators/version1
-	cp  $(TTOOL_SIMULATORS)/systemc1/Makefile.defs $(TTOOL_TARGET)/simulators/version1
-	cp  $(TTOOL_SIMULATORS)/systemc1/src_simulator/*.cpp $(TTOOL_TARGET)/simulators/version1/src_simulator
-	cp  $(TTOOL_SIMULATORS)/systemc1/src_simulator/*.h $(TTOOL_TARGET)/simulators/version1/src_simulator
-	mkdir -p $(TTOOL_TARGET)/simulators/version2/src_simulator
-	mkdir -p $(TTOOL_TARGET)/simulators/version2/lib
-	cp  $(TTOOL_SIMULATORS)/c++2/Makefile $(TTOOL_TARGET)/simulators/version2
-	cp  $(TTOOL_SIMULATORS)/c++2/Makefile.defs $(TTOOL_TARGET)/simulators/version2
-	cp  $(TTOOL_SIMULATORS)/c++2/schedstyle.css $(TTOOL_TARGET)/simulators/version2
-	cp  $(TTOOL_SIMULATORS)/c++2/src_simulator/*.cpp $(TTOOL_TARGET)/simulators/version2/src_simulator
-	cp  $(TTOOL_SIMULATORS)/c++2/src_simulator/*.h $(TTOOL_TARGET)/simulators/version2/src_simulator
+	mkdir -p $(TTOOL_TARGET)/simulators/systemc1/src_simulator
+	mkdir -p $(TTOOL_TARGET)/simulators/systemc1/lib
+	cp  $(TTOOL_SIMULATORS)/systemc1/lib/README $(TTOOL_TARGET)/simulators/systemc1/lib/
+	cp  $(TTOOL_SIMULATORS)/systemc1/Makefile $(TTOOL_TARGET)/simulators/systemc1
+	cp  $(TTOOL_SIMULATORS)/systemc1/Makefile.defs $(TTOOL_TARGET)/simulators/systemc1
+	cp  $(TTOOL_SIMULATORS)/systemc1/src_simulator/*.cpp $(TTOOL_TARGET)/simulators/systemc1/src_simulator
+	cp  $(TTOOL_SIMULATORS)/systemc1/src_simulator/*.h $(TTOOL_TARGET)/simulators/systemc1/src_simulator
+	mkdir -p $(TTOOL_TARGET)/simulators/c++2/src_simulator
+	mkdir -p $(TTOOL_TARGET)/simulators/c++2/lib
+	cp  $(TTOOL_SIMULATORS)/c++2/lib/README $(TTOOL_TARGET)/simulators/c++2/lib/
+	cp  $(TTOOL_SIMULATORS)/c++2/Makefile $(TTOOL_TARGET)/simulators/c++2
+	cp  $(TTOOL_SIMULATORS)/c++2/Makefile.defs $(TTOOL_TARGET)/simulators/c++2
+	cp  $(TTOOL_SIMULATORS)/c++2/schedstyle.css $(TTOOL_TARGET)/simulators/c++2
+	cp  $(TTOOL_SIMULATORS)/c++2/src_simulator/*.cpp $(TTOOL_TARGET)/simulators/c++2/src_simulator
+	cp  $(TTOOL_SIMULATORS)/c++2/src_simulator/*.h $(TTOOL_TARGET)/simulators/c++2/src_simulator
 # Licenses
 	cd $(TTOOL_DOC); cp $(RELEASE_STD_FILES_LICENSES) $(TTOOL_TARGET)
 # Main readme
diff --git a/src/tmltranslator/TMLArchitecture.java b/src/tmltranslator/TMLArchitecture.java
index bd1c5fa5ea..bcad2d2a26 100755
--- a/src/tmltranslator/TMLArchitecture.java
+++ b/src/tmltranslator/TMLArchitecture.java
@@ -54,6 +54,9 @@ public class TMLArchitecture {
 	
 	private int masterClockFrequency = 200; // in MHz
 	
+	private int hashCode;
+	private boolean hashCodeComputed = false;
+	
     
     public TMLArchitecture() {
         init();
@@ -64,6 +67,21 @@ public class TMLArchitecture {
 		hwlinks = new ArrayList<HwLink>();
     }
 	
+	private void computeHashCode() {
+		TMLArchiTextSpecification architxt = new TMLArchiTextSpecification("spec.tarchi");
+		String s = architxt.toTextFormat(this);
+		hashCode = s.hashCode();
+		System.out.println("TARCHI hashcode = " + hashCode); 
+	}
+	
+	public int getHashCode() {
+		if (!hashCodeComputed) {
+			computeHashCode();
+			hashCodeComputed = true;
+		}
+		return hashCode;
+	}
+	
 	public void setMasterClockFrequency(int value) {
 		masterClockFrequency = value;
 	}
diff --git a/src/tmltranslator/TMLMapping.java b/src/tmltranslator/TMLMapping.java
index 1a120bf586..34341c018f 100755
--- a/src/tmltranslator/TMLMapping.java
+++ b/src/tmltranslator/TMLMapping.java
@@ -58,6 +58,9 @@ public class TMLMapping {
 	private ArrayList<TMLElement> mappedcommelts;
 	
 	private boolean optimized = false;
+	
+	private int hashCode;
+	private boolean hashCodeComputed = false;
     
     public TMLMapping(TMLModeling _tmlm, TMLArchitecture _tmla) {
         tmlm = _tmlm;
@@ -89,6 +92,21 @@ public class TMLMapping {
 		return tmla;
 	}
 	
+	private void computeHashCode() {
+		hashCode = tmlm.getHashCode() + tmla.getHashCode();
+		TMLMappingTextSpecification tmaptxt = new TMLMappingTextSpecification("spec.tmap");
+		hashCode += tmaptxt.toString().hashCode();
+		System.out.println("TMAP hashcode = " + hashCode); 
+	}
+	
+	public int getHashCode() {
+		if (!hashCodeComputed) {
+			computeHashCode();
+			hashCodeComputed = true;
+		}
+		return hashCode;
+	}
+	
 	public ArrayList<HwExecutionNode> getNodes(){
 		return onnodes;
 	}
diff --git a/src/tmltranslator/TMLMappingTextSpecification.java b/src/tmltranslator/TMLMappingTextSpecification.java
index c01358717f..4cccf447ea 100755
--- a/src/tmltranslator/TMLMappingTextSpecification.java
+++ b/src/tmltranslator/TMLMappingTextSpecification.java
@@ -72,6 +72,8 @@ public class TMLMappingTextSpecification {
 
 	private String taskparameters[] = {"PRIORITY"};		
 	
+	private int hashCode;
+	
 	
 	public TMLMappingTextSpecification(String _title) {
 		title = _title;
diff --git a/src/tmltranslator/TMLModeling.java b/src/tmltranslator/TMLModeling.java
index 1082e5685e..d88bcb8d40 100755
--- a/src/tmltranslator/TMLModeling.java
+++ b/src/tmltranslator/TMLModeling.java
@@ -36,7 +36,7 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 
 /**
- * Class TMLTask
+ * Class TMLModeling
  * Creation: 21/11/2005
  * @version 1.0 21/11/2005
  * @author Ludovic APVRILLE
@@ -60,6 +60,9 @@ public class TMLModeling {
 	private boolean optimized = false;
 	
 	private String[] ops = {">", "<", "+", "-", "*", "/", "[", "]", "(", ")", ":", "=", "==", ","};
+	
+	private int hashCode;
+	private boolean hashCodeComputed = false;
     
     public TMLModeling() {
         init();
@@ -114,6 +117,21 @@ public class TMLModeling {
         }
         return null;
 	}
+	
+	private void computeHashCode() {
+		TMLTextSpecification tmltxt = new TMLTextSpecification("spec.tml");
+		String s = tmltxt.toTextFormat(this);
+		hashCode = s.hashCode();
+		System.out.println("TML hashcode = " + hashCode); 
+	}
+	
+	public int getHashCode() {
+		if (!hashCodeComputed) {
+			computeHashCode();
+			hashCodeComputed = true;
+		}
+		return hashCode;
+	}
     
     public String toString() {
         String s = tasksToString();
-- 
GitLab