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 namespace table {
00028 namespace instance {
00029 
00030 void release(TableShare *share);
00031 void release(TableShare::shared_ptr &share);
00032 void release(const identifier::Table &identifier);
00033 
00034 
00035 class Shared : public drizzled::TableShare
00036 {
00037   friend void release(TableShare *share);
00038   friend void release(TableShare::shared_ptr &share);
00039 
00040 public:
00041   typedef boost::shared_ptr<Shared> shared_ptr;
00042   typedef std::vector <shared_ptr> vector;
00043 
00044   Shared(const identifier::Table::Type type_arg,
00045          const identifier::Table &identifier,
00046          char *path_arg= NULL, uint32_t path_length_arg= 0); // Shares for cache
00047 
00048   Shared(const identifier::Table &identifier, message::schema::shared_ptr schema_message);
00049 
00050   Shared(const identifier::Table &identifier); // Used by placeholder
00051 
00052   ~Shared();
00053 
00054 
00055   void lock()
00056   {
00057     mutex.lock();
00058   }
00059 
00060   void unlock()
00061   {
00062     mutex.unlock();
00063   }
00064 
00065   static shared_ptr make_shared(Session *session, 
00066                                 const identifier::Table &identifier,
00067                                 int &in_error);
00068 
00069   static shared_ptr foundTableShare(shared_ptr share);
00070 
00071   plugin::EventObserverList *getTableObservers() 
00072   { 
00073     return event_observers;
00074   }
00075 
00076   void setTableObservers(plugin::EventObserverList *observers) 
00077   { 
00078     event_observers= observers;
00079   }
00080 
00081   virtual bool is_replicated() const;
00082 
00083 private:
00084   boost::mutex mutex;                /* For locking the share  */
00085   drizzled::message::schema::shared_ptr _schema;
00086 
00087   /* 
00088     event_observers is a class containing all the event plugins that have 
00089     registered an interest in this table.
00090   */
00091   plugin::EventObserverList *event_observers;
00092 
00093 };
00094 
00095 } /* namespace instance */
00096 } /* namespace table */
00097 } /* namespace drizzled */
00098