1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
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.
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.
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
21
#ifndef DRIZZLED_CATALOG_INSTANCE_H
22
#define DRIZZLED_CATALOG_INSTANCE_H
24
#include <boost/thread/mutex.hpp>
25
#include <boost/make_shared.hpp>
27
#include <drizzled/message/catalog.h>
28
#include <drizzled/identifier/session.h>
41
drizzled::session_id_t _lock_id;
42
message::catalog::shared_ptr _message;
43
mutable boost::mutex _schema_lock;
44
mutable boost::mutex _system_variable_lock;
48
typedef boost::shared_ptr<Instance> shared_ptr;
49
typedef std::vector<shared_ptr> vector;
50
typedef const Instance* const_pointer;
51
typedef const Instance& const_reference;
52
typedef Instance& reference;
54
Instance(message::catalog::shared_ptr &message_arg)
56
_message= message_arg;
59
Instance(const message::catalog::shared_ptr &message_arg)
61
_message= message_arg;
64
static shared_ptr make_shared(message::catalog::shared_ptr &message_arg)
66
assert(not message_arg->name().empty());
67
return boost::make_shared<Instance>(message_arg);
70
static shared_ptr make_shared(const identifier::Catalog &identifier)
72
drizzled::message::catalog::shared_ptr new_message= drizzled::message::catalog::make_shared(identifier);
73
assert(not new_message->name().empty());
74
return boost::make_shared<Instance>(new_message);
77
const std::string &getName() const
80
return _message->name();
83
const std::string &name() const
86
return _message->name();
89
message::catalog::shared_ptr message() const
99
bool lock(drizzled::session_id_t id)
101
if (_locked and _lock_id == id)
103
assert(0); // We shouldn't support recursion
117
bool unlock(drizzled::session_id_t id)
119
if (_locked and _lock_id == id)
130
boost::mutex &schemaLock()
135
boost::mutex &systemVariableLock()
137
return _system_variable_lock;
141
} /* namespace catalog */
142
} /* namespace drizzled */
144
#endif /* DRIZZLED_CATALOG_INSTANCE_H */