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>
00027 #include <string>
00028 
00029 namespace drizzled {
00030 
00035 class NamedSavepoint
00036 {
00037 public:
00041   NamedSavepoint(const char *in_name, size_t in_name_length) :
00042     name(in_name, in_name_length),
00043     resource_contexts(),
00044     transaction_message(NULL)
00045   {}
00046 
00047   ~NamedSavepoint();
00048 
00049   NamedSavepoint(const NamedSavepoint &other);
00050 
00051   void setResourceContexts(TransactionContext::ResourceContexts &new_contexts)
00052   {
00053     resource_contexts= new_contexts;
00054   }
00055   const TransactionContext::ResourceContexts &getResourceContexts() const
00056   {
00057     return resource_contexts;
00058   }
00059   TransactionContext::ResourceContexts &getResourceContexts()
00060   {
00061     return resource_contexts;
00062   }
00063   const std::string &getName() const
00064   {
00065     return name;
00066   }
00067   message::Transaction *getTransactionMessage() const
00068   {
00069     return transaction_message;
00070   }
00071   void setTransactionMessage(message::Transaction *in_transaction_message)
00072   {
00073     transaction_message= in_transaction_message;
00074   }
00075   NamedSavepoint &operator=(const NamedSavepoint &other)
00076   {
00077     if (this == &other)
00078       return *this;
00079 
00080     name= other.getName();
00081     resource_contexts= other.getResourceContexts();
00082     return *this;
00083   }
00084 private:
00085   std::string name;
00086   TransactionContext::ResourceContexts resource_contexts;
00087   message::Transaction *transaction_message;
00088 };
00089 
00090 } /* namespace drizzled */
00091