[opengtl-commits] [540] * TypeManager -> TypesManager, KernelMetadata -> Metadata |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 540
Author: cyrille
Date: 2008-12-12 18:54:03 +0100 (Fri, 12 Dec 2008)
Log Message:
-----------
* TypeManager -> TypesManager, KernelMetadata -> Metadata
* introduce a categorie manager, a collection of kernel
* install examples, make SunRay have parameters
* fix countless of bug in the metadaparser when passing badly formated metadata was leading to assertion
Modified Paths:
--------------
trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp
trunk/OpenGTL/OpenCTL/OpenCTL/Module.h
trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.h
trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.h
trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h
trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
trunk/OpenGTL/OpenGTL/GTLCore/Type.h
trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp
trunk/OpenGTL/OpenGTL/GTLGlue/InputNode.h
trunk/OpenGTL/OpenShiva/CMakeLists.txt
trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/LibrariesManager.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Library.h
trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h
trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
trunk/OpenGTL/OpenShiva/examples/SunRay.shiva
trunk/OpenGTL/OpenShiva/tests/library/TestMetadataLexer.h
trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
Added Paths:
-----------
trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.h
trunk/OpenGTL/OpenGTL/GTLCore/Category.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Category.h
trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.cpp
trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.h
trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.h
trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h
trunk/OpenGTL/OpenShiva/examples/CMakeLists.txt
Removed Paths:
-------------
trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp
trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h
trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.h
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -180,7 +180,7 @@
return d->moduleData;
}
-const GTLCore::TypeManager* Module::typeManager() const
+const GTLCore::TypesManager* Module::typesManager() const
{
- return d->moduleData->typeManager();
+ return d->moduleData->typesManager();
}
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Module.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Module.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Module.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -27,7 +27,7 @@
class ErrorMessage;
class Function;
class ModuleData;
- class TypeManager;
+ class TypesManager;
}
namespace OpenCTL {
@@ -95,7 +95,7 @@
* @return the type manager with the types defines and use by this module (this
* includes type that are defined by imported modules)
*/
- const GTLCore::TypeManager* typeManager() const;
+ const GTLCore::TypesManager* typesManager() const;
public:
/**
* @return the assembly source code, it's mostly usefull for testing purpose
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -283,9 +283,9 @@
return d->module;
}
-GTLCore::TypeManager* Compiler::typeManager()
+GTLCore::TypesManager* Compiler::typesManager()
{
- return d->moduleData->typeManager();
+ return d->moduleData->typesManager();
}
GTLCore::CodeGenerator* Compiler::codeGenerator()
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -38,7 +38,7 @@
class ErrorMessage;
class ScopedName;
class Type;
- class TypeManager;
+ class TypesManager;
}
#include <GTLCore/CompilerBase_p.h>
@@ -56,7 +56,7 @@
bool compile(const GTLCore::String& sourceCode, const GTLCore::String& moduleName, GTLCore::ModuleData* moduleData);
bool importModule(const GTLCore::String& name);
public:
- virtual GTLCore::TypeManager* typeManager();
+ virtual GTLCore::TypesManager* typesManager();
llvm::Module* module();
GTLCore::CodeGenerator* codeGenerator();
public:
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/ParserNG.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -40,7 +40,7 @@
#include "GTLCore/Token_p.h"
#include "GTLCore/Function_p.h"
-#include "GTLCore/TypeManager.h"
+#include "GTLCore/TypesManager.h"
#include "GTLCore/VariablesManager_p.h"
namespace AST = GTLCore::AST;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt 2008-12-12 17:54:03 UTC (rev 540)
@@ -9,13 +9,15 @@
set(GTLCore_SRCS
AbstractImage.cpp
- BufferImage.cpp
Array.cpp
- Image.cpp
Buffer.cpp
+ BufferImage.cpp
+ CategoriesManager.cpp
+ Category.cpp
Debug.cpp
ErrorMessage.cpp
Function.cpp
+ Image.cpp
Optimiser.cpp
Parameter.cpp
PixelDescription.cpp
@@ -24,7 +26,7 @@
ScopedName.cpp
String.cpp
Type.cpp
- TypeManager.cpp
+ TypesManager.cpp
Value.cpp
# Internal files
AST/AccessorExpression.cpp
@@ -53,7 +55,7 @@
ParserBase_p.cpp
Token_p.cpp
Type_p.cpp
- TypeManager_p.cpp
+ TypesManager_p.cpp
VariableNG_p.cpp
VariablesManager_p.cpp
VirtualMachine_p.cpp
@@ -83,7 +85,29 @@
# installation
install(TARGETS GTLCore DESTINATION ${LIB_INSTALL_DIR} )
-install( FILES Parameter.h Function.h Array.h Buffer.h ErrorMessage.h PixelDescription.h Region.h RegionF.h ScopedName.h String.h Type.h Value.h Version.h Macros.h AbstractImage.h BufferImage.h Image.h DESTINATION ${INCLUDE_INSTALL_DIR}/GTLCore )
+install( FILES
+ AbstractImage.h
+ Array.h
+ Buffer.h
+ BufferImage.h
+ CategoriesManager.h
+ Category.h
+ ErrorMessage.h
+ Function.h
+ Macros.h
+ Image.h
+ Parameter.h
+ PixelDescription.h
+ Region.h
+ RegionF.h
+ ScopedName.h
+ String.h
+ Type.h
+ TypesManager.h
+ Value.h
+ Version.h
+ DESTINATION ${INCLUDE_INSTALL_DIR}/GTLCore )
+
install( FILES Metadata/ParameterEntry.h Metadata/Entry.h Metadata/Group.h Metadata/TextEntry.h DESTINATION ${INCLUDE_INSTALL_DIR}/GTLCore/Metadata )
# Create and install pc file
Added: trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.cpp (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,73 @@
+/*
+ * 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 "CategoriesManager.h"
+
+#include <map>
+
+#include "Category.h"
+#include "String.h"
+
+using namespace GTLCore;
+
+struct CategoriesManager::Private {
+ mutable std::map< String, const Category*> str2cat;
+ static CategoriesManager* s_categoriesManager;
+};
+
+CategoriesManager* CategoriesManager::Private::s_categoriesManager = 0;
+
+CategoriesManager::CategoriesManager() : d(new Private)
+{
+}
+
+CategoriesManager::~CategoriesManager()
+{
+ delete d;
+}
+
+const CategoriesManager* CategoriesManager::instance()
+{
+ if( not Private::s_categoriesManager )
+ {
+ Private::s_categoriesManager = new CategoriesManager;
+ }
+ return Private::s_categoriesManager;
+}
+
+const Category* CategoriesManager::category( const GTLCore::String& _key ) const
+{
+ std::map< String, const Category*>::const_iterator it = d->str2cat.find( _key );
+ if( it != d->str2cat.end() )
+ {
+ return it->second;
+ }
+ return 0;
+}
+
+const Category* CategoriesManager::category( const GTLCore::String& _key, const GTLCore::String& _label, const GTLCore::String& _description ) const
+{
+ const Category* cat = category( _key );
+ if( not cat )
+ {
+ cat = new Category( _key, _label, _description );
+ d->str2cat[ _key ] = cat;
+ }
+ return cat;
+}
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.h (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,43 @@
+/*
+ * 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 _GTLCORE_CATEGORIES_MANAGER_H_
+#define _GTLCORE_CATEGORIES_MANAGER_H_
+
+namespace GTLCore {
+ class Category;
+ class String;
+ /**
+ * @ingroup GTLCore
+ * Manages the category.
+ */
+ class CategoriesManager {
+ CategoriesManager();
+ ~CategoriesManager();
+ public:
+ static const CategoriesManager* instance();
+ const Category* category( const GTLCore::String& _key ) const;
+ const Category* category( const GTLCore::String& _key, const GTLCore::String& _label, const GTLCore::String& _description ) const;
+ private:
+ struct Private;
+ Private* const d;
+ };
+}
+
+#endif
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/CategoriesManager.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/OpenGTL/OpenGTL/GTLCore/Category.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Category.cpp (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Category.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,53 @@
+/*
+ * 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 "Category.h"
+
+using namespace GTLCore;
+
+struct Category::Private {
+ String key, label, description;
+};
+
+Category::Category( const GTLCore::String& _key, const GTLCore::String& _label, const GTLCore::String& _description ) : d(new Private)
+{
+ d->key = _key;
+ d->label = _label;
+ d->description = _description;
+}
+
+Category::~Category()
+{
+ delete d;
+}
+
+const GTLCore::String& Category::key() const
+{
+ return d->key;
+}
+
+const GTLCore::String& Category::label() const
+{
+ return d->label;
+}
+
+const GTLCore::String& Category::description() const
+{
+ return d->description;
+}
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Category.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/OpenGTL/OpenGTL/GTLCore/Category.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Category.h (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Category.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,43 @@
+/*
+ * 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 _GTLCORE_CATEGORY_H_
+#define _GTLCORE_CATEGORY_H_
+
+#include <GTLCore/String.h>
+
+namespace GTLCore {
+ /**
+ * @ingroup GTLCore
+ */
+ class Category {
+ friend class CategoriesManager;
+ Category( const GTLCore::String& _key, const GTLCore::String& _label, const GTLCore::String& _description );
+ ~Category();
+ public:
+ const GTLCore::String& key() const;
+ const GTLCore::String& label() const;
+ const GTLCore::String& description() const;
+ private:
+ struct Private;
+ Private* const d;
+ };
+}
+
+#endif
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Category.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -35,7 +35,7 @@
#include "Value.h"
#include "VariableNG_p.h"
#include "ModuleData_p.h"
-#include "TypeManager_p.h"
+#include "TypesManager_p.h"
#include "AST/AccessorExpression.h"
#include "wrappers/ArrayWrap.h"
@@ -158,7 +158,7 @@
{
inits.push_back( _val );
}
- return llvm::ConstantVector::get( static_cast<const llvm::VectorType*>( GTLCore::TypeManager::getVector( _valType, _size)->d->type()), inits );
+ return llvm::ConstantVector::get( static_cast<const llvm::VectorType*>( GTLCore::TypesManager::getVector( _valType, _size)->d->type()), inits );
}
llvm::Value* CodeGenerator::convertPointerToCharP(llvm::BasicBlock* _currentBlock, llvm::Value* _value)
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -28,7 +28,7 @@
class ErrorMessage;
class Function;
class ScopedName;
- class TypeManager;
+ class TypesManager;
class Type;
class ModuleData;
namespace AST {
@@ -56,7 +56,7 @@
*
* @return the type manager used for compilation
*/
- virtual GTLCore::TypeManager* typeManager() = 0;
+ virtual GTLCore::TypesManager* typesManager() = 0;
/**
* @return the \ref ConvertCenter used for compilation
*/
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -20,17 +20,29 @@
#include "Group.h"
#include "Factory_p.h"
+#include "../Debug.h"
#include "../Macros_p.h"
+#include "TextEntry.h"
+
using namespace GTLCore::Metadata;
struct Group::Private {
std::list< const Entry* > entries;
+ GTLCore::String label;
};
Group::Group( const GTLCore::String& _name, const std::list< const Entry* >& _entries) : Entry( _name), d(new Private)
{
d->entries = _entries;
+ // Label
+ const Entry* labelEntry = entry( "label" );
+ if( labelEntry )
+ {
+ const TextEntry* v = labelEntry->asTextEntry();
+ GTL_ASSERT( v );
+ d->label = v->text();
+ }
}
Group::~Group()
@@ -46,6 +58,7 @@
{
foreach( const Entry* entry, d->entries )
{
+ GTL_ASSERT( entry );
if( entry->name() == _name )
{
return entry;
@@ -63,3 +76,8 @@
{
return this;
}
+
+const GTLCore::String& Group::label() const
+{
+ return d->label;
+}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -23,7 +23,7 @@
#include <GTLCore/Metadata/Entry.h>
namespace OpenShiva {
- class KernelMetadata;
+ class Metadata;
}
namespace GTLCore {
@@ -34,12 +34,13 @@
class Group : public Entry {
friend class Factory;
friend class ParameterEntry;
- friend class OpenShiva::KernelMetadata;
+ friend class OpenShiva::Metadata;
Group( const GTLCore::String& _name, const std::list< const Entry* >& _entries);
virtual ~Group();
public:
const Entry* entry( const GTLCore::String& _name ) const;
const std::list< const Entry* >& entries() const;
+ const GTLCore::String& label() const;
virtual const Group* asGroup() const;
private:
struct Private;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -22,7 +22,7 @@
#include "../Debug.h"
#include "../Value.h"
#include "../Type.h"
-#include "../TypeManager.h"
+#include "../TypesManager.h"
#include "TextEntry.h"
#include "ValueEntry.h"
@@ -58,11 +58,11 @@
d->widgetType = FloatWidget;
widgetTypeSet = true;
} else if( v->text() == "curve" ) {
- d->type = TypeManager::getArray( TypeManager::getVector( Type::Float, 2 ) );
+ d->type = TypesManager::getArray( TypesManager::getVector( Type::Float, 2 ) );
d->widgetType = CurveWidget;
widgetTypeSet = true;
} else if( v->text() == "rgb" ) {
- d->type = TypeManager::getVector( Type::Float, 3 );
+ d->type = TypesManager::getVector( Type::Float, 3 );
d->widgetType = RgbColorWidget;
widgetTypeSet = true;
}
@@ -140,13 +140,13 @@
} else if( d->type == Type::Float )
{
d->defaultValue.setFloat( 0.5 );
- } else if( d->type == TypeManager::getArray( TypeManager::getVector( Type::Float, 2 ) ) )
+ } else if( d->type == TypesManager::getArray( TypesManager::getVector( Type::Float, 2 ) ) )
{
std::vector< GTLCore::Value > v1; v1.push_back( 0.0f ); v1.push_back( 0.0f );
std::vector< GTLCore::Value > v2; v2.push_back( 1.0f ); v2.push_back( 1.0f );
std::vector< GTLCore::Value > v3; v3.push_back( v1 ); v3.push_back( v2 );
d->defaultValue.setArray( v3, d->type );
- } else if( d->type == TypeManager::getVector( Type::Float, 3 ) )
+ } else if( d->type == TypesManager::getVector( Type::Float, 3 ) )
{
std::vector< GTLCore::Value > v1; v1.push_back( 0.0f ); v1.push_back( 0.0f ); v1.push_back( 0.0f );
d->defaultValue.setArray( v1, d->type );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -23,7 +23,7 @@
#include "Debug.h"
#include "GTLCore/Function.h"
-#include "TypeManager.h"
+#include "TypesManager.h"
#include "Macros_p.h"
#include "Optimiser_p.h"
@@ -39,7 +39,7 @@
using namespace GTLCore;
-ModuleData::ModuleData( llvm::Module* llvmModule) : m_llvmModule(llvmModule), m_llvmLinkedModule(0), m_typeManager(new TypeManager)
+ModuleData::ModuleData( llvm::Module* llvmModule) : m_llvmModule(llvmModule), m_llvmLinkedModule(0), m_typesManager(new TypesManager)
{
}
@@ -52,7 +52,7 @@
delete it->second;
}
delete m_llvmModule;
- delete m_typeManager;
+ delete m_typesManager;
}
bool ModuleData::appendFunction(const ScopedName& name, Function* function)
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -31,7 +31,7 @@
namespace GTLCore {
class Function;
- class TypeManager;
+ class TypesManager;
/**
* @internal
* This class is not part of the public API of GTLCore.
@@ -56,13 +56,13 @@
const llvm::Module* llvmModule() const { return m_llvmModule; }
llvm::Module* llvmLinkedModule() { return m_llvmLinkedModule; }
const llvm::Module* llvmLinkedModule() const { return m_llvmLinkedModule; }
- TypeManager* typeManager() { return m_typeManager; }
- const TypeManager* typeManager() const { return m_typeManager; }
+ TypesManager* typesManager() { return m_typesManager; }
+ const TypesManager* typesManager() const { return m_typesManager; }
private:
llvm::Module* m_llvmModule;
llvm::Module* m_llvmLinkedModule;
std::map<ScopedName, Function*> m_functions;
- TypeManager* m_typeManager;
+ TypesManager* m_typesManager;
std::map< ScopedName, llvm::Constant* > m_constants;
std::list< const llvm::Module* > m_linkModuleWith;
};
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -49,8 +49,8 @@
#include "Utils_p.h"
#include "VariablesManager_p.h"
-#include "TypeManager.h"
-#include "TypeManager_p.h"
+#include "TypesManager.h"
+#include "TypesManager_p.h"
using namespace GTLCore;
@@ -96,7 +96,7 @@
std::list<int> memberArraySize = expressionsListToIntegersList( parseArraySize(true) );
if( d->compiler) // This is needed for the Parser's test
{
- type = d->compiler->typeManager()->getArray( type, memberArraySize.size() );
+ type = d->compiler->typesManager()->getArray( type, memberArraySize.size() );
}
// Check that there is an initialiser
if( isOfType( currentToken(), GTLCore::Token::EQUAL ) )
@@ -152,7 +152,7 @@
{
String name = d->currentToken.string;
getNextToken();
- if( d->compiler->typeManager()->d->isKnownType( name ) )
+ if( d->compiler->typesManager()->d->isKnownType( name ) )
{ // It has allready been declared
reportError( name + " has allready been declared", d->currentToken);
} else {
@@ -172,7 +172,7 @@
getNextToken();
// Check if it's an array
std::list<int> memberArraySize = expressionsListToIntegersList( parseArraySize(true) );
- smtype = d->compiler->typeManager()->getArray( smtype, memberArraySize.size() );
+ smtype = d->compiler->typesManager()->getArray( smtype, memberArraySize.size() );
// Check if expression end by a SEMI and add the struct member
if( isOfType( d->currentToken, Token::SEMI ) )
{
@@ -197,7 +197,7 @@
if( isOfType( d->currentToken, Token::SEMI ) )
{
getNextToken();
- d->compiler->typeManager()->d->createStructure( name, members);
+ d->compiler->typesManager()->d->createStructure( name, members);
}
}
}
@@ -823,7 +823,7 @@
getNextToken();
AST::Expression* initialiser = 0;
std::list<AST::Expression*> memberArraySize = parseArraySize(true);
- ptype = d->compiler->typeManager()->getArray( ptype, memberArraySize.size() );
+ ptype = d->compiler->typesManager()->getArray( ptype, memberArraySize.size() );
deleteAll( memberArraySize);
if( d->currentToken.type == Token::EQUAL )
{
@@ -1148,7 +1148,7 @@
{
getNextToken();
std::list<AST::Expression*> initialsize = parseArraySize(false);
- type = d->compiler->typeManager()->getArray( type, initialsize.size() );
+ type = d->compiler->typesManager()->getArray( type, initialsize.size() );
bool initialised = false;
AST::Expression* initialiser = 0;
if( d->currentToken.type == Token::EQUAL )
@@ -1219,7 +1219,7 @@
if( not type ) return 0;
std::list< AST::Expression* > sizes = parseArraySize(true);
deleteAll( sizes );
- return d->compiler->typeManager()->getArray( type, sizes.size() );
+ return d->compiler->typesManager()->getArray( type, sizes.size() );
}
}
@@ -1248,7 +1248,7 @@
}
case Token::IDENTIFIER:
{
- const Type* type = d->compiler->typeManager()->getStructure( d->currentToken.string );
+ const Type* type = d->compiler->typesManager()->getStructure( d->currentToken.string );
if( not type )
{
reportError("Unknown type : " + d->currentToken.string, d->currentToken );
@@ -1582,7 +1582,7 @@
bool ParserBase::isType( const Token& token )
{
- return token.isNativeType() or ( token.type == Token::IDENTIFIER and d->compiler->typeManager()->d->isKnownType( token.string ) );
+ return token.isNativeType() or ( token.type == Token::IDENTIFIER and d->compiler->typesManager()->d->isKnownType( token.string ) );
}
std::list<int> ParserBase::expressionsListToIntegersList( const std::list< AST::Expression* >& list )
@@ -1621,9 +1621,9 @@
return d->nameSpace;
}
-TypeManager* ParserBase::typeManager()
+TypesManager* ParserBase::typesManager()
{
- return d->compiler->typeManager();
+ return d->compiler->typesManager();
}
VariablesManager* ParserBase::variablesManager()
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -35,7 +35,7 @@
class CompilerBase;
class LexerBase;
class Parameter;
- class TypeManager;
+ class TypesManager;
class VariablesManager;
namespace AST {
class Tree;
@@ -167,7 +167,7 @@
// Context
std::list<int> expressionsListToIntegersList( const std::list< AST::Expression* >& );
void setNameSpace( const String& nameSpace );
- TypeManager* typeManager();
+ TypesManager* typesManager();
VariablesManager* variablesManager();
protected: // Events
virtual void startParsingFunction( const GTLCore::String& _name );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -26,7 +26,7 @@
#include <vector>
#if __GNUC__ == 3 && (__GNUC_MINOR__ <= 3 && __GNUC_MINOR__ <= 3)
-#include <GTLCore/TypeManager.h>
+#include <GTLCore/TypesManager.h>
#endif
@@ -69,9 +69,9 @@
friend class OpenShiva::Wrapper;
friend class ParserBase;
friend class Function;
- friend class TypeManager;
+ friend class TypesManager;
#if __GNUC__ == 3 && (__GNUC_MINOR__ <= 3 && __GNUC_MINOR__ <= 3)
- friend struct TypeManager::Private;
+ friend struct TypesManager::Private;
#endif
friend class Visitor;
friend class VectorVisitor;
Deleted: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,88 +0,0 @@
-/*
- * 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 "TypeManager.h"
-
-#include "Debug.h"
-#include "TypeManager_p.h"
-
-using namespace GTLCore;
-
-std::map< const GTLCore::Type*, const GTLCore::Type*> TypeManager::Private::knownArrays;
-std::map< const GTLCore::Type*, std::map< int, const GTLCore::Type* > > TypeManager::Private::knownVectors;
-
-TypeManager::TypeManager() : d(new Private)
-{
-}
-
-TypeManager::~TypeManager()
-{
- for( std::map< GTLCore::String, const GTLCore::Type*>::iterator it = d->knownTypes.begin(); it != d->knownTypes.end(); ++it)
- {
- delete it->second;
- }
- delete d;
-}
-
-const GTLCore::Type* TypeManager::getStructure( const GTLCore::String& _name) const
-{
- std::map< GTLCore::String, const GTLCore::Type*>::const_iterator it = d->knownTypes.find(_name);
- if( it == d->knownTypes.end())
- {
- return 0;
- }
- return it->second;
-}
-
-const GTLCore::Type* TypeManager::getArray( const GTLCore::Type* _type)
-{
- GTL_ASSERT( _type );
- std::map< const GTLCore::Type*, const GTLCore::Type*>::const_iterator it = TypeManager::Private::knownArrays.find( _type );
- if( it == TypeManager::Private::knownArrays.end())
- {
- GTLCore::Type* at = new GTLCore::Type( _type );
- TypeManager::Private::knownArrays[ _type] = at;
- return at;
- }
- return it->second;
-}
-
-const GTLCore::Type* TypeManager::getArray( const GTLCore::Type* _type, int _levelsCount)
-{
- GTL_ASSERT( _type );
- const GTLCore::Type* type = _type;
- for(int i = 0; i < _levelsCount; ++i )
- {
- type = getArray( type );
- }
- return type;
-}
-
-const GTLCore::Type* TypeManager::getVector( const GTLCore::Type* _type, int _size )
-{
- GTL_ASSERT( _type );
- std::map< const GTLCore::Type*, std::map< int, const GTLCore::Type* > >::const_iterator it
- = TypeManager::Private::knownVectors.find( _type );
- const GTLCore::Type*& type = TypeManager::Private::knownVectors[ _type ][ _size ];
- if( type == 0 )
- {
- type = new GTLCore::Type( _size, _type );
- }
- return type;
-}
Deleted: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,75 +0,0 @@
-/*
- * 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 _OPENCTL_TYPE_MANAGER_H_
-#define _OPENCTL_TYPE_MANAGER_H_
-
-#include <GTLCore/String.h>
-
-namespace OpenShiva {
- class Wrapper;
-}
-
-namespace GTLCore {
- class Type;
- /**
- * This class gives access to all types used by a module.
- * @ingroup GTLCore
- */
- class TypeManager {
- friend class ParserBase;
- friend class OpenShiva::Wrapper;
-#if __GNUC__ == 3 && (__GNUC_MINOR__ <= 3 && __GNUC_MINOR__ <= 3)
- friend class Type;
-#endif
- public:
- TypeManager();
- ~TypeManager();
- const GTLCore::Type* getStructure( const GTLCore::String& name) const;
- /**
- * @param type the type of the elements in the array
- * @return the array type
- */
- static const GTLCore::Type* getArray( const GTLCore::Type* type);
- /**
- * Create an array of array.
- * @param _type the base type of an array
- * @param _levelsCount the number of level of the array (if _levelsCount == 0,
- * then _type is returned);
- *
- * @code
- * getArray( GTLCore::Type::Integer32, 0 ) == GTLCore::Type::Integer32;
- * getArray( GTLCore::Type::Integer32, 1 ) == getArray( GTLCore::Type::Integer32 );
- * getArray( GTLCore::Type::Integer32, 2 ) == getArray( getArray( GTLCore::Type::Integer32 );
- * @endcode
- */
- static const GTLCore::Type* getArray( const GTLCore::Type* _type, int _levelsCount);
- /**
- * @param _type the type of the elements of the vector
- * @param _size number of elements of the vector
- * @return the vector type that contains \a _type
- */
- static const GTLCore::Type* getVector( const GTLCore::Type* _type, int _size );
- private:
- struct Private;
- Private* const d;
- };
-}
-
-#endif
Deleted: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,43 +0,0 @@
-/*
- * 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 "TypeManager_p.h"
-
-#include "Debug.h"
-
-using namespace GTLCore;
-
-bool TypeManager::Private::isKnownType(const GTLCore::String& _name) const
-{
- return knownTypes.find(_name) != knownTypes.end();
-}
-
-const GTLCore::Type* TypeManager::Private::createStructure( const GTLCore::String& _name, const std::vector<GTLCore::Type::StructDataMember>& _members)
-{
- GTL_DEBUG("createStructure " << _name);
- if(isKnownType( _name) )
- {
- GTL_DEBUG("Allready exist");
- return 0;
- }
- GTLCore::Type* t = new GTLCore::Type( _name, _members);
- knownTypes[ _name ] = t;
- GTL_ASSERT(isKnownType( _name) );
- return t;
-}
Deleted: trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,48 +0,0 @@
-/*
- * 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 _GTLCORE_TYPEMANAGER_P_H
-#define _GTLCORE_TYPEMANAGER_P_H
-
-#include "GTLCore/TypeManager.h"
-#include "GTLCore/Type.h"
-
-#include <map>
-
-namespace GTLCore {
- /**
- * @internal
- *
- * @ingroup GTLCore
- */
- struct TypeManager::Private {
- std::map< GTLCore::String, const GTLCore::Type*> knownTypes;
- static std::map< const GTLCore::Type*, const GTLCore::Type*> knownArrays;
- static std::map< const GTLCore::Type*, std::map< int, const GTLCore::Type* > > knownVectors;
- /**
- * @param name the name of the type
- * @return true if the name given as argument is the name of a known type
- * for this manager
- */
- bool isKnownType(const GTLCore::String& name) const;
- const GTLCore::Type* createStructure( const GTLCore::String& name, const std::vector<GTLCore::Type::StructDataMember>& members);
- };
-}
-
-#endif
Copied: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.cpp (from rev 500, trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.cpp)
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.cpp (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,88 @@
+/*
+ * 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 "TypesManager.h"
+
+#include "Debug.h"
+#include "TypesManager_p.h"
+
+using namespace GTLCore;
+
+std::map< const GTLCore::Type*, const GTLCore::Type*> TypesManager::Private::knownArrays;
+std::map< const GTLCore::Type*, std::map< int, const GTLCore::Type* > > TypesManager::Private::knownVectors;
+
+TypesManager::TypesManager() : d(new Private)
+{
+}
+
+TypesManager::~TypesManager()
+{
+ for( std::map< GTLCore::String, const GTLCore::Type*>::iterator it = d->knownTypes.begin(); it != d->knownTypes.end(); ++it)
+ {
+ delete it->second;
+ }
+ delete d;
+}
+
+const GTLCore::Type* TypesManager::getStructure( const GTLCore::String& _name) const
+{
+ std::map< GTLCore::String, const GTLCore::Type*>::const_iterator it = d->knownTypes.find(_name);
+ if( it == d->knownTypes.end())
+ {
+ return 0;
+ }
+ return it->second;
+}
+
+const GTLCore::Type* TypesManager::getArray( const GTLCore::Type* _type)
+{
+ GTL_ASSERT( _type );
+ std::map< const GTLCore::Type*, const GTLCore::Type*>::const_iterator it = TypesManager::Private::knownArrays.find( _type );
+ if( it == TypesManager::Private::knownArrays.end())
+ {
+ GTLCore::Type* at = new GTLCore::Type( _type );
+ TypesManager::Private::knownArrays[ _type] = at;
+ return at;
+ }
+ return it->second;
+}
+
+const GTLCore::Type* TypesManager::getArray( const GTLCore::Type* _type, int _levelsCount)
+{
+ GTL_ASSERT( _type );
+ const GTLCore::Type* type = _type;
+ for(int i = 0; i < _levelsCount; ++i )
+ {
+ type = getArray( type );
+ }
+ return type;
+}
+
+const GTLCore::Type* TypesManager::getVector( const GTLCore::Type* _type, int _size )
+{
+ GTL_ASSERT( _type );
+ std::map< const GTLCore::Type*, std::map< int, const GTLCore::Type* > >::const_iterator it
+ = TypesManager::Private::knownVectors.find( _type );
+ const GTLCore::Type*& type = TypesManager::Private::knownVectors[ _type ][ _size ];
+ if( type == 0 )
+ {
+ type = new GTLCore::Type( _size, _type );
+ }
+ return type;
+}
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.cpp
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.h (from rev 500, trunk/OpenGTL/OpenGTL/GTLCore/TypeManager.h)
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.h (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,75 @@
+/*
+ * 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 _OPENCTL_TYPE_MANAGER_H_
+#define _OPENCTL_TYPE_MANAGER_H_
+
+#include <GTLCore/String.h>
+
+namespace OpenShiva {
+ class Wrapper;
+}
+
+namespace GTLCore {
+ class Type;
+ /**
+ * This class gives access to all types used by a module.
+ * @ingroup GTLCore
+ */
+ class TypesManager {
+ friend class ParserBase;
+ friend class OpenShiva::Wrapper;
+#if __GNUC__ == 3 && (__GNUC_MINOR__ <= 3 && __GNUC_MINOR__ <= 3)
+ friend class Type;
+#endif
+ public:
+ TypesManager();
+ ~TypesManager();
+ const GTLCore::Type* getStructure( const GTLCore::String& name) const;
+ /**
+ * @param type the type of the elements in the array
+ * @return the array type
+ */
+ static const GTLCore::Type* getArray( const GTLCore::Type* type);
+ /**
+ * Create an array of array.
+ * @param _type the base type of an array
+ * @param _levelsCount the number of level of the array (if _levelsCount == 0,
+ * then _type is returned);
+ *
+ * @code
+ * getArray( GTLCore::Type::Integer32, 0 ) == GTLCore::Type::Integer32;
+ * getArray( GTLCore::Type::Integer32, 1 ) == getArray( GTLCore::Type::Integer32 );
+ * getArray( GTLCore::Type::Integer32, 2 ) == getArray( getArray( GTLCore::Type::Integer32 );
+ * @endcode
+ */
+ static const GTLCore::Type* getArray( const GTLCore::Type* _type, int _levelsCount);
+ /**
+ * @param _type the type of the elements of the vector
+ * @param _size number of elements of the vector
+ * @return the vector type that contains \a _type
+ */
+ static const GTLCore::Type* getVector( const GTLCore::Type* _type, int _size );
+ private:
+ struct Private;
+ Private* const d;
+ };
+}
+
+#endif
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager.h
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.cpp (from rev 500, trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.cpp)
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.cpp (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,43 @@
+/*
+ * 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 "TypesManager_p.h"
+
+#include "Debug.h"
+
+using namespace GTLCore;
+
+bool TypesManager::Private::isKnownType(const GTLCore::String& _name) const
+{
+ return knownTypes.find(_name) != knownTypes.end();
+}
+
+const GTLCore::Type* TypesManager::Private::createStructure( const GTLCore::String& _name, const std::vector<GTLCore::Type::StructDataMember>& _members)
+{
+ GTL_DEBUG("createStructure " << _name);
+ if(isKnownType( _name) )
+ {
+ GTL_DEBUG("Allready exist");
+ return 0;
+ }
+ GTLCore::Type* t = new GTLCore::Type( _name, _members);
+ knownTypes[ _name ] = t;
+ GTL_ASSERT(isKnownType( _name) );
+ return t;
+}
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Copied: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.h (from rev 500, trunk/OpenGTL/OpenGTL/GTLCore/TypeManager_p.h)
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.h (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,48 @@
+/*
+ * 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 _GTLCORE_TYPESMANAGER_P_H
+#define _GTLCORE_TYPESMANAGER_P_H
+
+#include "GTLCore/TypesManager.h"
+#include "GTLCore/Type.h"
+
+#include <map>
+
+namespace GTLCore {
+ /**
+ * @internal
+ *
+ * @ingroup GTLCore
+ */
+ struct TypesManager::Private {
+ std::map< GTLCore::String, const GTLCore::Type*> knownTypes;
+ static std::map< const GTLCore::Type*, const GTLCore::Type*> knownArrays;
+ static std::map< const GTLCore::Type*, std::map< int, const GTLCore::Type* > > knownVectors;
+ /**
+ * @param name the name of the type
+ * @return true if the name given as argument is the name of a known type
+ * for this manager
+ */
+ bool isKnownType(const GTLCore::String& name) const;
+ const GTLCore::Type* createStructure( const GTLCore::String& name, const std::vector<GTLCore::Type::StructDataMember>& members);
+ };
+}
+
+#endif
Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/TypesManager_p.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Value.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -21,7 +21,7 @@
#include "Debug.h"
#include "Type.h"
-#include "TypeManager_p.h"
+#include "TypesManager_p.h"
using namespace GTLCore;
@@ -80,7 +80,7 @@
{
d->type = _type;
} else {
- d->type = TypeManager::getArray( v[0].type() );
+ d->type = TypesManager::getArray( v[0].type() );
}
}
@@ -216,6 +216,6 @@
{
d->type = _type;
} else {
- d->type = TypeManager::getArray( _array[0].type() );
+ d->type = TypesManager::getArray( _array[0].type() );
}
}
Modified: trunk/OpenGTL/OpenGTL/GTLGlue/InputNode.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLGlue/InputNode.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenGTL/GTLGlue/InputNode.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -20,6 +20,10 @@
#ifndef _GTLGlue_INPUT_NODE_H_
#define _GTLGlue_INPUT_NODE_H_
+namespace GTLCore {
+ class PixelDescription;
+}
+
namespace GTLGlue {
class NodeData;
class OutputNode;
@@ -31,7 +35,7 @@
friend class ProcessingNode;
friend class DestinationNode;
private:
- InputNode();
+ InputNode( const GTLCore::PixelDescription& _outputBuffer );
~InputNode();
public:
/**
Modified: trunk/OpenGTL/OpenShiva/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/CMakeLists.txt 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/CMakeLists.txt 2008-12-12 17:54:03 UTC (rev 540)
@@ -12,3 +12,4 @@
add_subdirectory(OpenShiva)
add_subdirectory(tools)
add_subdirectory(tests)
+add_subdirectory(examples)
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt 2008-12-12 17:54:03 UTC (rev 540)
@@ -15,10 +15,11 @@
Kernel_p.cpp
Library.cpp
LibrariesManager.cpp
+ KernelsCollection.cpp
# Metadata
MetadataLexer_p.cpp
MetadataParser_p.cpp
- KernelMetadata.cpp
+ Metadata.cpp
# Wrap
wrappers/ImageWrap_p.cpp
wrappers/PixelWrap_p.cpp
@@ -35,7 +36,8 @@
add_definitions( -D_OPENSHIVA_LIB_INSTALL_="${CMAKE_INSTALL_PREFIX}/lib/")
add_definitions( -D_OPENSHIVA_SHIVA_STD_LIB_SRC_DIR_="${CMAKE_CURRENT_SOURCE_DIR}")
-add_definitions( -D_OPENSHIVA_SHIVA_SHARE_DIR_="${SHARE_INSTALL_DIR}/shiva" )
+add_definitions( -D_OPENSHIVA_SHIVA_LIBRARIES_DIR_="${SHARE_INSTALL_DIR}/shiva/libraries" )
+add_definitions( -D_OPENSHIVA_SHIVA_KERNELS_DIR_="${SHARE_INSTALL_DIR}/shiva/kernels" )
# Set the ABI version of the library
@@ -43,7 +45,7 @@
# Install target
install(TARGETS OpenShiva DESTINATION ${LIB_INSTALL_DIR} )
-install( FILES Kernel.h KernelMetadata.h Library.h LibrariesManager.h Version.h DESTINATION ${INCLUDE_INSTALL_DIR}/OpenShiva )
+install( FILES Kernel.h Metadata.h Library.h LibrariesManager.h Version.h DESTINATION ${INCLUDE_INSTALL_DIR}/OpenShiva )
# Create and install pc file
configure_file("OpenShiva.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/OpenShiva.pc" @ONLY)
@@ -51,4 +53,4 @@
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenShiva.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
# Install standard library
-install(FILES shivastdlib.shiva DESTINATION ${SHARE_INSTALL_DIR}/shiva )
+install(FILES shivastdlib.shiva DESTINATION ${SHARE_INSTALL_DIR}/shiva/libraries )
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -39,7 +39,7 @@
#include "GTLCore/Parameter.h"
#include "GTLCore/PixelDescription.h"
#include "GTLCore/Type.h"
-#include "GTLCore/TypeManager_p.h"
+#include "GTLCore/TypesManager_p.h"
#include "GTLCore/Value.h"
#include "GTLCore/VariableNG_p.h"
@@ -340,7 +340,7 @@
GTLCore::CodeGenerator codeGenerator( _moduleData );
llvm::Function* func = codeGenerator.createFunction(
- Wrapper::image_wrap_mem_to_vec_float_type( _moduleData->typeManager(), _pixelDescription.channels()) ,
+ Wrapper::image_wrap_mem_to_vec_float_type( _moduleData->typesManager(), _pixelDescription.channels()) ,
"image_wrap_memToVec" + GTLCore::String::number( ++memToVecId) );
// Initialise a generation context
GTLCore::GenerationContext generationContext( &codeGenerator, func, 0, _moduleData );
@@ -458,7 +458,7 @@
GTLCore::CodeGenerator codeGenerator( _moduleData );
llvm::Function* func = codeGenerator.createFunction(
- Wrapper::image_wrap_vec_float_to_mem_type( _moduleData->typeManager(), _pixelDescription.channels()) ,
+ Wrapper::image_wrap_vec_float_to_mem_type( _moduleData->typesManager(), _pixelDescription.channels()) ,
"image_wrap_vecToMem" + GTLCore::String::number( ++vecToMemId) );
// Initialise a generation context
GTLCore::GenerationContext generationContext( &codeGenerator, func, 0, _moduleData );
@@ -588,7 +588,7 @@
GTLCore::CodeGenerator codeGenerator( _moduleData );
llvm::Function* func = codeGenerator.createFunction(
- Wrapper::image_wrap_sample_nearest_type( _moduleData->typeManager(), _imageType, _pixelType),
+ Wrapper::image_wrap_sample_nearest_type( _moduleData->typesManager(), _imageType, _pixelType),
"image_wrap_sample_nearest" + GTLCore::String::number( ++imageSampleNearestId) );
GTLCore::GenerationContext generationContext( &codeGenerator, func, 0, _moduleData );
// Get the args.
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -191,9 +191,9 @@
return library;
}
-GTLCore::TypeManager* Compiler::typeManager()
+GTLCore::TypesManager* Compiler::typesManager()
{
- return d->moduleData->typeManager();
+ return d->moduleData->typesManager();
}
GTLCore::AST::Expression* Compiler::standardConstant( const GTLCore::String& _name )
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Compiler_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -41,7 +41,7 @@
~Compiler();
bool compile(bool _loadStdLibrary, const GTLCore::String& _sourceCode, const GTLCore::String& _kernelName, GTLCore::ModuleData* _moduleData, GTLCore::String& _nameSpace, const std::map< GTLCore::String, GTLCore::Value >& parameters );
bool importModule(const GTLCore::String& name);
- virtual GTLCore::TypeManager* typeManager();
+ virtual GTLCore::TypesManager* typesManager();
bool isKernel() const;
const std::map< GTLCore::String, GTLCore::Value >& parameters() const;
public:
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -31,7 +31,7 @@
#include "GTLCore/PixelDescription.h"
#include "GTLCore/Region.h"
#include "GTLCore/Type.h"
-#include "GTLCore/TypeManager.h"
+#include "GTLCore/TypesManager.h"
#include "GTLCore/Value.h"
#include "GTLCore/VirtualMachine_p.h"
#include "GTLCore/wrappers/Allocate.h"
Deleted: trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,86 +0,0 @@
-/*
- * 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 "KernelMetadata.h"
-
-#include "GTLCore/Value.h"
-#include "GTLCore/Metadata/ValueEntry.h"
-
-#include "Debug.h"
-#include "Version.h"
-
-using namespace OpenShiva;
-using namespace GTLCore::Metadata;
-
-struct KernelMetadata::Private {
- int version;
- const Group* infoList;
- const Group* parametersList;
-};
-
-inline std::list<const Entry*> createList( const Entry* _version, const Group* _infoList, const Group* _parametersList )
-{
- std::list<const Entry*> list;
- if( _version )
- {
- list.push_back( _version );
- }
- if( _infoList )
- {
- list.push_back( _infoList );
- }
- if( _parametersList )
- {
- list.push_back( _parametersList );
- }
- return list;
-}
-
-KernelMetadata::KernelMetadata( const Entry* _version, const Group* _infoList, const Group* _parametersList ) : Group( "Kernel", createList( _version, _infoList, _parametersList ) ), d(new Private)
-{
- d->version = LanguageVersion;
- if( _version )
- {
- const ValueEntry* te = _version->asValueEntry();
- SHIVA_ASSERT( te );
- d->version = te->value().asInt32();
- }
- d->infoList = _infoList;
- d->parametersList = _parametersList;
-}
-
-KernelMetadata::~KernelMetadata()
-{
- delete d;
-}
-
-int KernelMetadata::version() const
-{
- return d->version;
-}
-const Group* KernelMetadata::infos() const
-{
- return d->infoList;
-}
-
-const Group* KernelMetadata::parameters() const
-{
- return d->parametersList;
-}
-
Deleted: trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,45 +0,0 @@
-/*
- * 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 _OPENSHIVA_KERNEL_METADATA_H_
-#define _OPENSHIVA_KERNEL_METADATA_H_
-
-#include <GTLCore/Metadata/Group.h>
-
-namespace OpenShiva {
- namespace Metadata {
- class Parser;
- }
- class KernelMetadata : public GTLCore::Metadata::Group {
- friend class Metadata::Parser;
- friend class Kernel;
- KernelMetadata( const GTLCore::Metadata::Entry* _version, const GTLCore::Metadata::Group* _infoList, const GTLCore::Metadata::Group* _parametersList );
- ~KernelMetadata();
- public:
- int version() const;
- const GTLCore::Metadata::Group* infos() const;
- const GTLCore::Metadata::Group* parameters() const;
- private:
- struct Private;
- Private* const d;
- };
-}
-
-#endif
-
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -25,7 +25,7 @@
#include "GTLCore/ModuleData_p.h"
#include "GTLCore/Macros_p.h"
#include "GTLCore/Type.h"
-#include "GTLCore/TypeManager.h"
+#include "GTLCore/TypesManager.h"
#include "Debug.h"
@@ -58,9 +58,9 @@
SHIVA_ASSERT( m_outputPixelType->structName().head( 5 ) == "pixel" );
if( m_outputPixelType->structName() == "pixel" )
{
- m_outputImageType = self->Library::d->m_moduleData->typeManager()->getStructure( "image" );
+ m_outputImageType = self->Library::d->m_moduleData->typesManager()->getStructure( "image" );
} else {
- m_outputImageType = self->Library::d->m_moduleData->typeManager()->getStructure( "image" + m_outputPixelType->structName().tail(1) );
+ m_outputImageType = self->Library::d->m_moduleData->typesManager()->getStructure( "image" + m_outputPixelType->structName().tail(1) );
}
GTL_ASSERT( m_outputImageType );
} else {
Added: trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.cpp (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,82 @@
+/*
+ * 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 "KernelsCollection.h"
+
+// LLVM
+#include <llvm/System/Path.h>
+
+#include "GTLCore/String.h"
+#include "GTLCore/Macros_p.h"
+#include "GTLCore/Utils_p.h"
+
+#include "Kernel.h"
+
+using namespace OpenShiva;
+
+struct KernelsCollection::Private {
+ std::list< Kernel* > kernels;
+ int channelsNb;
+ void addDirectory( const llvm::sys::Path& path );
+};
+
+
+void KernelsCollection::Private::addDirectory( const llvm::sys::Path& path )
+{
+ std::set< llvm::sys::Path > content;
+ path.getDirectoryContents( content, 0 );
+ foreach( const llvm::sys::Path& path, content )
+ {
+ if( GTLCore::String( path.getSuffix() ).toLower() == "shiva" )
+ {
+ Kernel* kernel = new Kernel( channelsNb );
+ kernels.push_back( kernel );
+ }
+ }
+}
+
+KernelsCollection::KernelsCollection(int _channelsNb ) : d(new Private)
+{
+ addDirectory( _OPENSHIVA_SHIVA_KERNELS_DIR_ );
+ d->channelsNb = _channelsNb;
+ d->addDirectory( llvm::sys::Path::GetUserHomeDirectory() );
+}
+
+KernelsCollection::~KernelsCollection()
+{
+ GTLCore::deleteAll( d->kernels );
+ delete d;
+}
+
+void KernelsCollection::addDirectory(const GTLCore::String& directory)
+{
+ d->addDirectory( llvm::sys::Path( directory ) );
+}
+
+void KernelsCollection::registerKernel( Kernel* kernel )
+{
+ d->kernels.push_back( kernel );
+}
+
+const std::list< Kernel* >& KernelsCollection::kernels() const
+{
+ return d->kernels;
+}
+
+
Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.h (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,62 @@
+/*
+ * 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 _OPENSHIVA_KERNELS_COLLECTION_H_
+#define _OPENSHIVA_KERNELS_COLLECTION_H_
+
+#include <list>
+
+namespace GTLCore {
+ class String;
+}
+
+namespace OpenShiva {
+ class Kernel;
+ /**
+ * @ingroup OpenShiva
+ *
+ * This class allows to access to the list of kernels installed in the system.
+ *
+ * The collection will look for .shiva files in:
+ * ${PREFIX}/share/OpenGTL/shiva/kernels
+ * ${HOME}/.OpenGTL/shiva/kernels
+ */
+ class KernelsCollection {
+ public:
+ KernelsCollection( int _channelsNb );
+ ~KernelsCollection();
+ /**
+ * Add custom directories
+ */
+ void addDirectory(const GTLCore::String& directory);
+ /**
+ * Manually register a Kernel in the collection.
+ */
+ void registerKernel( Kernel* );
+ /**
+ * @return the list of kernels in the collection
+ */
+ const std::list< Kernel* >& kernels() const;
+ private:
+ struct Private;
+ Private* const d;
+ };
+}
+
+#endif
Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/KernelsCollection.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/LibrariesManager.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/LibrariesManager.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/LibrariesManager.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -40,9 +40,9 @@
LibrariesManager::LibrariesManager() : d(new Private)
{
- addDirectory(".");
- addDirectory(_OPENSHIVA_SHIVA_STD_LIB_SRC_DIR_);
- addDirectory(_OPENSHIVA_SHIVA_SHARE_DIR_);
+ addDirectory( "." );
+ addDirectory( _OPENSHIVA_SHIVA_STD_LIB_SRC_DIR_ );
+ addDirectory( _OPENSHIVA_SHIVA_LIBRARIES_DIR_ );
}
void LibrariesManager::addDirectory(const GTLCore::String& directory)
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -33,7 +33,7 @@
#include "GTLCore/Region.h"
#include "GTLCore/Type.h"
#include "GTLCore/Macros_p.h"
-#include "GTLCore/TypeManager.h"
+#include "GTLCore/TypesManager.h"
#include "GTLCore/Value.h"
#include "GTLCore/VirtualMachine_p.h"
#include "GTLCore/wrappers/Allocate.h"
@@ -49,7 +49,7 @@
#include "wrappers/RegionWrap_p.h"
#include "MetadataLexer_p.h"
#include "MetadataParser_p.h"
-#include "KernelMetadata.h"
+#include "Metadata.h"
#include "Kernel_p.h"
@@ -63,17 +63,23 @@
metadata = 0;
compilationErrors.clear();
std::istringstream iss(source);
- Metadata::Lexer* lexer = new Metadata::Lexer(&iss);
- Metadata::Parser parser( lexer, "" );
+ MetadataLexer* lexer = new MetadataLexer(&iss);
+ MetadataParser parser( lexer, "" );
metadata = parser.parse();
compilationErrors = parser.errorMessages();
metadataCompilationFailed = not compilationErrors.empty();
GTL_DEBUG( compilationErrors.size() );
GTL_DEBUG( parser.errorMessages().size() );
parameters.clear();
- if( metadata and metadata->parameters() )
+ if( compilationErrors.size() == 0 )
{
- metadataToParameters( metadata->parameters() );
+ if( metadata and metadata->parameters() )
+ {
+ metadataToParameters( metadata->parameters() );
+ }
+ } else {
+ GTLCore::Metadata::Factory::deleteEntry( metadata );
+ metadata = 0;
}
}
@@ -168,7 +174,7 @@
cleanup();
d->m_moduleData = new GTLCore::ModuleData(new llvm::Module(d->name));
Compiler c( d->isKernel, d->count_channels_generic );
- Wrapper::fillTypeManager( d->m_moduleData, d->m_moduleData->typeManager(), c.convertCenter() , d->count_channels_generic );
+ Wrapper::fillTypesManager( d->m_moduleData, d->m_moduleData->typesManager(), c.convertCenter() , d->count_channels_generic );
GTLCore::String nameSpace;
bool result = c.compile( not d->isStandardLibrary, d->source, d->name, d->m_moduleData, nameSpace, d->parameters );
@@ -228,7 +234,7 @@
return d->m_moduleData->functions();
}
-const KernelMetadata* Library::metadata() const
+const Metadata* Library::metadata() const
{
return d->metadata;
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -30,7 +30,7 @@
}
namespace OpenShiva {
- class KernelMetadata;
+ class Metadata;
/**
*
* @ingroup OpenShiva
@@ -89,7 +89,7 @@
/**
* @return the metadata for this kernel.
*/
- const KernelMetadata* metadata() const;
+ const Metadata* metadata() const;
/**
* Set a given parameter to a given value
*/
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -56,7 +56,7 @@
int count_channels_generic;
bool isKernel;
bool isStandardLibrary;
- KernelMetadata* metadata;
+ Metadata* metadata;
bool metadataCompilationFailed;
std::map< GTLCore::String, GTLCore::Value > parameters;
};
Copied: trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp (from rev 506, trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.cpp)
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,86 @@
+/*
+ * 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 "Metadata.h"
+
+#include "GTLCore/Value.h"
+#include "GTLCore/Metadata/ValueEntry.h"
+
+#include "Debug.h"
+#include "Version.h"
+
+using namespace OpenShiva;
+using namespace GTLCore::Metadata;
+
+struct Metadata::Private {
+ int version;
+ const Group* infoList;
+ const Group* parametersList;
+};
+
+inline std::list<const Entry*> createList( const Entry* _version, const Group* _infoList, const Group* _parametersList )
+{
+ std::list<const Entry*> list;
+ if( _version )
+ {
+ list.push_back( _version );
+ }
+ if( _infoList )
+ {
+ list.push_back( _infoList );
+ }
+ if( _parametersList )
+ {
+ list.push_back( _parametersList );
+ }
+ return list;
+}
+
+Metadata::Metadata( const Entry* _version, const Group* _infoList, const Group* _parametersList ) : Group( "Kernel", createList( _version, _infoList, _parametersList ) ), d(new Private)
+{
+ d->version = LanguageVersion;
+ if( _version )
+ {
+ const ValueEntry* te = _version->asValueEntry();
+ SHIVA_ASSERT( te );
+ d->version = te->value().asInt32();
+ }
+ d->infoList = _infoList;
+ d->parametersList = _parametersList;
+}
+
+Metadata::~Metadata()
+{
+ delete d;
+}
+
+int Metadata::version() const
+{
+ return d->version;
+}
+const Group* Metadata::infos() const
+{
+ return d->infoList;
+}
+
+const Group* Metadata::parameters() const
+{
+ return d->parametersList;
+}
+
Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Copied: trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h (from rev 506, trunk/OpenGTL/OpenShiva/OpenShiva/KernelMetadata.h)
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,42 @@
+/*
+ * 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 _OPENSHIVA_KERNEL_METADATA_H_
+#define _OPENSHIVA_KERNEL_METADATA_H_
+
+#include <GTLCore/Metadata/Group.h>
+
+namespace OpenShiva {
+ class Metadata : public GTLCore::Metadata::Group {
+ friend class MetadataParser;
+ friend class Kernel;
+ Metadata( const GTLCore::Metadata::Entry* _version, const GTLCore::Metadata::Group* _infoList, const GTLCore::Metadata::Group* _parametersList );
+ ~Metadata();
+ public:
+ int version() const;
+ const GTLCore::Metadata::Group* infos() const;
+ const GTLCore::Metadata::Group* parameters() const;
+ private:
+ struct Private;
+ Private* const d;
+ };
+}
+
+#endif
+
Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -23,17 +23,17 @@
#include "Debug.h"
-using namespace OpenShiva::Metadata;
+using namespace OpenShiva;
-Lexer::Lexer(std::istream* sstream) : LexerBase(sstream)
+MetadataLexer::MetadataLexer(std::istream* sstream) : LexerBase(sstream)
{
}
-Lexer::~Lexer()
+MetadataLexer::~MetadataLexer()
{
}
-GTLCore::Token Lexer::nextToken()
+GTLCore::Token MetadataLexer::nextToken()
{
int lastChar = getNextNonSeparatorChar();
int initial_line = line() - 1;
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -23,18 +23,16 @@
#include "GTLCore/LexerBase_p.h"
namespace OpenShiva {
- namespace Metadata {
- /**
- * @internal
- * @ingroup OpenShiva
- */
- class Lexer : public GTLCore::LexerBase {
- public:
- Lexer(std::istream* sstream);
- virtual ~Lexer();
- virtual GTLCore::Token nextToken();
- };
- }
+ /**
+ * @internal
+ * @ingroup OpenShiva
+ */
+ class MetadataLexer : public GTLCore::LexerBase {
+ public:
+ MetadataLexer(std::istream* sstream);
+ virtual ~MetadataLexer();
+ virtual GTLCore::Token nextToken();
+ };
}
#endif
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -22,7 +22,7 @@
#include "GTLCore/ErrorMessage.h"
#include "GTLCore/Macros_p.h"
#include "GTLCore/Type.h"
-#include "GTLCore/TypeManager.h"
+#include "GTLCore/TypesManager.h"
#include "GTLCore/Value.h"
#include "GTLCore/Metadata/TextEntry.h"
@@ -33,30 +33,30 @@
#include "Debug.h"
#include "MetadataLexer_p.h"
-#include "KernelMetadata.h"
+#include "Metadata.h"
-using namespace OpenShiva::Metadata;
+using namespace OpenShiva;
-struct Parser::Private {
- Lexer* lexer;
+struct MetadataParser::Private {
+ MetadataLexer* lexer;
GTLCore::Token token;
std::list<GTLCore::ErrorMessage> errorMessages;
GTLCore::String fileName;
};
-Parser::Parser( Lexer* _lexer, const GTLCore::String& fileName) : d(new Private)
+MetadataParser::MetadataParser( MetadataLexer* _lexer, const GTLCore::String& fileName) : d(new Private)
{
d->lexer = _lexer;
d->fileName = fileName;
}
-Parser::~Parser()
+MetadataParser::~MetadataParser()
{
delete d->lexer;
delete d;
}
-OpenShiva::KernelMetadata* Parser::parse()
+OpenShiva::Metadata* MetadataParser::parse()
{
const GTLCore::Metadata::Entry* version = 0;
const GTLCore::Metadata::Group* infoList = 0;
@@ -101,37 +101,37 @@
getNextToken();
}
}
- return new KernelMetadata( version, infoList, parametersList );
+ return new Metadata( version, infoList, parametersList );
}
-void Parser::getNextToken()
+void MetadataParser::getNextToken()
{
d->token = d->lexer->nextToken();
}
-const GTLCore::Token& Parser::currentToken()
+const GTLCore::Token& MetadataParser::currentToken()
{
return d->token;
}
-void Parser::reportError( const GTLCore::String& errMsg, const GTLCore::Token& token )
+void MetadataParser::reportError( const GTLCore::String& errMsg, const GTLCore::Token& token )
{
SHIVA_DEBUG( errMsg );
d->errorMessages.push_back( GTLCore::ErrorMessage( errMsg, token.line, d->fileName ) );
}
-void Parser::reportUnexpected( const GTLCore::Token& token )
+void MetadataParser::reportUnexpected( const GTLCore::Token& token )
{
reportError("Unexpected: " + GTLCore::Token::typeToString( token.type ), token );
getNextToken();
}
-const std::list<GTLCore::ErrorMessage>& Parser::errorMessages() const
+const std::list<GTLCore::ErrorMessage>& MetadataParser::errorMessages() const
{
return d->errorMessages;
}
-bool Parser::isOfType( const GTLCore::Token& token, GTLCore::Token::Type type )
+bool MetadataParser::isOfType( const GTLCore::Token& token, GTLCore::Token::Type type )
{
if( token.type == type )
{
@@ -142,13 +142,13 @@
}
}
-const GTLCore::Metadata::ParameterEntry* Parser::parseParameterEntry(const GTLCore::String& name)
+const GTLCore::Metadata::ParameterEntry* MetadataParser::parseParameterEntry(const GTLCore::String& name)
{
GTL_ABORT("oh");
return 0;
}
-const GTLCore::Metadata::TextEntry* Parser::parseTextEntry( const GTLCore::String& name)
+const GTLCore::Metadata::TextEntry* MetadataParser::parseTextEntry( const GTLCore::String& name)
{
GTL_DEBUG( "parseTextEntry" );
if( currentToken().type == GTLCore::Token::STRING_CONSTANT or currentToken().type == GTLCore::Token::IDENTIFIER )
@@ -166,7 +166,7 @@
return 0;
}
-GTLCore::Value Parser::parseCoumpoundValue()
+GTLCore::Value MetadataParser::parseCoumpoundValue()
{
std::vector< GTLCore::Value > values;
enum { UNKNOWN, ARRAY, FLOAT } coumpoundType = UNKNOWN;
@@ -208,7 +208,7 @@
const GTLCore::Type* type = 0;
if( coumpoundType == FLOAT )
{
- type = GTLCore::TypeManager::getVector( GTLCore::Type::Float, values.size() );
+ type = GTLCore::TypesManager::getVector( GTLCore::Type::Float, values.size() );
}
return GTLCore::Value(values, type);
}
@@ -223,7 +223,7 @@
return values;
}
-const GTLCore::Metadata::ValueEntry* Parser::parseValueEntry(const GTLCore::String& name)
+const GTLCore::Metadata::ValueEntry* MetadataParser::parseValueEntry(const GTLCore::String& name)
{
GTL_DEBUG( "parseValueEntry" );
GTLCore::Value val;
@@ -252,7 +252,7 @@
return 0;
}
-const GTLCore::Metadata::Entry* Parser::parseGroupOrParameterEntry( const GTLCore::String& _name, bool _parameter)
+const GTLCore::Metadata::Entry* MetadataParser::parseGroupOrParameterEntry( const GTLCore::String& _name, bool _parameter)
{
bool isAParameter = false;
GTL_DEBUG( "parseListEntry" );
@@ -269,27 +269,42 @@
if( isOfType( currentToken(), GTLCore::Token::COLON ) )
{
getNextToken();
+ const GTLCore::Metadata::Entry* entry = 0;
if( currentToken().type == GTLCore::Token::INFERIOR )
{
- entries.push_back( parseGroupOrParameterEntry( str, _parameter ) );
- } else if( not _parameter or str == "description" ) {
+ entry = parseGroupOrParameterEntry( str, _parameter );
+ } else if( not _parameter or str == "description" or str == "label" ) {
GTL_DEBUG("t: " << str);
- entries.push_back( parseTextEntry( str ) );
+ entry = parseTextEntry( str );
} else {
GTL_DEBUG("t: " << str);
if( str == "type" )
{
- isAParameter = true;
- entries.push_back( parseTextEntry( str ) );
+ const GTLCore::Metadata::TextEntry* entryType = parseTextEntry( str );
+ if( entryType )
+ {
+ if( entryType->text() == "int" or entryType->text() == "float"
+ or entryType->text() == "curve" or entryType->text() == "rgb" )
+ {
+ isAParameter = true;
+ entry = entryType;
+ } else {
+ GTLCore::Metadata::Factory::deleteEntry( entryType );
+ }
+ }
} else if( str == "minValue" or str == "maxValue" or str == "defaultValue" )
{
isAParameter = true;
- entries.push_back( parseValueEntry( str ) );
+ entry = parseValueEntry( str );
} else {
GTL_DEBUG("Unexpected");
reportUnexpected( currentToken() );
}
}
+ if( entry )
+ {
+ entries.push_back( entry );
+ }
} else {
break;
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -38,36 +38,34 @@
}
namespace OpenShiva {
- class KernelMetadata;
- namespace Metadata {
- class Lexer;
- /**
- * @internal
- * @ingroup OpenShiva
- */
- class Parser {
- public:
- Parser( Lexer* _lexer, const GTLCore::String& fileName);
- ~Parser();
- KernelMetadata* parse();
- const std::list<GTLCore::ErrorMessage>& errorMessages() const;
- private:
- const GTLCore::Metadata::ValueEntry* parseValueEntry(const GTLCore::String& name);
- GTLCore::Value parseCoumpoundValue();
- const GTLCore::Metadata::ParameterEntry* parseParameterEntry(const GTLCore::String& name);
- const GTLCore::Metadata::TextEntry* parseTextEntry(const GTLCore::String& name);
- const GTLCore::Metadata::Entry* parseGroupOrParameterEntry(const GTLCore::String& name, bool _parameter);
- private:
- void getNextToken();
- const GTLCore::Token& currentToken();
- void reportError( const GTLCore::String& errMsg, const GTLCore::Token& token );
- void reportUnexpected( const GTLCore::Token& token );
- bool isOfType( const GTLCore::Token& , GTLCore::Token::Type type );
- private:
- struct Private;
- Private* const d;
- };
- }
+ class Metadata;
+ class MetadataLexer;
+ /**
+ * @internal
+ * @ingroup OpenShiva
+ */
+ class MetadataParser {
+ public:
+ MetadataParser( MetadataLexer* _lexer, const GTLCore::String& fileName);
+ ~MetadataParser();
+ Metadata* parse();
+ const std::list<GTLCore::ErrorMessage>& errorMessages() const;
+ private:
+ const GTLCore::Metadata::ValueEntry* parseValueEntry(const GTLCore::String& name);
+ GTLCore::Value parseCoumpoundValue();
+ const GTLCore::Metadata::ParameterEntry* parseParameterEntry(const GTLCore::String& name);
+ const GTLCore::Metadata::TextEntry* parseTextEntry(const GTLCore::String& name);
+ const GTLCore::Metadata::Entry* parseGroupOrParameterEntry(const GTLCore::String& name, bool _parameter);
+ private:
+ void getNextToken();
+ const GTLCore::Token& currentToken();
+ void reportError( const GTLCore::String& errMsg, const GTLCore::Token& token );
+ void reportUnexpected( const GTLCore::Token& token );
+ bool isOfType( const GTLCore::Token& , GTLCore::Token::Type type );
+ private:
+ struct Private;
+ Private* const d;
+ };
}
#endif
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -30,7 +30,7 @@
#include <GTLCore/CompilerBase_p.h>
#include <GTLCore/Macros_p.h>
#include <GTLCore/Type.h>
-#include <GTLCore/TypeManager.h>
+#include <GTLCore/TypesManager.h>
#include <GTLCore/Value.h>
#include <GTLCore/VariableNG_p.h>
#include <GTLCore/VariablesManager_p.h>
@@ -229,31 +229,31 @@
{
case GTLCore::Token::BOOL2:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Boolean, 2 );
+ return typesManager()->getVector( GTLCore::Type::Boolean, 2 );
case GTLCore::Token::BOOL3:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Boolean, 3 );
+ return typesManager()->getVector( GTLCore::Type::Boolean, 3 );
case GTLCore::Token::BOOL4:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Boolean, 4 );
+ return typesManager()->getVector( GTLCore::Type::Boolean, 4 );
case GTLCore::Token::INT2:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Integer32, 2 );
+ return typesManager()->getVector( GTLCore::Type::Integer32, 2 );
case GTLCore::Token::INT3:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Integer32, 3 );
+ return typesManager()->getVector( GTLCore::Type::Integer32, 3 );
case GTLCore::Token::INT4:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Integer32, 4 );
+ return typesManager()->getVector( GTLCore::Type::Integer32, 4 );
case GTLCore::Token::FLOAT2:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Float, 2 );
+ return typesManager()->getVector( GTLCore::Type::Float, 2 );
case GTLCore::Token::FLOAT3:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Float, 3 );
+ return typesManager()->getVector( GTLCore::Type::Float, 3 );
case GTLCore::Token::FLOAT4:
getNextToken();
- return typeManager()->getVector( GTLCore::Type::Float, 4 );
+ return typesManager()->getVector( GTLCore::Type::Float, 4 );
default:
return GTLCore::ParserBase::parseType();
}
@@ -268,7 +268,7 @@
GTLCore::String name = currentToken().string;
getNextToken();
std::list<int> memberArraySize = expressionsListToIntegersList( parseArraySize(true) );
- type = d->compiler->typeManager()->getArray( type, memberArraySize.size() );
+ type = d->compiler->typesManager()->getArray( type, memberArraySize.size() );
if( isOfType( currentToken(), GTLCore::Token::SEMI ) )
{
getNextToken();
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
@@ -34,8 +34,8 @@
#include "GTLCore/PixelDescription.h"
#include "GTLCore/Type.h"
#include "GTLCore/Type_p.h"
-#include "GTLCore/TypeManager.h"
-#include "GTLCore/TypeManager_p.h"
+#include "GTLCore/TypesManager.h"
+#include "GTLCore/TypesManager_p.h"
#include "GTLCore/Value.h"
#include "GTLCore/VirtualMachine_p.h"
@@ -101,22 +101,22 @@
return owrap;
}
-void Wrapper::fillTypeManager( GTLCore::ModuleData* _module, GTLCore::TypeManager* _typeManager, GTLCore::ConvertCenter* _convertCenter, int _channels )
+void Wrapper::fillTypesManager( GTLCore::ModuleData* _module, GTLCore::TypesManager* _typesManager, GTLCore::ConvertCenter* _convertCenter, int _channels )
{
- SHIVA_DEBUG("fillTypeManager");
+ SHIVA_DEBUG("fillTypesManager");
_convertCenter->addConvertExpressionFactory(new PixelConvertExpressionFactory);
for( int i = 1; i <= 5; ++i)
{
// Create Image type
- const GTLCore::Type* pixelType = createPixelType( _module, _typeManager, _convertCenter, GTLCore::String::number( i ), i );
- createImageType( _module, _typeManager, GTLCore::String::number( i ), i, pixelType );
+ const GTLCore::Type* pixelType = createPixelType( _module, _typesManager, _convertCenter, GTLCore::String::number( i ), i );
+ createImageType( _module, _typesManager, GTLCore::String::number( i ), i, pixelType );
}
- const GTLCore::Type* pixelType = createPixelType( _module, _typeManager, _convertCenter, "", _channels );
- createImageType( _module, _typeManager, "", _channels, pixelType );
- createRegionType( _module, _typeManager );
+ const GTLCore::Type* pixelType = createPixelType( _module, _typesManager, _convertCenter, "", _channels );
+ createImageType( _module, _typesManager, "", _channels, pixelType );
+ createRegionType( _module, _typesManager );
}
-const GTLCore::Type* Wrapper::createPixelType( GTLCore::ModuleData* _module, GTLCore::TypeManager* _typeManager, GTLCore::ConvertCenter* _convertCenter, const GTLCore::String& _suffix, int _channels )
+const GTLCore::Type* Wrapper::createPixelType( GTLCore::ModuleData* _module, GTLCore::TypesManager* _typesManager, GTLCore::ConvertCenter* _convertCenter, const GTLCore::String& _suffix, int _channels )
{
//---------------------- WARNING ----------------------//
// Whenever the following structure is edited, //
@@ -124,13 +124,13 @@
// struct PixelWrap ! //
//---------------------- WARNING ----------------------//
- const GTLCore::Type* vecType = vectorType( _typeManager, _channels );
+ const GTLCore::Type* vecType = vectorType( _typesManager, _channels );
std::vector<GTLCore::Type::StructDataMember> pixelDataMembers;
pixelDataMembers.push_back( GTLCore::Type::StructDataMember( "data", vecType ) );
- pixelDataMembers.push_back( GTLCore::Type::StructDataMember( "coord", _typeManager->getVector( GTLCore::Type::Float, 2 ) ) );
+ pixelDataMembers.push_back( GTLCore::Type::StructDataMember( "coord", _typesManager->getVector( GTLCore::Type::Float, 2 ) ) );
- const GTLCore::Type* type = _typeManager->d->createStructure( "pixel" + _suffix, pixelDataMembers );
+ const GTLCore::Type* type = _typesManager->d->createStructure( "pixel" + _suffix, pixelDataMembers );
type->d->setVisitor( PixelVisitor::instance() );
_convertCenter->addAutoConversion( type, vecType );
@@ -138,7 +138,7 @@
return type;
}
-void Wrapper::createRegionType( GTLCore::ModuleData* _module, GTLCore::TypeManager* _typeManager )
+void Wrapper::createRegionType( GTLCore::ModuleData* _module, GTLCore::TypesManager* _typesManager )
{
//---------------------- WARNING ----------------------//
// Whenever the following structure is edited, //
@@ -150,7 +150,7 @@
regionDataMembers.push_back( GTLCore::Type::StructDataMember( "y", GTLCore::Type::Float) );
regionDataMembers.push_back( GTLCore::Type::StructDataMember( "width", GTLCore::Type::Float ) );
regionDataMembers.push_back( GTLCore::Type::StructDataMember( "height", GTLCore::Type::Float ) );
- const GTLCore::Type* type = _typeManager->d->createStructure( "region", regionDataMembers);
+ const GTLCore::Type* type = _typesManager->d->createStructure( "region", regionDataMembers);
type->d->addFunctionMember( GTLCore::Type::StructFunctionMember(
GTLCore::Function::Private::createExternalFunction(
_module, "left", "region_wrap_left", GTLCore::Type::Float, 1,
@@ -196,31 +196,31 @@
return (llvm::Function*)_module->getOrInsertFunction( "image_wrap_data", functionTy);
}
-llvm::FunctionType* Wrapper::image_wrap_sample_nearest_type( GTLCore::TypeManager* _typeManager, const GTLCore::Type* _imageType, const GTLCore::Type* _pixelType )
+llvm::FunctionType* Wrapper::image_wrap_sample_nearest_type( GTLCore::TypesManager* _typesManager, const GTLCore::Type* _imageType, const GTLCore::Type* _pixelType )
{
std::vector<const llvm::Type*> functionArgs;
functionArgs.push_back( _imageType->d->pointerType() );
- functionArgs.push_back( _typeManager->getVector( GTLCore::Type::Float, 2 )->d->type() );
+ functionArgs.push_back( _typesManager->getVector( GTLCore::Type::Float, 2 )->d->type() );
return llvm::FunctionType::get( _pixelType->d->pointerType() , functionArgs, false);
}
-llvm::FunctionType* Wrapper::image_wrap_mem_to_vec_float_type( GTLCore::TypeManager* _typeManager, int _channels )
+llvm::FunctionType* Wrapper::image_wrap_mem_to_vec_float_type( GTLCore::TypesManager* _typesManager, int _channels )
{
std::vector<const llvm::Type*> functionArgs;
- functionArgs.push_back( llvm::PointerType::get( vectorType( _typeManager, _channels)->d->type(), 0) );
+ functionArgs.push_back( llvm::PointerType::get( vectorType( _typesManager, _channels)->d->type(), 0) );
functionArgs.push_back( llvm::PointerType::get( llvm::IntegerType::get(8), 0));
return llvm::FunctionType::get( llvm::Type::VoidTy, functionArgs, false);
}
-llvm::FunctionType* Wrapper::image_wrap_vec_float_to_mem_type( GTLCore::TypeManager* _typeManager, int _channels )
+llvm::FunctionType* Wrapper::image_wrap_vec_float_to_mem_type( GTLCore::TypesManager* _typesManager, int _channels )
{
std::vector<const llvm::Type*> functionArgs;
functionArgs.push_back( llvm::PointerType::get( llvm::IntegerType::get(8), 0));
- functionArgs.push_back( llvm::PointerType::get( vectorType( _typeManager, _channels)->d->type(), 0) );
+ functionArgs.push_back( llvm::PointerType::get( vectorType( _typesManager, _channels)->d->type(), 0) );
return llvm::FunctionType::get( llvm::Type::VoidTy, functionArgs, false);
}
-void Wrapper::createImageType( GTLCore::ModuleData* _moduleData, GTLCore::TypeManager* _typeManager, const GTLCore::String& _suffix, int _channels, const GTLCore::Type* _pixelType )
+void Wrapper::createImageType( GTLCore::ModuleData* _moduleData, GTLCore::TypesManager* _typesManager, const GTLCore::String& _suffix, int _channels, const GTLCore::Type* _pixelType )
{
//---------------------- WARNING ----------------------//
// Whenever the following structure is edited, //
@@ -232,26 +232,26 @@
imageDataMembers.push_back( GTLCore::Type::StructDataMember(
"memToVec",
GTLCore::Type::Private::createArbitraryType(
- llvm::PointerType::get( image_wrap_mem_to_vec_float_type( _typeManager, _channels ), 0 ) ) ) ); // FIXME arbitraty type are leaking
+ llvm::PointerType::get( image_wrap_mem_to_vec_float_type( _typesManager, _channels ), 0 ) ) ) ); // FIXME arbitraty type are leaking
imageDataMembers.push_back( GTLCore::Type::StructDataMember(
"vecToMem",
GTLCore::Type::Private::createArbitraryType(
- llvm::PointerType::get( image_wrap_vec_float_to_mem_type( _typeManager, _channels ), 0 ) ) ) ); // FIXME arbitraty type are leaking
- const GTLCore::Type* type = _typeManager->d->createStructure( "image" + _suffix, imageDataMembers );
+ llvm::PointerType::get( image_wrap_vec_float_to_mem_type( _typesManager, _channels ), 0 ) ) ) ); // FIXME arbitraty type are leaking
+ const GTLCore::Type* type = _typesManager->d->createStructure( "image" + _suffix, imageDataMembers );
type->d->addFunctionMember( GTLCore::Type::StructFunctionMember(
GTLCore::Function::Private::createInternalFunction(
_moduleData, "sampleNearest",
CodeGenerator::generateImageSampleNearest( _moduleData, type, _pixelType ),
_pixelType, 2,
- type, _moduleData->typeManager()->getVector( GTLCore::Type::Float, 2 ) ) ) );
+ type, _moduleData->typesManager()->getVector( GTLCore::Type::Float, 2 ) ) ) );
}
-const GTLCore::Type* Wrapper::vectorType( GTLCore::TypeManager* _typeManager, int _channels )
+const GTLCore::Type* Wrapper::vectorType( GTLCore::TypesManager* _typesManager, int _channels )
{
if( _channels == 1)
{
return GTLCore::Type::Float;
}
- return _typeManager->getVector( GTLCore::Type::Float, _channels);
+ return _typesManager->getVector( GTLCore::Type::Float, _channels);
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -33,7 +33,7 @@
namespace GTLCore {
class ModuleData;
class PixelDescription;
- class TypeManager;
+ class TypesManager;
class AbstractImage;
class ConvertCenter;
}
@@ -55,19 +55,19 @@
struct Private;
Private* const d;
public:
- static void fillTypeManager( GTLCore::ModuleData* _module, GTLCore::TypeManager*, GTLCore::ConvertCenter*, int _channels );
+ static void fillTypesManager( GTLCore::ModuleData* _module, GTLCore::TypesManager*, GTLCore::ConvertCenter*, int _channels );
static llvm::Function* image_wrap_dataFunction( llvm::Module* _module, const GTLCore::Type* _imageType );
- static llvm::FunctionType* image_wrap_sample_nearest_type( GTLCore::TypeManager* _typeManager, const GTLCore::Type* _imageType, const GTLCore::Type* _pixelType );
- static llvm::FunctionType* image_wrap_mem_to_vec_float_type( GTLCore::TypeManager* _typeManager, int _channels );
- static llvm::FunctionType* image_wrap_vec_float_to_mem_type( GTLCore::TypeManager* _typeManager, int _channels );
+ static llvm::FunctionType* image_wrap_sample_nearest_type( GTLCore::TypesManager* _typesManager, const GTLCore::Type* _imageType, const GTLCore::Type* _pixelType );
+ static llvm::FunctionType* image_wrap_mem_to_vec_float_type( GTLCore::TypesManager* _typesManager, int _channels );
+ static llvm::FunctionType* image_wrap_vec_float_to_mem_type( GTLCore::TypesManager* _typesManager, int _channels );
/**
* @return the vectory type associated to that number of _channels
*/
- static const GTLCore::Type* vectorType( GTLCore::TypeManager* _typeManager, int _channels );
+ static const GTLCore::Type* vectorType( GTLCore::TypesManager* _typesManager, int _channels );
private:
- static void createRegionType( GTLCore::ModuleData* _module, GTLCore::TypeManager* _typeManager );
- static const GTLCore::Type* createPixelType( GTLCore::ModuleData* _module, GTLCore::TypeManager* _typeManager, GTLCore::ConvertCenter* _convertCenter, const GTLCore::String& _suffix, int _channels );
- static void createImageType( GTLCore::ModuleData* _moduleData, GTLCore::TypeManager* _typeManager, const GTLCore::String& _suffix, int _channels, const GTLCore::Type* _pixelType );
+ static void createRegionType( GTLCore::ModuleData* _module, GTLCore::TypesManager* _typesManager );
+ static const GTLCore::Type* createPixelType( GTLCore::ModuleData* _module, GTLCore::TypesManager* _typesManager, GTLCore::ConvertCenter* _convertCenter, const GTLCore::String& _suffix, int _channels );
+ static void createImageType( GTLCore::ModuleData* _moduleData, GTLCore::TypesManager* _typesManager, const GTLCore::String& _suffix, int _channels, const GTLCore::Type* _pixelType );
};
}
Modified: trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
===================================================================
--- trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex 2008-12-12 17:54:03 UTC (rev 540)
@@ -103,7 +103,7 @@
input images are needed. For instance, if you program is a gaussian blur, it
needs an extra pixel around the operated region.
-\begin{tabular}[t]{|c|p{250pt}|}
+\begin{tabular}[t]{|c|p{200pt}|}
\hline
\verb|region output_region| & the region that will be operated
by the kernel \\
@@ -117,7 +117,8 @@
Exemple for a gaussian blur:
\begin{lstlisting}
- region needed(region output_region, int input_index, region input_DOD[])
+ region needed(region output_region, int input_index,
+ region input_DOD[])
{
output_region.outset(1,1)
}
@@ -131,8 +132,8 @@
run to compute the region of the output image.
\begin{lstlisting}
- region changed( region changed_input_region, int input_index, region
-input_DOD[])
+ region changed( region changed_input_region, int input_index,
+ region input_DOD[])
{
...
}
@@ -188,6 +189,11 @@
\begin{lstlisting}
<
version: 0;
+ category: <
+ label: Miscaelenous;
+ key: misc;
+ description: Miscaelenous kernels;
+ >;
info: <
author: "Joe Doe; Joe Doe Jr";
vendor: <
@@ -199,18 +205,21 @@
parameters: <
param1: <
type: int;
+ label: "Param 1";
minValue: 0;
maxValue: 100;
defaultValue: 50;
description: "This is the first parameter";
>;
- categorie2: <
- description: "This is a categorie of parameters";
+ category2: <
+ description: "This is a category of parameters";
param2: <
+ label: "Param 2";
type: curve;
defaultValue: {{0,0},{1,1}};
>;
param3: <
+ label: "Param 3";
type: rgb;
defaultValue: {1,0,0};
>;
@@ -219,7 +228,27 @@
>
\end{lstlisting}
+\subsection{category}
+The \textit{category} group of the metadata is used by kernel collection
+management system to group together a set of kernel. All kernels with the same
+key are assummed to be in the same category, even if the \textit{label} and
+\textit{description} fields are different, those two are only suggestion, it is
+left to the collection management system to pick the \textit{label} and
+\textit{description}.
+If no category is specified, the kernel is assumed to belong to the
+\verb|misc| category.
+
+List of suggested default category, with labels and descriptions:
+
+\begin{tabular}{|c|c|p{210pt}|}
+\hline
+key & label & description \\
+\hline
+misc & Miscellaneous & Miscellaneous kernels \\
+\hline
+\end{tabular}
+
\subsection{info}
\subsection{parameters}
Added: trunk/OpenGTL/OpenShiva/examples/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/CMakeLists.txt (rev 0)
+++ trunk/OpenGTL/OpenShiva/examples/CMakeLists.txt 2008-12-12 17:54:03 UTC (rev 540)
@@ -0,0 +1,2 @@
+
+install(FILES AntiBullify.shiva Bullify.shiva RadialGradient.shiva Ripples.shiva Something.shiva SunRay.shiva SuperNova.shiva DESTINATION ${SHARE_INSTALL_DIR}/shiva/kernels )
Modified: trunk/OpenGTL/OpenShiva/examples/SunRay.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/examples/SunRay.shiva 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/examples/SunRay.shiva 2008-12-12 17:54:03 UTC (rev 540)
@@ -1,3 +1,32 @@
+<
+ parameters: <
+ xcenter: <
+ label: "Center x";
+ type: float;
+ >;
+ ycenter: <
+ label: "Center y";
+ type: float;
+ >;
+ fluctuation: <
+ label: "Fluctuation";
+ type: float;
+ >;
+ phase: <
+ label: "Phase";
+ type:float;
+ minValue: 0.1;
+ maxValue: 100.0;
+ defaultValue: 30.0;
+ >;
+ colorrgb: <
+ label: "Color";
+ type: rgb;
+ defaultValue: { 0.3, 0.05, 0.01 };
+ >;
+ >;
+>;
+
kernel SunRay
{
const float width = 500.0;
@@ -2,7 +31,5 @@
const float height = 500.0;
- const float2 center = { width/2.0, height/2.0 };
+ const float2 center = { width * xcenter, height * ycenter };
const float PI = 3.14159265;
- const float4 color = { 0.3, 0.05, 0.01, 1.0 };
- const float fluctuation = 0.5;
- const float phase = 30.0;
+ const float4 color = { colorrgb[0], colorrgb[1], colorrgb[2], 1.0 };
float length( float2 v)
Modified: trunk/OpenGTL/OpenShiva/tests/library/TestMetadataLexer.h
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/library/TestMetadataLexer.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/tests/library/TestMetadataLexer.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -25,7 +25,7 @@
virtual void runTest()
{
std::istringstream iss(" < version: 0; info: < \"bouh\"; \"b\\\"o;\" 12.0 >");
- OpenShiva::Metadata::Lexer lng(&iss);
+ OpenShiva::MetadataLexer lng(&iss);
TEST_FOR_TOKEN( INFERIOR );
TEST_FOR_TOKEN_AND_VALUE_STRICT( IDENTIFIER, string, "version" );
TEST_FOR_TOKEN( COLON );
Modified: trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h 2008-12-10 22:39:46 UTC (rev 539)
+++ trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h 2008-12-12 17:54:03 UTC (rev 540)
@@ -18,11 +18,11 @@
*/
#include "OpenShiva/MetadataParser_p.h"
-#include "OpenShiva/KernelMetadata.h"
+#include "OpenShiva/Metadata.h"
#include "GTLCore/ErrorMessage.h"
#include "GTLCore/Type.h"
-#include "GTLCore/TypeManager.h"
+#include "GTLCore/TypesManager.h"
#include "GTLCore/Value.h"
#include "GTLCore/Metadata/TextEntry.h"
#include "GTLCore/Metadata/Group.h"
@@ -76,9 +76,9 @@
>; \
>; \
>");
- OpenShiva::Metadata::Lexer* lng = new OpenShiva::Metadata::Lexer(&iss);
- OpenShiva::Metadata::Parser parser( lng, "");
- OpenShiva::KernelMetadata* km = parser.parse();
+ OpenShiva::MetadataLexer* lng = new OpenShiva::MetadataLexer(&iss);
+ OpenShiva::MetadataParser parser( lng, "");
+ OpenShiva::Metadata* km = parser.parse();
GTLTEST_CHECK_EQUAL( parser.errorMessages().size(), 0 );
GTLTEST_CHECK_EQUAL( km->version(), 0 );
@@ -116,11 +116,11 @@
const GTLCore::Metadata::ParameterEntry* param2 = categorie2->entry( "param2" )->asParameterEntry();
GTLTEST_CHECK_NOT_EQUAL( param2, 0 );
TESTMEDATAPARSER_TEST_TEXT_ENTRY( param2->entry( "type" ), "curve");
- const GTLCore::Type* typeVector2 = GTLCore::TypeManager::getVector( GTLCore::Type::Float, 2 );
+ const GTLCore::Type* typeVector2 = GTLCore::TypesManager::getVector( GTLCore::Type::Float, 2 );
std::vector< GTLCore::Value > v1; v1.push_back( 0.25f ); v1.push_back( 0.0f );
std::vector< GTLCore::Value > v2; v2.push_back( 1.0f ); v2.push_back( 0.5f );
std::vector< GTLCore::Value > v3; v3.push_back( GTLCore::Value( v1, typeVector2 ) ); v3.push_back( GTLCore::Value( v2, typeVector2 ) );
- GTLCore::Value param2value( v3, GTLCore::TypeManager::getArray( typeVector2 ) );
+ GTLCore::Value param2value( v3, GTLCore::TypesManager::getArray( typeVector2 ) );
TESTMEDATAPARSER_TEST_VALUE_ENTRY( param2->entry( "defaultValue" ), param2value);
GTLTEST_CHECK_EQUAL( param2->defaultValue(), param2value);
@@ -130,7 +130,7 @@
GTLTEST_CHECK_NOT_EQUAL( param3, 0 );
TESTMEDATAPARSER_TEST_TEXT_ENTRY( param3->entry( "type" ), "rgb");
std::vector< GTLCore::Value > v4; v4.push_back( 1.0f ); v4.push_back( 0.0f ); v4.push_back( 0.0f );
- GTLCore::Value param3value( v4, GTLCore::TypeManager::getVector( GTLCore::Type::Float, 3 ) );
+ GTLCore::Value param3value( v4, GTLCore::TypesManager::getVector( GTLCore::Type::Float, 3 ) );
TESTMEDATAPARSER_TEST_VALUE_ENTRY( param3->entry( "defaultValue" ), param3value);
GTLTEST_CHECK_EQUAL( param3->defaultValue(), param3value);
GTLTEST_CHECK_EQUAL( param3->defaultValue().type(), param3->valueType());