[opengtl-commits] [435] move private class of Kernel in a separate file |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 435
Author: cyrille
Date: 2008-10-09 13:09:16 +0200 (Thu, 09 Oct 2008)
Log Message:
-----------
move private class of Kernel in a separate file
determine the input/outputs of the evaluatePixel
Modified Paths:
--------------
trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
Added Paths:
-----------
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt 2008-10-09 11:06:34 UTC (rev 434)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt 2008-10-09 11:09:16 UTC (rev 435)
@@ -12,6 +12,7 @@
Wrapper_p.cpp
PixelVisitor_p.cpp
PixelConvertExpressionFactory_p.cpp
+ Kernel_p.cpp
# Wrap
wrappers/ImageWrap_p.cpp
wrappers/PixelWrap_p.cpp
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-10-09 11:06:34 UTC (rev 434)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-10-09 11:09:16 UTC (rev 435)
@@ -43,23 +43,13 @@
#include "wrappers/ImageWrap_p.h"
#include "wrappers/RegionWrap_p.h"
+#include "Kernel_p.h"
+
using namespace OpenShiva;
-struct Kernel::Private {
- GTLCore::String name;
- GTLCore::String source;
- bool enableHydraCompatibility;
- bool compiled;
- std::list<GTLCore::ErrorMessage> compilationErrors;
- llvm::ModuleProvider* moduleProvider;
- GTLCore::ModuleData* moduleData;
- llvm::Function* evaluatePixelesFunction;
- int count_channels_generic;
- Wrapper* wrapper;
-};
-
Kernel::Kernel(const GTLCore::String& _name, int _channelsNb ) : d(new Private )
{
+ d->self = this;
d->name = _name;
d->compiled = false;
d->enableHydraCompatibility = false;
@@ -140,6 +130,7 @@
// Create a wrapper
d->wrapper = new Wrapper(this, d->moduleData);
+ d->determineTypes();
// Create the generateEvaluatePixeles LLVM function
d->evaluatePixelesFunction = CodeGenerator::generateEvaluatePixeles( this, d->moduleData, d->count_channels_generic );
d->name = nameSpace;
Added: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp 2008-10-09 11:09:16 UTC (rev 435)
@@ -0,0 +1,72 @@
+/*
+ * 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;
+ * version 2 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 "Kernel_p.h"
+
+#include "GTLCore/Parameter.h"
+#include "GTLCore/ErrorMessage.h"
+#include "GTLCore/Function.h"
+#include "GTLCore/ModuleData_p.h"
+#include "GTLCore/Macros_p.h"
+#include "GTLCore/Type.h"
+
+#include "Debug.h"
+
+using namespace OpenShiva;
+
+Kernel::Private::Private()
+{
+}
+
+void Kernel::Private::determineTypes()
+{
+ m_inputsTypes.clear();
+ GTLCore::Function* ePFunction = moduleData->function( self->name(), "evaluatePixel" );
+ bool hasOutput = false;
+ foreach( GTLCore::Parameter arg, ePFunction->parameters() )
+ {
+ if( arg.output() )
+ {
+ SHIVA_ASSERT(not hasOutput );
+ hasOutput = true;
+ SHIVA_ASSERT( arg.type()->dataType() == GTLCore::Type::STRUCTURE );
+ SHIVA_ASSERT( arg.type()->structName().head( 5 ) == "pixel" );
+ } else {
+ SHIVA_ASSERT( arg.type()->dataType() == GTLCore::Type::STRUCTURE );
+ SHIVA_ASSERT( arg.type()->structName().head( 5 ) == "image" );
+ m_inputsTypes.push_back( arg.type() );
+ }
+ }
+ SHIVA_ASSERT( hasOutput );
+}
+
+const std::list< const GTLCore::Type* >& Kernel::Private::inputsTypes()
+{
+ return m_inputsTypes;
+}
+
+const GTLCore::Type* Kernel::Private::outputPixelType()
+{
+ return m_outputPixelType;
+}
+
+const GTLCore::Type* Kernel::Private::outputImageType()
+{
+ return m_outputImageType;
+}
Added: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.h 2008-10-09 11:09:16 UTC (rev 435)
@@ -0,0 +1,68 @@
+/*
+ * 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;
+ * version 2 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 _OPENSHIVA_KERNEL_P_H_
+#define _OPENSHIVA_KERNEL_P_H_
+
+#include "Kernel.h"
+
+#include <list>
+
+namespace llvm {
+ class ModuleProvider;
+ class Function;
+}
+
+namespace GTLCore {
+ class Type;
+}
+
+namespace OpenShiva {
+ class Wrapper;
+ class Kernel::Private {
+ friend class Kernel;
+ Private();
+ public:
+ const std::list< const GTLCore::Type* >& inputsTypes();
+ const GTLCore::Type* outputPixelType();
+ const GTLCore::Type* outputImageType();
+ private:
+ /**
+ * Determines output and input types.
+ */
+ void determineTypes();
+ Kernel* self;
+ GTLCore::String name;
+ GTLCore::String source;
+ bool enableHydraCompatibility;
+ bool compiled;
+ std::list<GTLCore::ErrorMessage> compilationErrors;
+ llvm::ModuleProvider* moduleProvider;
+ GTLCore::ModuleData* moduleData;
+ llvm::Function* evaluatePixelesFunction;
+ int count_channels_generic;
+ Wrapper* wrapper;
+ std::list< const GTLCore::Type* > m_inputsTypes;
+ const GTLCore::Type* m_outputPixelType;
+ const GTLCore::Type* m_outputImageType;
+
+ };
+}
+
+#endif