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;
47
typedef boost::shared_ptr<Instance> shared_ptr;
48
typedef std::vector<shared_ptr> vector;
49
typedef const Instance* const_pointer;
50
typedef const Instance& const_reference;
51
typedef Instance& reference;
53
Instance(message::catalog::shared_ptr &message_arg)
55
_message= message_arg;
58
Instance(const message::catalog::shared_ptr &message_arg)
60
_message= message_arg;
63
static shared_ptr create(message::catalog::shared_ptr &message_arg)
65
assert(not message_arg->name().empty());
66
return boost::make_shared<Instance>(message_arg);
69
static shared_ptr create(const identifier::Catalog &identifier)
71
drizzled::message::catalog::shared_ptr new_message= drizzled::message::catalog::make_shared(identifier);
72
assert(not new_message->name().empty());
73
return boost::make_shared<Instance>(new_message);
76
const std::string &getName() const
79
return _message->name();
82
const std::string &name() const
85
return _message->name();
88
message::catalog::shared_ptr message() const
98
bool lock(drizzled::session_id_t id)
100
if (_locked and _lock_id == id)
102
assert(0); // We shouldn't support recursion
116
bool unlock(drizzled::session_id_t id)
118
if (_locked and _lock_id == id)
129
boost::mutex &schemaLock()
135
} /* namespace catalog */
136
} /* namespace drizzled */
138
#endif /* DRIZZLED_CATALOG_INSTANCE_H */