[opengtl-commits] [503] initial work on Metadata related classes

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


Revision: 503
Author:   cyrille
Date:     2008-11-27 00:10:07 +0100 (Thu, 27 Nov 2008)

Log Message:
-----------
initial work on Metadata related classes

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
    trunk/OpenGTL/OpenGTL/GTLCore/tests/TestGTLCore.cpp

Added Paths:
-----------
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.h
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_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/Metadata/ParameterEntry.h
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.h
    trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt	2008-11-26 23:09:40 UTC (rev 502)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt	2008-11-26 23:10:07 UTC (rev 503)
@@ -58,6 +58,12 @@
   VariablesManager_p.cpp
   VirtualMachine_p.cpp
   Visitor_p.cpp
+# Metadata
+  Metadata/Entry.cpp
+  Metadata/Group.cpp
+  Metadata/ParameterEntry.cpp
+  Metadata/TextEntry.cpp
+  Metadata/Factory_p.cpp
   ${LLVM_NATIVE_OBJECTS}
   )
 
@@ -77,4 +83,4 @@
 # 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 Metadata/ParameterEntry.h Metadata/Entry.h Metadata/Group.h Metadata/TextEntry.h DESTINATION ${INCLUDE_INSTALL_DIR}/GTLCore/Metadata )

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.cpp	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,56 @@
+/*
+ *  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 "Entry.h"
+
+using namespace GTLCore::Metadata;
+
+struct Entry::Private {
+  GTLCore::String name;
+};
+
+Entry::Entry( const GTLCore::String& _name ) : d(new Private)
+{
+  d->name = _name;
+}
+
+Entry::~Entry()
+{
+  delete d;
+}
+
+const GTLCore::String& Entry::name() const
+{
+  return d->name;
+}
+
+const Group* Entry::asGroup() const
+{
+  return 0;
+}
+
+const ParameterEntry* Entry::asParameterEntry() const
+{
+  return 0;
+}
+
+const TextEntry* Entry::asTextEntry() const
+{
+  return 0;
+}


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.h	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,54 @@
+/*
+ *  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_METADATA_ENTRY_H_
+#define _GTLCORE_METADATA_ENTRY_H_
+
+#include <GTLCore/String.h>
+
+namespace GTLCore {
+  namespace Metadata {
+    class Group;
+    class ParameterEntry;
+    class TextEntry;
+    /**
+     * @ingroup GTLCore_Metadata
+     */
+    class Entry {
+      friend class Group;
+      friend class ParameterEntry;
+      friend class TextEntry;
+      friend class Factory;
+      private:
+        Entry( const GTLCore::String& _name );
+        virtual ~Entry();
+      public:
+        const GTLCore::String& name() const;
+      public:
+        virtual const Group* asGroup() const;
+        virtual const ParameterEntry* asParameterEntry() const;
+        virtual const TextEntry* asTextEntry() const;
+      private:
+        struct Private;
+        Private* const d;
+    };
+  }
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Entry.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.cpp	2008-11-26 23:10:07 UTC (rev 503)
@@ -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.
+ */
+
+#include "Factory_p.h"
+
+#include "Entry.h"
+#include "Group.h"
+#include "ParameterEntry.h"
+#include "TextEntry.h"
+
+using namespace GTLCore::Metadata;
+
+Entry* Factory::createEntry( const GTLCore::String& _name)
+{
+  return new Entry( _name );
+}
+
+TextEntry* Factory::createTextEntry( const GTLCore::String& _name, const GTLCore::String& _text)
+{
+  return new TextEntry( _name, _text );
+}
+
+Group* Factory::createGroup( const GTLCore::String& _name, const std::list< Entry* >& _entries)
+{
+  return new Group( _name, _entries );
+}
+
+void Factory::deleteEntry( Entry* _entry )
+{
+  delete _entry;
+}
+
+ParameterEntry* Factory::createParameterEntry( const GTLCore::String& _name, int _minimumValue, int _maximumValue, int _defaultValue )
+{
+  return new ParameterEntry( _name, _minimumValue, _maximumValue, _defaultValue );
+}
+
+ParameterEntry* Factory::createParameterEntry( const GTLCore::String& _name, float _minimumValue, float _maximumValue, float _defaultValue )
+{
+  return new ParameterEntry( _name, _minimumValue, _maximumValue, _defaultValue );
+}
+
+ParameterEntry* Factory::createParameterEntry( const GTLCore::String& _name, const GTLCore::Value& _defaultValue )
+{
+  return new ParameterEntry( _name, _defaultValue );
+}


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.h	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,51 @@
+/*
+ *  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_METADATA_FACTORY_H_
+#define _GTLCORE_METADATA_FACTORY_H_
+
+#include <GTLCore/String.h>
+
+namespace GTLCore {
+  class Value;
+  namespace Metadata {
+    class Entry;
+    class Group;
+    class ParameterEntry;
+    class TextEntry;
+    /**
+     * @internal
+     * @ingroup GTLCore_Metadata
+     * This class is only used to create metadata objects
+     */
+    class Factory {
+      Factory();
+      public:
+        static Entry* createEntry( const GTLCore::String& _name);
+        static TextEntry* createTextEntry( const GTLCore::String& _name, const GTLCore::String& _text);
+        static Group* createGroup( const GTLCore::String& _name, const std::list< Entry* >& _entries);
+        static void deleteEntry( Entry* );
+        static ParameterEntry* createParameterEntry( const GTLCore::String& _name, int _minimumValue, int _maximumValue, int _defaultValue );
+        static ParameterEntry* createParameterEntry( const GTLCore::String& _name, float _minimumValue, float _maximumValue, float _defaultValue );
+        static ParameterEntry* createParameterEntry( const GTLCore::String& _name, const GTLCore::Value& _defaultValue );
+    };
+  }
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Factory_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp	2008-11-26 23:10:07 UTC (rev 503)
@@ -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 "Group.h"
+#include "Factory_p.h"
+
+#include "../Macros_p.h"
+
+using namespace GTLCore::Metadata;
+
+struct Group::Private {
+  std::list< Entry* > entries;
+};
+
+Group::Group( const GTLCore::String& _name, const std::list< Entry* >& _entries) : Entry( _name), d(new Private)
+{
+  d->entries = _entries;
+}
+
+Group::~Group()
+{
+  foreach( Entry* entry, d->entries )
+  {
+    Factory::deleteEntry( entry );
+  }
+  delete d;
+}
+
+const std::list< Entry* >& Group::entries() const
+{
+  return d->entries;
+}
+
+const Group* Group::asGroup() const
+{
+  return this;
+}


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,44 @@
+/*
+ *  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_METADATA_GROUP_H_
+#define _GTLCORE_METADATA_GROUP_H_
+
+#include <GTLCore/Metadata/Entry.h>
+
+namespace GTLCore {
+  namespace Metadata {
+    /**
+     * @ingroup GTLCore_Metadata
+     */
+    class Group : public Entry {
+        friend class Factory;
+        Group( const GTLCore::String& _name, const std::list< Entry* >& _entries);
+        virtual ~Group();
+      public:
+        const std::list< Entry* >& entries() const;
+        virtual const Group* asGroup() const;
+      private:
+        struct Private;
+        Private* const d;
+    };
+  }
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/Group.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,94 @@
+/*
+ *  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 "ParameterEntry.h"
+
+#include "../Value.h"
+#include "../Type.h"
+#include "../TypeManager.h"
+
+using namespace GTLCore::Metadata;
+
+struct ParameterEntry::Private {
+  Value minimumValue;
+  Value maximumValue;
+  Value defaultValue;
+  const Type* type;
+};
+
+ParameterEntry::ParameterEntry( const GTLCore::String& _name, int _minimumValue, int _maximumValue, int _defaultValue ) : Entry( _name ), d(new Private)
+{
+  d->type = GTLCore::Type::Integer32;
+  d->minimumValue.setInt32( _minimumValue );
+  d->maximumValue.setInt32( _maximumValue );
+  d->defaultValue.setInt32( _defaultValue );
+}
+
+ParameterEntry::ParameterEntry( const GTLCore::String& _name, float _minimumValue, float _maximumValue, float _defaultValue ) : Entry( _name ), d(new Private)
+{
+  d->type = GTLCore::Type::Float;
+  d->minimumValue.setFloat( _minimumValue );
+  d->maximumValue.setFloat( _maximumValue );
+  d->defaultValue.setFloat( _defaultValue );
+}
+
+ParameterEntry::ParameterEntry( const GTLCore::String& _name, const GTLCore::Value& _defaultValue ) : Entry( _name ), d(new Private)
+{
+  d->type = _defaultValue.type();
+  d->defaultValue = _defaultValue;
+  if( d->type == Type::Integer32 )
+  {
+    d->minimumValue.setInt32( 0 );
+    d->maximumValue.setInt32( 100 );
+  } else if( d->type == Type::Float )
+  {
+    d->minimumValue.setFloat( 0.0 );
+    d->maximumValue.setFloat( 1.0 );
+  }
+}
+        
+ParameterEntry::~ParameterEntry()
+{
+  delete d;
+}
+
+const GTLCore::Value& ParameterEntry::minimumValue() const
+{
+  return d->minimumValue;
+}
+
+const GTLCore::Value& ParameterEntry::maximumValue() const
+{
+  return d->maximumValue;
+}
+
+const GTLCore::Value& ParameterEntry::defaultValue() const
+{
+  return d->defaultValue;
+}
+
+const GTLCore::Type* ParameterEntry::type() const
+{
+  return d->type;
+}
+
+const ParameterEntry* ParameterEntry::asParameterEntry() const
+{
+  return this;
+}


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h	2008-11-26 23:10:07 UTC (rev 503)
@@ -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.
+ */
+
+#ifndef _GTLCORE_METADATA_PARAMETER_ENTRY_H_
+#define _GTLCORE_METADATA_PARAMETER_ENTRY_H_
+
+#include <GTLCore/Metadata/Entry.h>
+
+namespace GTLCore {
+  class Type;
+  class Value;
+  namespace Metadata {
+    /**
+     * @ingroup GTLCore_Metadata
+     */
+    class ParameterEntry : public Entry {
+      friend class Factory;
+      private:
+        ParameterEntry( const GTLCore::String& _name, int _minimumValue, int _maximumValue, int _defaultValue );
+        ParameterEntry( const GTLCore::String& _name, float _minimumValue, float _maximumValue, float _defaultValue );
+        ParameterEntry( const GTLCore::String& _name, const GTLCore::Value& _defaultValue );
+        virtual ~ParameterEntry();
+      public:
+        const Value& minimumValue() const;
+        const Value& maximumValue() const;
+        const Value& defaultValue() const;
+        const Type* type() const;
+      public:
+        virtual const ParameterEntry* asParameterEntry() const;
+      private:
+        struct Private;
+        Private* const d;
+    };
+  }
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/ParameterEntry.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.cpp	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,46 @@
+/*
+ *  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 "TextEntry.h"
+
+using namespace GTLCore::Metadata;
+
+struct TextEntry::Private {
+  GTLCore::String text;
+};
+
+TextEntry::TextEntry( const GTLCore::String& _name, const GTLCore::String& _text ) : Entry( _name ), d(new Private)
+{
+  d->text = _text;
+}
+
+TextEntry::~TextEntry()
+{
+  delete d;
+}
+
+const GTLCore::String& TextEntry::text() const
+{
+  return d->text;
+}
+
+const TextEntry* TextEntry::asTextEntry() const
+{
+  return this;
+}


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.h	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,44 @@
+/*
+ *  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_METADATA_TEXT_ENTRY_H_
+#define _GTLCORE_METADATA_TEXT_ENTRY_H_
+
+#include <GTLCore/Metadata/Entry.h>
+
+namespace GTLCore {
+  namespace Metadata {
+    /**
+     * @ingroup GTLCore_Metadata
+     */
+    class TextEntry : public Entry {
+      friend class Factory;
+        TextEntry( const GTLCore::String& _name, const GTLCore::String& _text );
+        virtual ~TextEntry();
+      public:
+        const GTLCore::String& text() const;
+        virtual const TextEntry* asTextEntry() const;
+      private:
+        struct Private;
+        Private* const d;
+    };
+  }
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/Metadata/TextEntry.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/OpenGTL/OpenGTL/GTLCore/tests/TestGTLCore.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/tests/TestGTLCore.cpp	2008-11-26 23:09:40 UTC (rev 502)
+++ trunk/OpenGTL/OpenGTL/GTLCore/tests/TestGTLCore.cpp	2008-11-26 23:10:07 UTC (rev 503)
@@ -37,6 +37,7 @@
 #include "TestPixelDescription.h"
 #include "TestScopedName.h"
 #include "TestConvertCenter.h"
