[opengtl-commits] [714] add the ArrayToVector conversion to the conversion center |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 714
Author: cyrille
Date: 2009-04-09 15:12:29 +0200 (Thu, 09 Apr 2009)
Log Message:
-----------
add the ArrayToVector conversion to the conversion center
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp 2009-04-09 12:59:34 UTC (rev 713)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp 2009-04-09 13:12:29 UTC (rev 714)
@@ -60,6 +60,23 @@
}
};
+//------------------------ ArrayToVectorConvertExpressionFactory -----------------------//
+
+class ArrayToVectorConvertExpressionFactory : public ConvertExpressionFactory {
+ public:
+ virtual AST::ConvertExpression* create( AST::Expression* value, const GTLCore::Type* _dstType ) const
+ {
+ GTL_ASSERT( canConvertBetween( value->type(), _dstType ));
+ return new AST::ArrayToVectorConvertExpression( value, _dstType );
+ }
+ virtual bool canConvertBetween( const GTLCore::Type* srcType, const GTLCore::Type* dstType) const
+ {
+ return ( srcType->dataType() == GTLCore::Type::ARRAY
+ and dstType->dataType() == GTLCore::Type::VECTOR
+ and srcType->embeddedType() == dstType->embeddedType() );
+ }
+};
+
//--------------------------------- ConvertCenter --------------------------------//
struct ConvertCenter::Private {
@@ -70,6 +87,7 @@
ConvertCenter::ConvertCenter() : d(new Private)
{
addConvertExpressionFactory( new DefaultConvertExpressionFactory );
+ addConvertExpressionFactory( new ArrayToVectorConvertExpressionFactory );
}
ConvertCenter::~ConvertCenter()