~drizzle-trunk/drizzle/development

2069.4.4 by Brian Aker
Create a shared form of the instance which is a bit more heavier weight then
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2011 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
22
#ifndef DRIZZLED_TABLE_INSTANCE_SHARED_H
23
#define DRIZZLED_TABLE_INSTANCE_SHARED_H
24
25
#include <drizzled/table/instance/base.h>
26
27
namespace drizzled
28
{
29
30
class TableShare;
31
class Session;
32
2088.1.4 by Brian Aker
FreeBSD fix.
33
namespace identifier { class Table; }
34
2069.4.4 by Brian Aker
Create a shared form of the instance which is a bit more heavier weight then
35
namespace table
36
{
37
38
namespace instance
39
{
40
41
void release(TableShare *share);
42
void release(TableShare::shared_ptr &share);
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
43
void release(const identifier::Table &identifier);
2069.4.4 by Brian Aker
Create a shared form of the instance which is a bit more heavier weight then
44
45
46
class Shared : public drizzled::TableShare
47
{
48
  friend void release(TableShare *share);
49
  friend void release(TableShare::shared_ptr &share);
50
51
private:
52
  boost::mutex mutex;                /* For locking the share  */
53
54
public:
55
  typedef boost::shared_ptr<Shared> shared_ptr;
56
  typedef std::vector <shared_ptr> vector;
57
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
58
  Shared(const identifier::Table::Type type_arg,
59
         const identifier::Table &identifier,
2069.4.4 by Brian Aker
Create a shared form of the instance which is a bit more heavier weight then
60
         char *path_arg= NULL, uint32_t path_length_arg= 0); // Shares for cache
61
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
62
  Shared(const identifier::Table &identifier); // Used by placeholder
2069.4.4 by Brian Aker
Create a shared form of the instance which is a bit more heavier weight then
63
64
  ~Shared();
65
66
67
  void lock()
68
  {
69
    mutex.lock();
70
  }
71
72
  void unlock()
73
  {
74
    mutex.unlock();
75
  }
76
77
78
  static shared_ptr make_shared(Session *session, 
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
79
                                const identifier::Table &identifier,
2069.4.4 by Brian Aker
Create a shared form of the instance which is a bit more heavier weight then
80
                                int &in_error);
81
82
  static shared_ptr foundTableShare(shared_ptr share);
83
};
84
85
} /* namespace instance */
86
} /* namespace table */
87
} /* namespace drizzled */
88
89
#endif /* DRIZZLED_TABLE_INSTANCE_SHARED_H */