[opengtl-commits] [306] add a class to manage conversion between types

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


Revision: 306
Author:   cyrille
Date:     2008-07-29 09:09:01 +0200 (Tue, 29 Jul 2008)

Log Message:
-----------
add a class to manage conversion between types

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt

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


Modified: trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt	2008-07-28 17:32:21 UTC (rev 305)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CMakeLists.txt	2008-07-29 07:09:01 UTC (rev 306)
@@ -36,6 +36,7 @@
   AST/UnaryExpression.cpp
   CodeGenerator_p.cpp
   CompilerBase_p.cpp
+  ConvertCenter_p.cpp
   ErrorMessages_p.cpp
   ExpressionResult_p.cpp
   Function_p.cpp

Added: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp	2008-07-29 07:09:01 UTC (rev 306)
@@ -0,0 +1,77 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ConvertCenter_p.h"
+
+#include <list>
+
+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)
+{
+  d->srcType = _srcType;
+  d->dstType = _dstType;
+}
+
+ConvertExpressionFactory::~ConvertExpressionFactory()
+{
+  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;
+};
+
+ConvertCenter::ConvertCenter() : d(new Private)
+{
+}
+
+ConvertCenter::~ConvertCenter()
+{
+}
+
+AST::ConvertExpression* ConvertCenter::createConvertExpression( AST::Expression* value, const GTLCore::Type* _dstType ) const
+{
+  return 0;
+}
+
+AST::ConvertExpression* ConvertCenter::createConvertExpressionForBinaryExpression( AST::Expression* value, const GTLCore::Type* _otherType ) const
+{
+  return 0;
+}
+
+void ConvertCenter::addConvertExpressionFactory( ConvertExpressionFactory* cef)
+{
+  d->factories.push_back( cef );
+}

Added: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.h	2008-07-29 07:09:01 UTC (rev 306)
@@ -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;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _CONVERT_CENTER_H_
+#define _CONVERT_CENTER_H_
+
+namespace GTLCore {
+  namespace AST {
+    class ConvertExpression;
+    class Expression;
+  }
+  class Type;
+  class ConvertExpressionFactory {
+    public:
+      ConvertExpressionFactory( const GTLCore::Type* _srcType, const GTLCore::Type* _dstType);
+      virtual ~ConvertExpressionFactory();
+      virtual AST::ConvertExpression* create( AST::Expression* value ) = 0;
+      const GTLCore::Type* srcType() const;
+      const GTLCore::Type* dstType() const;
+    private:
+      struct Private;
+      Private* const d;
+  };
+  class ConvertCenter {
+    public:
+      ConvertCenter();
+      ~ConvertCenter();
+      AST::ConvertExpression* createConvertExpression( AST::Expression* value, const GTLCore::Type* _dstType ) const;
+      AST::ConvertExpression* createConvertExpressionForBinaryExpression( AST::Expression* value, const GTLCore::Type* _otherType ) const;
+      void addConvertExpressionFactory( ConvertExpressionFactory* );
+    private:
+      struct Private;
+      Private* const d;
+  };
+
+}
+
+#endif


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