~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/named_savepoint.h

  • Committer: Patrick Crews
  • Date: 2010-08-23 22:43:09 UTC
  • mto: (1730.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1731.
  • Revision ID: gleebix@gmail.com-20100823224309-xmvlpo9kds4x5vod
Bug#586464 - add extra lines to gdbinit on OSX.  Added a test + insertion of extra gdbinit lines to test-run.pl code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
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; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
/**
 
21
 * @file Simple named savepoint class.
 
22
 */
 
23
 
 
24
#ifndef DRIZZLED_NAMED_SAVEPOINT_H
 
25
#define DRIZZLED_NAMED_SAVEPOINT_H
 
26
 
 
27
#include "drizzled/transaction_context.h" /* for TransactionContext::ResourceContexts */
 
28
 
 
29
namespace drizzled
 
30
{
 
31
 
 
32
/**
 
33
 * This is a class which stores information about
 
34
 * a named savepoint in a transaction
 
35
 */
 
36
class NamedSavepoint
 
37
{
 
38
public:
 
39
  /**
 
40
   * Constructor
 
41
   */
 
42
  NamedSavepoint(const char *in_name, size_t in_name_length) :
 
43
    name(in_name, in_name_length),
 
44
    resource_contexts()
 
45
  {}
 
46
  ~NamedSavepoint()
 
47
  {}
 
48
 
 
49
  void setResourceContexts(TransactionContext::ResourceContexts &new_contexts)
 
50
  {
 
51
    resource_contexts.assign(new_contexts.begin(), new_contexts.end());
 
52
  }
 
53
  const TransactionContext::ResourceContexts &getResourceContexts() const
 
54
  {
 
55
    return resource_contexts;
 
56
  }
 
57
  TransactionContext::ResourceContexts &getResourceContexts()
 
58
  {
 
59
    return resource_contexts;
 
60
  }
 
61
  const std::string &getName() const
 
62
  {
 
63
    return name;
 
64
  }
 
65
  const std::string &getName()
 
66
  {
 
67
    return name;
 
68
  }
 
69
  NamedSavepoint(const NamedSavepoint &other)
 
70
  {
 
71
    name.assign(other.getName());
 
72
    const TransactionContext::ResourceContexts &other_resource_contexts= other.getResourceContexts();
 
73
    resource_contexts.assign(other_resource_contexts.begin(),
 
74
                             other_resource_contexts.end());
 
75
  }
 
76
  NamedSavepoint &operator=(const NamedSavepoint &other)
 
77
  {
 
78
    if (this == &other)
 
79
      return *this;
 
80
 
 
81
    name.assign(other.getName());
 
82
    const TransactionContext::ResourceContexts &other_resource_contexts= other.getResourceContexts();
 
83
    resource_contexts.assign(other_resource_contexts.begin(),
 
84
                             other_resource_contexts.end());
 
85
    return *this;
 
86
  }
 
87
private:
 
88
  std::string name;
 
89
  TransactionContext::ResourceContexts resource_contexts;
 
90
  NamedSavepoint();
 
91
};
 
92
 
 
93
} /* namespace drizzled */
 
94
 
 
95
#endif /* DRIZZLED_NAMED_SAVEPOINT_H */