From 8d3e09e430e829b9d847847334cbfe37790baca3 Mon Sep 17 00:00:00 2001
From: stephane Domas <stephane.domas@univ-fcomte.fr>
Date: Thu, 11 May 2017 21:37:28 +0200
Subject: [PATCH 1/1] started to include patterns in implementation

---
 BlockImplementation.cpp | 24 +++++++++++++++++++++++
 BlockImplementation.h   |  2 ++
 Exception.cpp           |  1 +
 Exception.h             | 42 +++++++++++++++++++++--------------------
 blast.creator.user      |  8 ++++----
 5 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/BlockImplementation.cpp b/BlockImplementation.cpp
index 571b72b..af06ef3 100644
--- a/BlockImplementation.cpp
+++ b/BlockImplementation.cpp
@@ -20,6 +20,30 @@ BlockImplementation::BlockImplementation(const QString& _xmlFile, const QString
   referenceMd5 = _referenceMd5;
 }
 
+void BlockImplementation::assignPatterns(FunctionalBlock *_block) throw(Exception) {
+  
+  block = _block;
+
+  QFile implFile(xmlFile);
+
+  // reading in into QDomDocument
+  QDomDocument document("implFile");
+
+  if (!implFile.open(QIODevice::ReadOnly)) {
+    throw(Exception(IMPLFILE_NOACCESS));
+  }
+  if (!document.setContent(&implFile)) {
+    implFile.close();
+    throw(Exception(IMPLFILE_NOACCESS));
+  }
+  implFile.close();
+  QDomElement impl = document.documentElement();
+  QDomNodeList patternNode = impl.elementsByTagName("patterns");
+  if (patternNode.isEmpty()) return;
+  QDomElement patternElt = patternNode.at(0).toElement();
+  
+}
+
 void BlockImplementation::generateVHDL(FunctionalBlock* _block, const QString &path) throw(Exception) {
 
   block = _block;
diff --git a/BlockImplementation.h b/BlockImplementation.h
index df0e499..852cc63 100644
--- a/BlockImplementation.h
+++ b/BlockImplementation.h
@@ -40,7 +40,9 @@ public:
 
   inline void setReference(ReferenceBlock* _reference) { reference = _reference; }
 
+  void assignPatterns(FunctionalBlock* _block) throw(Exception); // called during output pattern computation
   void generateVHDL(FunctionalBlock* _block, const QString& path) throw(Exception); // main entry to generate the VHDL code
+  
 
 private:  
   QString xmlFile;
diff --git a/Exception.cpp b/Exception.cpp
index c45c367..9093e49 100644
--- a/Exception.cpp
+++ b/Exception.cpp
@@ -24,6 +24,7 @@ QString Exception::getDefaultMessage() {
   case BLOCKFILE_NOACCESS : ret = tr("Block file cannot be read"); break;
   case IMPLFILE_CORRUPTED : ret = tr("Implementation file is corrupted"); break;
   case IMPLFILE_NOACCESS : ret = tr("Implementation file cannot be read"); break;
+  case IMPLFILE_NOPATTERN : ret = tr("Implementation file does not contains pattern definitions"); break;
   case BLOCK_NULL : ret = tr("A parameter of type AbstractBlock* has been provided with NULL value."); break;
   case BLOCK_INVALID_TYPE : ret = tr("A parameter of type AbstractBlock* is used with an incorrect instance type."); break;
   case IFACE_NULL : ret = tr("A parameter of type AbstractInterface* has been provided with NULL value."); break;
diff --git a/Exception.h b/Exception.h
index 32b2e49..c65ed5a 100644
--- a/Exception.h
+++ b/Exception.h
@@ -20,41 +20,43 @@ supp. infos : saved in UTF-8 [éè]
 #include <QtCore>
 
 // exceptions for file accesses
-#define CONFIGFILE_NOACCESS 1
-#define CONFIGFILE_CORRUPTED 2
+#define CONFIGFILE_NOACCESS 101
+#define CONFIGFILE_CORRUPTED 102
 
-#define PROJECTFILE_NOACCESS 3
-#define PROJECTFILE_CORRUPTED 4
+#define PROJECTFILE_NOACCESS 201
+#define PROJECTFILE_CORRUPTED 202
 
-#define BLOCKPATH_NOACCESS 5
-#define IMPLPATH_NOACCESS 6
+#define BLOCKFILE_NOACCESS 301
+#define BLOCKFILE_CORRUPTED 302
 
-#define BLOCKFILE_NOACCESS 7
-#define BLOCKFILE_CORRUPTED 8
+#define IMPLFILE_NOACCESS 401
+#define IMPLFILE_CORRUPTED 402
+#define IMPLFILE_NOPATTERN 403
 
-#define IMPLFILE_NOACCESS 9
-#define IMPLFILE_CORRUPTED 10
+#define VHDLFILE_NOACCESS 501
 
-#define VHDLFILE_NOACCESS 11
+#define BLOCKPATH_NOACCESS 601
+
+#define IMPLPATH_NOACCESS 701
 
 // exceptions for block manipulations
-#define BLOCK_NULL 100
-#define BLOCK_INVALID_TYPE 101
+#define BLOCK_NULL 1001
+#define BLOCK_INVALID_TYPE 1002
 
 // exceptions for interfaces manipulations
-#define IFACE_NULL 200
-#define IFACE_INVALID_TYPE 201
-#define IFACE_MULTIPLICITY_REACHED 202
+#define IFACE_NULL 2001
+#define IFACE_INVALID_TYPE 2002
+#define IFACE_MULTIPLICITY_REACHED 2003
 
 // exceptions for block items manipulations
-#define BLOCKITEM_NULL 300
-#define BLOCKITEM_INVALID_TYPE 301
+#define BLOCKITEM_NULL 3001
+#define BLOCKITEM_INVALID_TYPE 3002
 
 // exceptions for width interfaces validation
-#define WIDTHS_NOT_EQUALS 400
+#define WIDTHS_NOT_EQUALS 4001
 
 // exceptions for VHDL generation
-#define INVALID_VALUE 500
+#define INVALID_VALUE 5001
 
 using namespace std;
 using namespace Qt;
diff --git a/blast.creator.user b/blast.creator.user
index 6673fe4..b9d826a 100755
--- a/blast.creator.user
+++ b/blast.creator.user
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-11T17:54:38. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-11T21:36:51. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-  <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</value>
+  <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -60,12 +60,12 @@
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
-    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/localhome/sdomas/Projet/Blast/code/blast</value>
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/sdomas/Projet/Blast/code/blast</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
       <valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
-- 
2.39.5