1 /* 2 # PostgreSQL Database Modeler (pgModeler) 3 # 4 # Copyright 2006-2020 - Raphael Araújo e Silva <raphael@pgmodeler.io> 5 # 6 # This program is free software: you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation version 3. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # The complete text of GPLv3 is at LICENSE file on source code root directory. 16 # Also, you can get the complete GNU General Public License at <http://www.gnu.org/licenses/> 17 */ 18 19 /** 20 \ingroup libpgmodeler 21 \brief Implements the operations to manipulate foreign tables on the database. 22 */ 23 24 #ifndef FOREIGN_TABLE_H 25 #define FOREIGN_TABLE_H 26 27 #include "physicaltable.h" 28 #include "foreignobject.h" 29 #include "foreignserver.h" 30 31 class ForeignTable: public PhysicalTable, public ForeignObject { 32 private: 33 //! \brief The foreign server in which the foreign table resides 34 ForeignServer *foreign_server; 35 36 public: 37 ForeignTable(); 38 virtual ~ForeignTable(); 39 40 void setForeignServer(ForeignServer *server); 41 ForeignServer *getForeignServer(); 42 43 /*! \brief Adds an child object to the foreign table. 44 * This will raise an error if the user try to add constraints other than CHECK, 45 * indexes, rules and policies. This because foreign tables only accepts columns, check constraints, triggers */ 46 void addObject(BaseObject *object, int obj_idx = -1); 47 48 /*! \brief This method ignores any partitioning type provided for the foreign table. 49 * It always set partitioning type as null since foreign tables doesn't support partitioning */ 50 void setPartitioningType(PartitioningType); 51 52 //! \brief Returns the SQL / XML definition for table 53 virtual QString getCodeDefinition(unsigned def_type) final; 54 55 //! \brief Copy the attributes between two tables 56 void operator = (ForeignTable &table); 57 58 //! \brief Returns the alter definition comparing the this table against the one provided via parameter 59 virtual QString getAlterDefinition(BaseObject *object) final; 60 61 /*! \brief Generates the table's SQL code considering adding the relationship added object or not. 62 * Note if the method is called with incl_rel_added_objs = true it can produce an SQL/XML code 63 * that does not reflect the real semantics of the table. So take care to use this method and always 64 * invalidate the tables code (see setCodeInvalidated()) after retrieving the resulting code */ 65 QString __getCodeDefinition(unsigned def_type, bool incl_rel_added_objs); 66 67 friend class Relationship; 68 friend class OperationList; 69 }; 70 71 #endif 72