00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Sverre Rabbelier * 00003 * sverre@rabbelier.nl * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 3 of the License, or * 00008 * (at your option) any later version. * 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 * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #pragma once 00021 00029 #include "Types.h" 00030 00031 typedef std::vector<KeysPtr> KeysVector; 00046 class SelectionMask 00047 { 00048 public: 00050 SelectionMask(TableImplPtr table); 00051 00053 ~SelectionMask(); 00054 00056 TableImplPtr getTable() const; 00057 00059 void addField(ValuePtr value); 00060 00071 void addJoin(TableImplPtr joinTable, KeyImplPtr nativeKey, KeyImplPtr foreignKey); 00072 00083 void addJoin(TableImplPtr nativeTable, TableImplPtr joinTable, KeyImplPtr nativeKey, KeyImplPtr foreignKey); 00084 00086 void addJoin(JoinPtr join); 00087 00088 00090 void bindSelectMulti(sqlite3* db, sqlite3_stmt* statement) const; 00091 00093 void parseRow(sqlite3_stmt* statement); 00094 00096 void parseCount(sqlite3_stmt* statement); 00097 00098 00100 size_t size() { return m_restrictions.size(); } 00101 00103 Strings::const_iterator begin() { return m_restrictions.begin(); } 00104 00106 Strings::const_iterator end() { return m_restrictions.end(); } 00107 00108 00110 size_t joinssize() { return m_joins.size(); } 00111 00113 Joins::const_iterator joinsbegin() { return m_joins.begin(); } 00114 00116 Joins::const_iterator joinsend() { return m_joins.end(); } 00117 00118 00120 SavableManagersPtr getResult() { return m_result; } 00121 00123 size_t getCount() { return m_count; } 00124 00125 private: 00127 bool isReachableTable(TableImplPtr table); 00128 00129 TableImplPtr m_nativeTable; 00130 ValuesPtr m_values; 00131 TableImplVector m_foreignTables; 00132 Joins m_joins; 00133 Strings m_restrictions; 00135 SavableManagersPtr m_result; 00136 size_t m_count; 00137 };