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/make_shared.hpp>
25
#include "drizzled/message/catalog.h"
26
#include "drizzled/identifier/session.h"
39
drizzled::session_id_t _lock_id;
40
message::catalog::shared_ptr _message;
43
typedef boost::shared_ptr<Instance> shared_ptr;
44
typedef std::vector<shared_ptr> vector;
45
typedef const Instance* const_pointer;
47
Instance(message::catalog::shared_ptr &message_arg)
49
_message= message_arg;
52
Instance(const message::catalog::shared_ptr &message_arg)
54
_message= message_arg;
57
static shared_ptr create(message::catalog::shared_ptr &message_arg)
59
assert(not message_arg->name().empty());
60
return boost::make_shared<Instance>(message_arg);
63
static shared_ptr create(const identifier::Catalog &identifier)
65
drizzled::message::catalog::shared_ptr new_message= drizzled::message::catalog::make_shared(identifier);
66
assert(not new_message->name().empty());
67
return boost::make_shared<Instance>(new_message);
70
const std::string &getName() const
73
return _message->name();
76
const std::string &name() const
79
return _message->name();
82
message::catalog::shared_ptr message() const
92
bool lock(drizzled::session_id_t id)
94
if (_locked and _lock_id == id)
96
assert(0); // We shouldn't support recursion
110
bool unlock(drizzled::session_id_t id)
112
if (_locked and _lock_id == id)
124
} /* namespace catalog */
125
} /* namespace drizzled */
127
#endif /* DRIZZLED_CATALOG_INSTANCE_H */