drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
plugin/user_locks/key.h
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#include <boost/thread/mutex.hpp>
22#include <boost/thread/condition_variable.hpp>
23#include <functional>
24#include <unordered_map>
25#include <unordered_set>
26
27#include <string>
28
29#include <drizzled/session.h>
30#include <drizzled/util/string.h>
31
32#pragma once
33
34namespace user_locks {
35
36class Key {
38 std::string lock_name;
39 size_t hash_value;
40
41public:
42 Key(const drizzled::identifier::User &context_arg, const std::string &lock_name_arg) :
43 context(context_arg),
44 lock_name(lock_name_arg)
45 {
47 hash_value= hasher(context.username() + lock_name_arg);
48 }
49
50 size_t getHashValue() const
51 {
52 return hash_value;
53 }
54
55 const std::string &getLockName() const
56 {
57 return lock_name;
58 }
59
60 const std::string &getUser() const
61 {
62 return context.username();
63 }
64};
65
66bool operator==(Key const& left, Key const& right);
67
68std::size_t hash_value(Key const& b);
69
70typedef std::unordered_set<Key> Keys;
71
72} /* namespace user_locks */
73
74namespace std {
75template<>
76struct hash<user_locks::Key>
77{
78 size_t operator()(const user_locks::Key& v) const
79 {
80 return user_locks::hash_value(v);
81 }
82};
83} /* namespace std */
84
A set of Session members describing the current authenticated user.
STL namespace.