Drizzled Public API Documentation

transaction_context.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 
00020 #pragma once
00021 
00022 #include <vector>
00023 #include <drizzled/common_fwd.h>
00024 
00025 namespace drizzled {
00026 
00027 class TransactionContext
00028 {
00029 public:
00030   TransactionContext() :
00031     no_2pc(false),
00032     resource_contexts(),
00033     modified_non_trans_data(false)
00034   {}
00035 
00036   void reset() { no_2pc= false; modified_non_trans_data= false; resource_contexts.clear();}
00037 
00038   typedef std::vector<ResourceContext *> ResourceContexts;
00039 
00040   void setResourceContexts(ResourceContexts &new_contexts)
00041   {
00042     resource_contexts= new_contexts;
00043   }
00044 
00045   ResourceContexts &getResourceContexts()
00046   {
00047     return resource_contexts;
00048   }
00050   void registerResource(ResourceContext *resource)
00051   {
00052     resource_contexts.push_back(resource);
00053   }
00054 
00059   void markModifiedNonTransData()
00060   {
00061     modified_non_trans_data= true;
00062   }
00063 
00068   bool hasModifiedNonTransData() const
00069   {
00070     return modified_non_trans_data;
00071   }
00072 
00073   /* true is not all entries in the resource contexts support 2pc */
00074   bool no_2pc;
00075 private:
00077   ResourceContexts resource_contexts;
00079   bool modified_non_trans_data;
00080 };
00081 
00082 } /* namespace drizzled */
00083