Code_table_list.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef ODBC_CODEGEN_Code_table_list_hpp
  14. #define ODBC_CODEGEN_Code_table_list_hpp
  15. #include <common/common.hpp>
  16. #include "Code_base.hpp"
  17. #include "Code_table.hpp"
  18. /**
  19.  * @class Plan_table_list
  20.  * @brief List of tables in select statement
  21.  */
  22. class Plan_table_list : public Plan_base {
  23. public:
  24.     Plan_table_list(Plan_root* root);
  25.     virtual ~Plan_table_list();
  26.     Plan_base* analyze(Ctx& ctx, Ctl& ctl);
  27.     Exec_base* codegen(Ctx& ctx, Ctl& ctl);
  28.     void print(Ctx& ctx);
  29.     // children
  30.     unsigned countTable() const;
  31.     void addTable(Plan_table* table);
  32.     Plan_table* getTable(unsigned i) const;
  33. protected:
  34.     friend class Plan_select;
  35.     TableVector m_tableList;
  36. };
  37. inline
  38. Plan_table_list::Plan_table_list(Plan_root* root) :
  39.     Plan_base(root),
  40.     m_tableList(1)
  41. {
  42. }
  43. // children
  44. inline unsigned
  45. Plan_table_list::countTable() const
  46. {
  47.     return m_tableList.size() - 1;
  48. }
  49. inline void
  50. Plan_table_list::addTable(Plan_table* table)
  51. {
  52.     ctx_assert(table != 0);
  53.     m_tableList.push_back(table);
  54. }
  55. inline Plan_table*
  56. Plan_table_list::getTable(unsigned i) const
  57. {
  58.     ctx_assert(1 <= i && i <= countTable() && m_tableList[i] != 0);
  59.     return m_tableList[i];
  60. }
  61. #endif