Drizzled Public API Documentation

shared.h
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2011 Brian Aker
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; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 
00022 #pragma once
00023 
00024 #include <drizzled/table/instance/base.h>
00025 
00026 namespace drizzled
00027 {
00028 
00029 class TableShare;
00030 class Session;
00031 
00032 namespace identifier { class Table; }
00033 
00034 namespace table
00035 {
00036 
00037 namespace instance
00038 {
00039 
00040 void release(TableShare *share);
00041 void release(TableShare::shared_ptr &share);
00042 void release(const identifier::Table &identifier);
00043 
00044 
00045 class Shared : public drizzled::TableShare
00046 {
00047   friend void release(TableShare *share);
00048   friend void release(TableShare::shared_ptr &share);
00049 
00050 public:
00051   typedef boost::shared_ptr<Shared> shared_ptr;
00052   typedef std::vector <shared_ptr> vector;
00053 
00054   Shared(const identifier::Table::Type type_arg,
00055          const identifier::Table &identifier,
00056          char *path_arg= NULL, uint32_t path_length_arg= 0); // Shares for cache
00057 
00058   Shared(const identifier::Table &identifier, message::schema::shared_ptr schema_message);
00059 
00060   Shared(const identifier::Table &identifier); // Used by placeholder
00061 
00062   ~Shared();
00063 
00064 
00065   void lock()
00066   {
00067     mutex.lock();
00068   }
00069 
00070   void unlock()
00071   {
00072     mutex.unlock();
00073   }
00074 
00075   static shared_ptr make_shared(Session *session, 
00076                                 const identifier::Table &identifier,
00077                                 int &in_error);
00078 
00079   static shared_ptr foundTableShare(shared_ptr share);
00080 
00081   plugin::EventObserverList *getTableObservers() 
00082   { 
00083     return event_observers;
00084   }
00085 
00086   void setTableObservers(plugin::EventObserverList *observers) 
00087   { 
00088     event_observers= observers;
00089   }
00090 
00091   virtual bool is_replicated() const;
00092 
00093 private:
00094   boost::mutex mutex;                /* For locking the share  */
00095   drizzled::message::schema::shared_ptr _schema;
00096 
00097   /* 
00098     event_observers is a class containing all the event plugins that have 
00099     registered an interest in this table.
00100   */
00101   plugin::EventObserverList *event_observers;
00102 
00103 };
00104 
00105 } /* namespace instance */
00106 } /* namespace table */
00107 } /* namespace drizzled */
00108