~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/user.h

  • Committer: Olaf van der Spek
  • Date: 2011-03-24 00:16:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2251.
  • Revision ID: olafvdspek@gmail.com-20110324001614-wvmgc6eg52oq2321
Remove const_reference and reference from Session

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
 
22
 
#ifndef DRIZZLED_IDENTIFIER_USER_H
23
 
#define DRIZZLED_IDENTIFIER_USER_H
 
21
#pragma once
24
22
 
25
23
#include <string>
26
24
#include <boost/shared_ptr.hpp>
 
25
#include <drizzled/identifier.h>
 
26
#include <drizzled/visibility.h>
27
27
 
28
 
namespace drizzled
29
 
{
30
 
namespace identifier
31
 
{
 
28
namespace drizzled {
 
29
namespace identifier {
32
30
 
33
31
/**
34
32
  @class User
35
33
  @brief A set of Session members describing the current authenticated user.
36
34
*/
37
35
 
38
 
class User {
 
36
class User : public Identifier
 
37
{
39
38
public:
40
39
  typedef boost::shared_ptr<User> shared_ptr;
41
40
  typedef boost::shared_ptr<const User> const_shared_ptr;
42
 
  static shared_ptr make_shared();
 
41
  DRIZZLED_API static shared_ptr make_shared();
43
42
 
44
43
  enum PasswordType
45
44
  {
 
45
    NONE,
46
46
    PLAIN_TEXT,
47
47
    MYSQL_HASH
48
48
  };
49
49
 
50
50
  User():
51
 
    password_type(PLAIN_TEXT),
52
 
    _user(""),
53
 
    _address("")
 
51
    password_type(NONE)
54
52
  { }
55
53
 
 
54
  virtual std::string getSQLPath() const
 
55
        {
 
56
                return _user.empty() ? "<no user>" : _user;
 
57
        }
 
58
 
 
59
  bool hasPassword() const
 
60
  {
 
61
    return password_type != NONE;
 
62
  }
 
63
 
56
64
  const std::string& address() const
57
65
  {
58
66
    return _address;
60
68
 
61
69
  void setAddress(const char *newip)
62
70
  {
63
 
    _address.assign(newip);
 
71
    _address = newip;
64
72
  }
65
73
 
66
74
  const std::string& username() const
70
78
 
71
79
  void setUser(const std::string &newuser)
72
80
  {
73
 
    _user.assign(newuser);
 
81
    _user = newuser;
74
82
  }
75
83
 
76
 
  PasswordType getPasswordType(void) const
 
84
  PasswordType getPasswordType() const
77
85
  {
78
86
    return password_type;
79
87
  }
102
110
 
103
111
} /* namespace identifier */
104
112
} /* namespace drizzled */
105
 
 
106
 
#endif /* DRIZZLED_IDENTIFIER_USER_H */