00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*- 00002 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: 00003 * 00004 * Copyright (C) 2009 Sun Microsystems, Inc. 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; version 2 of the License. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #pragma once 00021 00022 namespace drizzled 00023 { 00024 namespace optimizer 00025 { 00026 00040 class SargableParam 00041 { 00042 public: 00043 SargableParam() 00044 : 00045 field(NULL), 00046 arg_value(NULL), 00047 num_values(0) 00048 {} 00049 00050 SargableParam(Field *in_field, 00051 Item **in_arg_value, 00052 uint32_t in_num_values) 00053 : 00054 field(in_field), 00055 arg_value(in_arg_value), 00056 num_values(in_num_values) 00057 {} 00058 00059 SargableParam(const SargableParam &rhs) 00060 : 00061 field(rhs.field), 00062 arg_value(rhs.arg_value), 00063 num_values(rhs.num_values) 00064 {} 00065 00066 SargableParam &operator=(const SargableParam &rhs) 00067 { 00068 if (this == &rhs) 00069 { 00070 return *this; 00071 } 00072 field= rhs.field; 00073 arg_value= rhs.arg_value; 00074 num_values= rhs.num_values; 00075 return *this; 00076 } 00077 00078 Field *getField() 00079 { 00080 return field; 00081 } 00082 00083 uint32_t getNumValues() const 00084 { 00085 return num_values; 00086 } 00087 00088 bool isConstItem(uint32_t index) 00089 { 00090 return (arg_value[index]->const_item()); 00091 } 00092 00093 private: 00094 00098 Field *field; 00099 00103 Item **arg_value; 00104 00108 uint32_t num_values; 00109 }; 00110 00111 } /* end namespace optimizer */ 00112 00113 } /* end namespace drizzled */ 00114