From 45032ffd23ce741dd9cd63a4befcea89f2fd19cf Mon Sep 17 00:00:00 2001 From: Andrei Aiordachioaie Date: Mon, 25 Jan 2010 18:55:43 +0100 Subject: Added a layer of abstraction for optimization levels. --- qlparser/querytree.cc | 17 +++++++++++++++++ qlparser/querytree.hh | 10 ++++++++++ 2 files changed, 27 insertions(+) (limited to 'qlparser') diff --git a/qlparser/querytree.cc b/qlparser/querytree.cc index 4a14ed6..412a2a5 100644 --- a/qlparser/querytree.cc +++ b/qlparser/querytree.cc @@ -160,6 +160,9 @@ QueryTree::optimize( unsigned int currentOptimizationLevel ) } } + if (isValidOptimizationLevel(currentOptimizationLevel) == false) + throw r_Error(r_Error::r_Error_InvalidOptimizationLevel); + optimizationFnc(currentOptimizationLevel, rootNode); RMDBGIF( 1, RMDebug::module_qlparser, "QueryTree", \ @@ -487,3 +490,17 @@ void QueryTree::rewriteDomainObjects(r_Minterval *greatDomain, string *greatIter void QueryTree::addCString( char *str ) { lexedCStringList.push_back( str ); } + +bool QueryTree::isValidOptimizationLevel( int level ) +{ + switch (level) + { + case STANDARDIZATION: + case SIMPLIFICATION: + case SUBEXPRESSIONS: + return true; + + default: + return false; + } +} diff --git a/qlparser/querytree.hh b/qlparser/querytree.hh index d6f28cc..cfeafb7 100644 --- a/qlparser/querytree.hh +++ b/qlparser/querytree.hh @@ -84,6 +84,13 @@ class QueryTree public: + enum OptimizationLevel + { + STANDARDIZATION = 1, + SIMPLIFICATION = 2, + SUBEXPRESSIONS = 3 + }; + /// default constructor QueryTree(); @@ -198,6 +205,9 @@ class QueryTree static void (*optimizationFnc)(unsigned int, QtNode*); + // Validity checks for the level of optimization + bool isValidOptimizationLevel( int level ); + /// used by public seeSubexpression() vector* seeSubexpression( QtNode::QtNodeList* leafList ); -- cgit