Drizzled Public API Documentation

cache.cc

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 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 #include <config.h>
00021 
00022 #include <drizzled/field.h>
00023 #include <drizzled/item/cache.h>
00024 #include <drizzled/item/cache_decimal.h>
00025 #include <drizzled/item/cache_int.h>
00026 #include <drizzled/item/cache_real.h>
00027 #include <drizzled/item/cache_row.h>
00028 #include <drizzled/item/cache_str.h>
00029 #include <drizzled/lex_string.h>
00030 
00031 namespace drizzled
00032 {
00033 
00034 Item_cache* Item_cache::get_cache(const Item *item)
00035 {
00036   switch (item->result_type()) {
00037   case INT_RESULT:
00038     return new Item_cache_int();
00039 
00040   case REAL_RESULT:
00041     return new Item_cache_real();
00042 
00043   case DECIMAL_RESULT:
00044     return new Item_cache_decimal();
00045 
00046   case STRING_RESULT:
00047     return new Item_cache_str(item);
00048 
00049   case ROW_RESULT:
00050     return new Item_cache_row();
00051   }
00052 
00053   assert(0);
00054   abort();
00055 }
00056 
00057 
00058 void Item_cache::print(String *str)
00059 {
00060   str->append(STRING_WITH_LEN("<cache>("));
00061   if (example)
00062     example->print(str);
00063   else
00064     Item::print(str);
00065   str->append(')');
00066 }
00067 
00068 bool Item_cache::eq_def(Field *field)
00069 {
00070   return cached_field ? cached_field->eq_def (field) : false;
00071 }
00072 
00073 } /* namespace drizzled */