[opengtl-commits] [688] add support for hints

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 688
Author:   cyrille
Date:     2009-03-26 11:04:30 +0100 (Thu, 26 Mar 2009)

Log Message:
-----------
add support for hints

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h

Added Paths:
-----------
    trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.h


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt	2009-03-26 10:04:30 UTC (rev 688)
@@ -18,6 +18,7 @@
   PixelConvertExpressionFactory_p.cpp
   Kernel_p.cpp
   Library.cpp
+  LibraryCompilation_p.cpp
   LibrariesManager.cpp
 # Metadata
   MetadataLexer_p.cpp

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp	2009-03-26 10:04:30 UTC (rev 688)
@@ -189,3 +189,22 @@
 {
   return Library::d->m_moduleData->function( name(), "generated");
 }
+
+void Kernel::setHint( Hint _hint, const GTLCore::Value& _value)
+{
+  switch( _hint )
+  {
+    case IMAGE_WIDTH:
+    {
+      GTL_ASSERT( _value.type()->dataType() == GTLCore::Type::FLOAT );
+      d->m_imageWidthHint = _value;
+    }
+      break;
+    case IMAGE_HEIGHT:
+    {
+      GTL_ASSERT( _value.type()->dataType() == GTLCore::Type::FLOAT );
+      d->m_imageHeightHint = _value;
+    }
+      break;
+  }
+}

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.h	2009-03-26 10:04:30 UTC (rev 688)
@@ -70,6 +70,15 @@
       bool hasChangedFunction() const;
       GTLCore::Region generated();
       bool hasGeneratedFunction() const;
+    public:
+      enum Hint {
+        IMAGE_WIDTH,
+        IMAGE_HEIGHT
+      };
+      /**
+       * Set one of the hint.
+       */
+      void setHint( Hint _hint, const GTLCore::Value& _value);
     private:
       struct Private;
       Private * const d;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp	2009-03-26 10:04:30 UTC (rev 688)
@@ -33,10 +33,20 @@
 
 using namespace OpenShiva;
 
-Kernel::Private::Private()
+Kernel::Private::Private() : m_imageWidthHint(800), m_imageHeightHint(600)
 {
 }
 
+void Kernel::Private::preCompilation()
+{
+  self->setParameter( "IMAGE_WIDTH", m_imageWidthHint );
+  self->setParameter( "IMAGE_HEIGHT", m_imageHeightHint );
+  std::vector<GTLCore::Value> values;
+  values.push_back( m_imageWidthHint);
+  values.push_back( m_imageHeightHint);
+  self->setParameter( "IMAGE_SIZE", GTLCore::Value(values, GTLCore::TypesManager::getVector(GTLCore::Type::Float, 2) ) );
+}
+
 GTLCore::ModuleData* Kernel::Private::moduleData()
 {
   return self->Library::d->m_moduleData;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h	2009-03-26 10:04:30 UTC (rev 688)
@@ -22,7 +22,10 @@
 
 #include "Kernel.h"
 
+#include "GTLCore/Value.h"
+
 #include <list>
+#include "LibraryCompilation_p.h"
 
 namespace llvm {
   class Function;
@@ -34,10 +37,12 @@
 
 namespace OpenShiva {
   class Wrapper;
-  class Kernel::Private {
+  class Kernel::Private : public LibraryCompilation {
     friend class Kernel;
       Private();
     public:
+      virtual void preCompilation();
+    public:
       const std::list< const GTLCore::Type* >& inputsTypes();
       const GTLCore::Type* outputPixelType();
       const GTLCore::Type* outputImageType();
@@ -53,6 +58,8 @@
       std::list< const GTLCore::Type* > m_inputsTypes;
       const GTLCore::Type* m_outputPixelType;
       const GTLCore::Type* m_outputImageType;
+      GTLCore::Value m_imageWidthHint;
+      GTLCore::Value m_imageHeightHint;
   };
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2009-03-26 10:04:30 UTC (rev 688)
@@ -51,6 +51,7 @@
 
 
 #include "Kernel_p.h"
+#include "LibraryCompilation_p.h"
 
 using namespace OpenShiva;
 
@@ -147,6 +148,10 @@
 
 void Library::compile()
 {
+  if( d->libraryCompilation )
+  {
+    d->libraryCompilation->preCompilation();
+  }
   if(not d->source.metadata() )
   {
     d->compilationErrors = d->source.metadataCompilationErrors();

Added: trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.cpp	2009-03-26 10:04:30 UTC (rev 688)
@@ -0,0 +1,26 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * 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;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * 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; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "LibraryCompilation_p.h"
+
+using namespace OpenShiva;
+
+LibraryCompilation::LibraryCompilation() {}
+LibraryCompilation::~LibraryCompilation() {}
+


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.h	2009-03-26 10:04:30 UTC (rev 688)
@@ -0,0 +1,34 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * 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;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * 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; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _LIBRARY_COMPILATION_H_
+#define _LIBRARY_COMPILATION_H_
+
+namespace OpenShiva {
+  
+  class LibraryCompilation {
+    public:
+      LibraryCompilation();
+      virtual ~LibraryCompilation();
+      virtual void preCompilation() = 0;
+  };
+  
+};
+
+#endif


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/LibraryCompilation_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2009-03-26 09:43:16 UTC (rev 687)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2009-03-26 10:04:30 UTC (rev 688)
@@ -42,8 +42,9 @@
 }
 
 namespace OpenShiva {
+  class LibraryCompilation;
   struct Library::Private {
-    Private() : m_moduleData(0)
+    Private() : m_moduleData(0), libraryCompilation(0)
     {
     }
     void metadataToParameters( const GTLCore::Metadata::Group* );
@@ -59,6 +60,7 @@
     bool isStandardLibrary;
     std::map< GTLCore::String, GTLCore::Value > parameters;
     std::list<GTLCore::ErrorMessage> compilationErrors;
+    LibraryCompilation* libraryCompilation;
   };
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/