My Project
keycaches.h
00001 #ifndef KEYCACHES_INCLUDED
00002 #define KEYCACHES_INCLUDED
00003 
00004 /* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
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 Foundation,
00017    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
00018 
00019 #include "sql_list.h"
00020 #include <keycache.h>
00021 
00022 extern "C"
00023 {
00024   typedef int (*process_key_cache_t) (const char *, KEY_CACHE *);
00025 }
00026 
00030 class NAMED_ILINK :public ilink<NAMED_ILINK>
00031 {
00032 public:
00033   const char *name;
00034   uint name_length;
00035   uchar* data;
00036 
00037   NAMED_ILINK(I_List<NAMED_ILINK> *links, const char *name_arg,
00038              uint name_length_arg, uchar* data_arg)
00039     :name_length(name_length_arg), data(data_arg)
00040   {
00041     name= my_strndup(name_arg, name_length, MYF(MY_WME));
00042     links->push_back(this);
00043   }
00044 
00045   bool cmp(const char *name_cmp, uint length)
00046   {
00047     return length == name_length && !memcmp(name, name_cmp, length);
00048   }
00049 
00050   ~NAMED_ILINK()
00051   {
00052     my_free((void *) name);
00053   }
00054 };
00055 
00056 class NAMED_ILIST: public I_List<NAMED_ILINK>
00057 {
00058   public:
00059   void delete_elements(void (*free_element)(const char*, uchar*));
00060 };
00061 
00062 extern LEX_STRING default_key_cache_base;
00063 extern KEY_CACHE zero_key_cache;
00064 extern NAMED_ILIST key_caches;
00065 
00066 KEY_CACHE *create_key_cache(const char *name, uint length);
00067 KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
00068 KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
00069 void free_key_cache(const char *name, KEY_CACHE *key_cache);
00070 bool process_key_caches(process_key_cache_t func);
00071 
00072 #endif /* KEYCACHES_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines