[opengtl-commits] [324] make ConvertExpressionFactory works for multiple combination of types

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


Revision: 324
Author:   cyrille
Date:     2008-08-30 22:49:47 +0200 (Sat, 30 Aug 2008)

Log Message:
-----------
make ConvertExpressionFactory works for multiple combination of types

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp	2008-08-30 12:40:13 UTC (rev 323)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp	2008-08-30 20:49:47 UTC (rev 324)
@@ -27,14 +27,10 @@
 using namespace GTLCore;
 
 struct ConvertExpressionFactory::Private {
-  const GTLCore::Type* srcType;
-  const GTLCore::Type* dstType;
 };
 
-ConvertExpressionFactory::ConvertExpressionFactory( const GTLCore::Type* _srcType, const GTLCore::Type* _dstType) : d(new Private)
+ConvertExpressionFactory::ConvertExpressionFactory( ) : d(new Private)
 {
-  d->srcType = _srcType;
-  d->dstType = _dstType;
 }
 
 ConvertExpressionFactory::~ConvertExpressionFactory()
@@ -42,16 +38,7 @@
   delete d;
 }
 
-const GTLCore::Type* ConvertExpressionFactory::srcType() const
-{
-  return d->srcType;
-}
 
-const GTLCore::Type* ConvertExpressionFactory::dstType() const
-{
-  return d->dstType;
-}
-
 struct ConvertCenter::Private {
   std::list< ConvertExpressionFactory* > factories;
   std::map< const GTLCore::Type*, const GTLCore::Type* > autoconversion;
@@ -70,9 +57,9 @@
 {
   for( std::list< ConvertExpressionFactory* >::iterator it = d->factories.begin(); it != d->factories.end(); ++it)
   {
-    if( (*it)->srcType() == _value->type() and (*it)->dstType() == _dstType)
+    if( (*it)->canConvertBetween( _value->type(), _dstType ) )
     {
-      return (*it)->create( _value );
+      return (*it)->create( _value, _dstType );
     }
   }
   return 0;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h	2008-08-30 12:40:13 UTC (rev 323)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h	2008-08-30 20:49:47 UTC (rev 324)
@@ -30,11 +30,10 @@
   class Type;
   class ConvertExpressionFactory {
     public:
-      ConvertExpressionFactory( const GTLCore::Type* _srcType, const GTLCore::Type* _dstType);
+      ConvertExpressionFactory( );
       virtual ~ConvertExpressionFactory();
-      virtual AST::ConvertExpression* create( AST::Expression* value ) = 0;
-      const GTLCore::Type* srcType() const;
-      const GTLCore::Type* dstType() const;
+      virtual AST::ConvertExpression* create( AST::Expression* value, const GTLCore::Type* _dstType ) const = 0;
+      virtual bool canConvertBetween( const GTLCore::Type* srcType, const GTLCore::Type* dstType) const = 0;
     private:
       struct Private;
       Private* const d;


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