Drizzled Public API Documentation

named_savepoint.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00024 #pragma once
00025 
00026 #include <drizzled/transaction_context.h> /* for TransactionContext::ResourceContexts */
00027 
00028 namespace drizzled
00029 {
00030 
00031 namespace message
00032 {
00033 class Transaction;
00034 }
00035 
00040 class NamedSavepoint
00041 {
00042 public:
00046   NamedSavepoint(const char *in_name, size_t in_name_length) :
00047     name(in_name, in_name_length),
00048     resource_contexts(),
00049     transaction_message(NULL)
00050   {}
00051 
00052   ~NamedSavepoint();
00053 
00054   NamedSavepoint(const NamedSavepoint &other);
00055 
00056   void setResourceContexts(TransactionContext::ResourceContexts &new_contexts)
00057   {
00058     resource_contexts.assign(new_contexts.begin(), new_contexts.end());
00059   }
00060   const TransactionContext::ResourceContexts &getResourceContexts() const
00061   {
00062     return resource_contexts;
00063   }
00064   TransactionContext::ResourceContexts &getResourceContexts()
00065   {
00066     return resource_contexts;
00067   }
00068   const std::string &getName() const
00069   {
00070     return name;
00071   }
00072   const std::string &getName()
00073   {
00074     return name;
00075   }
00076   message::Transaction *getTransactionMessage() const
00077   {
00078     return transaction_message;
00079   }
00080   void setTransactionMessage(message::Transaction *in_transaction_message)
00081   {
00082     transaction_message= in_transaction_message;
00083   }
00084   NamedSavepoint &operator=(const NamedSavepoint &other)
00085   {
00086     if (this == &other)
00087       return *this;
00088 
00089     name.assign(other.getName());
00090     const TransactionContext::ResourceContexts &other_resource_contexts= other.getResourceContexts();
00091     resource_contexts.assign(other_resource_contexts.begin(),
00092                              other_resource_contexts.end());
00093     return *this;
00094   }
00095 private:
00096   std::string name;
00097   TransactionContext::ResourceContexts resource_contexts;
00098   message::Transaction *transaction_message;
00099   NamedSavepoint();
00100 };
00101 
00102 } /* namespace drizzled */
00103