rasdaman complete source
qtcaseop.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 
24 /*************************************************************
25  *
26  *
27  * PURPOSE:
28  * Defines the rasql CASE statement for scalar and induces cases.
29  * The following syntax applies:
30  * SELECT CASE WHEN condition1 THEN result1
31  * WHEN condition2 THEN result2
32  * ...
33  * WHEN conditionN THEN resultN
34  * ELSE resultDefault
35  * END
36  * FROM collectionName
37  *
38  * COMMENTS:
39  * The ELSE clause is mandatory.
40  *
41  ************************************************************/
42 
43 #ifndef QTCASEOP_HH
44 #define QTCASEOP_HH
45 
47 #include "relcatalogif/basetype.hh"
48 
49 class QtCaseOp : public QtNaryOperation {
50 public:
52  QtCaseOp(QtOperationList* opList);
53 
55  QtData* evaluate(QtDataList* inputList);
56 
57  //method for evaluating the induced node
59  QtData* inducedEvaluate(QtDataList* inputList);
60 
62  virtual void printTree(int tab, std::ostream& s = std::cout, QtChildType mode = QT_ALL_NODES);
63 
65  virtual void printAlgebraicExpression(std::ostream& s = std::cout);
66 
68  inline virtual const QtNodeType getNodeType() const;
69 
71  virtual const QtTypeElement& checkType(QtTypeTuple* typeTuple = NULL);
72 
74  virtual const QtTypeElement& checkInducedType(QtTypeTuple* typeTuple = NULL);
75 
77  void getCaseOperands(QtDataList* operandList, QtDataList* conditionList, QtDataList* resultList, QtData* &defaultResult);
78 
80  const BaseType* getResultType(const BaseType* op1, const BaseType* op2);
81 
83  int isSignedType(const BaseType* type);
84 private:
86  static const QtNodeType nodeType;
87 
89  bool inducedCase;
90 
92  BaseType* baseType;
93 };
94 
95 #endif /* QTCASEOP_HH */
96 
std::vector< QtData * > QtDataList
list of QtData pointers
Definition: qtnode.hh:77
Definition: qtnode.hh:463
virtual void printTree(int tab, std::ostream &s=std::cout, QtChildType mode=QT_ALL_NODES)
prints the tree
Definition: qtdata.hh:83
QtChildType
Definition: qtnode.hh:186
virtual const QtTypeElement & checkInducedType(QtTypeTuple *typeTuple=NULL)
type checking for the induced method
QtNodeType
Definition: qtnode.hh:93
QtData * inducedEvaluate(QtDataList *inputList)
method for evaluating the node
Definition: qtnode.hh:394
Definition: qtnaryoperation.hh:52
QtData * evaluate(QtDataList *inputList)
method for evaluating the node
const BaseType * getResultType(const BaseType *op1, const BaseType *op2)
type coercion: given 2 types, computes the resulting type
virtual const QtNodeType getNodeType() const
method for identification of nodes
void getCaseOperands(QtDataList *operandList, QtDataList *conditionList, QtDataList *resultList, QtData *&defaultResult)
breaks down the operand list into conditions and results
Definition: relcatalogif/basetype.hh:66
Definition: qtcaseop.hh:49
virtual void printAlgebraicExpression(std::ostream &s=std::cout)
prints the algebraic expression
virtual const QtTypeElement & checkType(QtTypeTuple *typeTuple=NULL)
type checking of the subtree
std::vector< QtOperation * > QtOperationList
list of QtOperation pointers
Definition: qtnode.hh:194
int isSignedType(const BaseType *type)
indicates if a type is signed or not
Definition: qtnode.hh:190
QtCaseOp(QtOperationList *opList)
constructor getting the operand list and a boolean