~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definition/cache.h

  • Committer: Brian Aker
  • Date: 2010-10-26 21:34:15 UTC
  • mto: (1887.2.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1888.
  • Revision ID: brian@tangent.org-20101026213415-666ezkzx542h8uf0
Adding cache.h for definition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
21
#ifndef DRIZZLED_DEFINITION_CACHE_H
 
22
#define DRIZZLED_DEFINITION_CACHE_H
 
23
 
 
24
namespace drizzled {
 
25
 
 
26
typedef boost::shared_ptr<TableShare> TableSharePtr;
 
27
typedef boost::unordered_map< TableIdentifier::Key, TableSharePtr> TableDefinitionCache;
 
28
 
 
29
namespace definition {
 
30
 
 
31
class Cache
 
32
{
 
33
  TableDefinitionCache cache;
 
34
 
 
35
public:
 
36
  static inline Cache &singleton()
 
37
  {
 
38
    static Cache open_cache;
 
39
 
 
40
    return open_cache;
 
41
  }
 
42
 
 
43
  TableDefinitionCache &getCache()
 
44
  {
 
45
    return cache;
 
46
  }
 
47
 
 
48
  size_t size() const
 
49
  {
 
50
    return cache.size();
 
51
  }
 
52
 
 
53
  void rehash(size_t arg)
 
54
  {
 
55
    cache.rehash(arg);
 
56
  }
 
57
};
 
58
 
 
59
} /* namespace definition */
 
60
} /* namespace drizzled */
 
61
 
 
62
#endif /* DRIZZLED_DEFINITION_CACHE_H */