Drizzled Public API Documentation

schema.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2009 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; 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   This is a "work in progress". The concept needs to be replicated throughout
00023   the code, but we will start with baby steps for the moment. To not incur
00024   cost until we are complete, for the moment it will do no allocation.
00025 
00026   This is mainly here so that it can be used in the SE interface for
00027   the time being.
00028 
00029   This will replace Table_ident.
00030   */
00031 
00032 #pragma once
00033 
00034 #include <drizzled/enum.h>
00035 #include <drizzled/definitions.h>
00036 #include <drizzled/message/table.pb.h>
00037 #include <drizzled/catalog/local.h>
00038 #include <string.h>
00039 
00040 #include <assert.h>
00041 
00042 #include <ostream>
00043 #include <list>
00044 #include <algorithm>
00045 #include <functional>
00046 #include <iostream>
00047 
00048 #include <boost/algorithm/string.hpp>
00049 
00050 #include <drizzled/visibility.h>
00051 
00052 namespace drizzled {
00053 namespace identifier {
00054 
00055 class DRIZZLED_API Schema : public Identifier
00056 {
00057   std::string db;
00058   std::string db_path;
00059 
00060 public:
00061   typedef std::vector <Schema> vector;
00062   typedef const Schema& const_reference;
00063 
00064   Schema(const std::string &db_arg);
00065 
00066   virtual ~Schema()
00067   { }
00068 
00069   virtual void getSQLPath(std::string &arg) const;
00070 
00071   const std::string &getPath() const;
00072 
00073   const std::string &getSchemaName() const
00074   {
00075     return db;
00076   }
00077 
00078   const std::string &getCatalogName() const;
00079 
00080   virtual bool isValid() const;
00081 
00082   inline virtual bool isSystem() const
00083   {
00084     return false;
00085   }
00086 
00087   bool compare(const std::string &arg) const;
00088   bool compare(Schema::const_reference) const;
00089 
00090   friend bool operator<(Schema::const_reference left, Schema::const_reference right)
00091   {
00092     return  boost::algorithm::to_upper_copy(left.getSchemaName()) < boost::algorithm::to_upper_copy(right.getSchemaName());
00093   }
00094 
00095   friend bool operator==(Schema::const_reference left,
00096                          Schema::const_reference right)
00097   {
00098     return boost::iequals(left.getSchemaName(), right.getSchemaName());
00099   }
00100 };
00101 
00102 std::ostream& operator<<(std::ostream& output, const Schema&identifier);
00103 
00104 
00105 } /* namespace identifier */
00106 } /* namespace drizzled */