+#include "TestMetadata.h"
 
 class TestArray : public GTLTest::Case {
   public:
@@ -68,4 +69,5 @@
 GTLTEST_MAIN_ADD_CASE(TestErrorMessage)
 GTLTEST_MAIN_ADD_CASE(TestScopedName)
 GTLTEST_MAIN_ADD_CASE(TestConvertCenter)
+GTLTEST_MAIN_ADD_CASE(TestMetadata)
 GTLTEST_MAIN_END()

Added: trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h	2008-11-26 23:10:07 UTC (rev 503)
@@ -0,0 +1,149 @@
+/*
+ *  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/Entry.h"
+#include "../Metadata/Factory_p.h"
+#include "../Metadata/Group.h"
+#include "../Metadata/ParameterEntry.h"
+#include "../Metadata/TextEntry.h"
+
+class TestEntry : public GTLTest::Case {
+  public:
+    TestEntry() : GTLTest::Case("Entry")
+    {
+    }
+    virtual void runTest()
+    {
+      Metadata::Entry* entry = Metadata::Factory::createEntry( "test");
+      GTLTEST_CHECK_EQUAL( entry->name(), "test" );
+      GTLTEST_CHECK_EQUAL( entry->asGroup(), 0 );
+      GTLTEST_CHECK_EQUAL( entry->asParameterEntry(), 0 );
+      GTLTEST_CHECK_EQUAL( entry->asTextEntry(), 0 );
+      Metadata::Factory::deleteEntry( entry );
+    }
+};
+
+class TestTextEntry : public GTLTest::Case {
+  public:
+    TestTextEntry() : GTLTest::Case("TextEntry")
+    {
+    }
+    virtual void runTest()
+    {
+      Metadata::TextEntry* entry = Metadata::Factory::createTextEntry( "test", "text" );
+      GTLTEST_CHECK_EQUAL( entry->name(), "test" );
+      GTLTEST_CHECK_EQUAL( entry->text(), "text" );
+      GTLTEST_CHECK_EQUAL( entry->asGroup(), 0 );
+      GTLTEST_CHECK_EQUAL( entry->asParameterEntry(), 0 );
+      GTLTEST_CHECK_EQUAL( entry->asTextEntry(), entry );
+      Metadata::Factory::deleteEntry( entry );
+    }
+};
+
+class TestGroup : public GTLTest::Case {
+  public:
+    TestGroup() : GTLTest::Case("TestGroup")
+    {
+    }
+    virtual void runTest()
+    {
+      Metadata::TextEntry* textEntry = Metadata::Factory::createTextEntry( "test", "text" );
+      std::list< Metadata::Entry* > entries;
+      entries.push_back( textEntry );
+      Metadata::Group* entry = Metadata::Factory::createGroup( "testGroup", entries );
+      GTLTEST_CHECK_EQUAL( entry->name(), "testGroup" );
+      GTLTEST_CHECK_EQUAL( entry->entries().size(), 1 );
+      GTLTEST_CHECK_EQUAL( *entry->entries().begin(), textEntry );
+      GTLTEST_CHECK_EQUAL( entry->asGroup(), entry );
+      GTLTEST_CHECK_EQUAL( entry->asParameterEntry(), 0 );
+      GTLTEST_CHECK_EQUAL( entry->asTextEntry(), 0 );
+      Metadata::Factory::deleteEntry( entry );
+    }
+};
+
+#define TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry) \
+  GTLTEST_CHECK_EQUAL( entry->minimumValue().type(), entry->type() ); \
+  GTLTEST_CHECK_EQUAL( entry->maximumValue().type(), entry->type() ); \
+  GTLTEST_CHECK_EQUAL( entry->defaultValue().type(), entry->type() );
+
+#define TEST_PARAMETER_ENTRY(entry) \
+  GTLTEST_CHECK_EQUAL( entry->asGroup(), 0 ); \
+  GTLTEST_CHECK_EQUAL( entry->asParameterEntry(), entry ); \
+  GTLTEST_CHECK_EQUAL( entry->asTextEntry(), 0 );
+
+class TestParameterEntry : public GTLTest::Case {
+  public:
+    TestParameterEntry() : GTLTest::Case("TestParameterEntry")
+    {
+    }
+    virtual void runTest()
+    {
+      {
+        Metadata::ParameterEntry* entry = Metadata::Factory::createParameterEntry( "int", -10, 20, 10 );
+        GTLTEST_CHECK_EQUAL( entry->name(), "int" );
+        TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
+        TEST_PARAMETER_ENTRY(entry);
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Integer32, entry->type() );
+        GTLTEST_CHECK_EQUAL( entry->minimumValue().asInt32(), -10 );
+        GTLTEST_CHECK_EQUAL( entry->maximumValue().asInt32(), 20 );
+        GTLTEST_CHECK_EQUAL( entry->defaultValue().asInt32(), 10 );
+      }
+      {
+        Metadata::ParameterEntry* entry = Metadata::Factory::createParameterEntry( "float", -0.1f, 1.0f, 0.5f );
+        GTLTEST_CHECK_EQUAL( entry->name(), "float" );
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Float, entry->type() );
+        TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
+        TEST_PARAMETER_ENTRY(entry);
+        GTLTEST_CHECK_EQUAL( entry->minimumValue().asFloat(), -0.1f );
+        GTLTEST_CHECK_EQUAL( entry->maximumValue().asFloat(), 1.0f );
+        GTLTEST_CHECK_EQUAL( entry->defaultValue().asFloat(), 0.5f );
+      }
+      {
+        Metadata::ParameterEntry* entry = Metadata::Factory::createParameterEntry( "int", GTLCore::Value( 10 ) );
+        GTLTEST_CHECK_EQUAL( entry->name(), "int" );
+        TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
+        TEST_PARAMETER_ENTRY(entry);
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Integer32, entry->type() );
+        GTLTEST_CHECK_EQUAL( entry->minimumValue().asInt32(), 0 );
+        GTLTEST_CHECK_EQUAL( entry->maximumValue().asInt32(), 100 );
+        GTLTEST_CHECK_EQUAL( entry->defaultValue().asInt32(), 10 );
+      }
+      {
+        Metadata::ParameterEntry* entry = Metadata::Factory::createParameterEntry( "float", GTLCore::Value( 0.5f ) );
+        GTLTEST_CHECK_EQUAL( entry->name(), "float" );
+        GTLTEST_CHECK_EQUAL( GTLCore::Type::Float, entry->type() );
+        TEST_PARAMETER_ENTRY_CONSISTENT_TYPE(entry);
+        TEST_PARAMETER_ENTRY(entry);
+        GTLTEST_CHECK_EQUAL( entry->minimumValue().asFloat(), 0.0f );
+        GTLTEST_CHECK_EQUAL( entry->maximumValue().asFloat(), 1.0f );
+        GTLTEST_CHECK_EQUAL( entry->defaultValue().asFloat(), 0.5f );
+      }
+    }
+};
+
+class TestMetadata : public GTLTest::Suite {
+  public:
+    TestMetadata() : GTLTest::Suite("Metdata")
+    {
+      addCase( new TestEntry );
+      addCase( new TestTextEntry );
+      addCase( new TestGroup );
+      addCase( new TestParameterEntry );
+    }
+};


Property changes on: trunk/OpenGTL/OpenGTL/GTLCore/tests/TestMetadata.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native


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