~drizzle-trunk/drizzle/development

1877.2.9 by Brian Aker
Adding cache.h for definition.
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Brian Aker
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
1877.2.9 by Brian Aker
Adding cache.h for definition.
22
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
23
#include <drizzled/table/instance.h>
1938.4.1 by Brian Aker
Fix style on naming of shared_ptr for tableshare.
24
1877.2.9 by Brian Aker
Adding cache.h for definition.
25
namespace drizzled {
26
namespace definition {
27
28
class Cache
29
{
30
public:
2275.3.6 by Olaf van der Spek
Definition Cache
31
  static size_t size()
32
  {
33
    // no lock?
1877.2.9 by Brian Aker
Adding cache.h for definition.
34
    return cache.size();
35
  }
36
2275.3.6 by Olaf van der Spek
Definition Cache
37
  static void rehash(size_t arg)
1877.2.9 by Brian Aker
Adding cache.h for definition.
38
  {
2275.3.6 by Olaf van der Spek
Definition Cache
39
    // no lock?
1877.2.9 by Brian Aker
Adding cache.h for definition.
40
    cache.rehash(arg);
41
  }
1877.2.10 by Brian Aker
Merge in work for cache (fetch directly from).
42
2275.3.6 by Olaf van der Spek
Definition Cache
43
  static table::instance::Shared::shared_ptr find(const identifier::Table::Key&);
44
  static void erase(const identifier::Table::Key&);
45
  static bool insert(const identifier::Table::Key&, table::instance::Shared::shared_ptr);
1938.4.3 by Brian Aker
Added generator for table_definition cache. Now no one can touch the guts :)
46
private:
2275.3.6 by Olaf van der Spek
Definition Cache
47
  static void CopyFrom(table::instance::Shared::vector&);
48
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
49
  typedef boost::unordered_map< identifier::Table::Key, table::instance::Shared::shared_ptr> Map;
1938.4.5 by Brian Aker
REmove the allowance for seeing the raw cache, and remove the ability for an
50
2275.3.6 by Olaf van der Spek
Definition Cache
51
  static Map cache;
52
  static boost::mutex _mutex;
53
54
  friend class generator::TableDefinitionCache;
1877.2.9 by Brian Aker
Adding cache.h for definition.
55
};
56
57
} /* namespace definition */
58
} /* namespace drizzled */
59