1 ////////////////////////////////////////////////////////////////////////// 2 // 3 // pgAdmin III - PostgreSQL Tools 4 // 5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team 6 // This software is released under the PostgreSQL Licence 7 // 8 // pgForeignServer.h PostgreSQL Foreign Server 9 // 10 ////////////////////////////////////////////////////////////////////////// 11 12 #ifndef PGFOREIGNSERVER_H 13 #define PGFOREIGNSERVER_H 14 15 #include "pgForeignDataWrapper.h" 16 17 class pgCollection; 18 class pgForeignServerFactory : public pgForeignDataWrapperObjFactory 19 { 20 public: 21 pgForeignServerFactory(); 22 virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent); 23 virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString); 24 }; 25 extern pgForeignServerFactory foreignServerFactory; 26 27 28 class pgForeignServer : public pgForeignDataWrapperObject 29 { 30 public: 31 pgForeignServer(pgForeignDataWrapper *newForeignDataWrapper, const wxString &newName = wxT("")); 32 wxString GetTranslatedMessage(int kindOfMessage) const; 33 34 void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0); 35 wxMenu *GetNewMenu(); CanDropCascaded()36 bool CanDropCascaded() 37 { 38 return true; 39 } CanCreate()40 bool CanCreate() 41 { 42 return true; 43 } GetType()44 wxString GetType() const 45 { 46 return type; 47 } iSetType(const wxString & s)48 void iSetType(const wxString &s) 49 { 50 type = s; 51 } GetVersion()52 wxString GetVersion() const 53 { 54 return version; 55 } iSetVersion(const wxString & s)56 void iSetVersion(const wxString &s) 57 { 58 version = s; 59 } GetOptions()60 wxString GetOptions() const 61 { 62 return options; 63 } 64 wxString GetCreateOptions(); iSetOptions(const wxString & s)65 void iSetOptions(const wxString &s) 66 { 67 options = s; 68 } 69 70 bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded); 71 wxString GetSql(ctlTree *browser); 72 pgObject *Refresh(ctlTree *browser, const wxTreeItemId item); 73 HasStats()74 bool HasStats() 75 { 76 return false; 77 } HasDepends()78 bool HasDepends() 79 { 80 return true; 81 } HasReferences()82 bool HasReferences() 83 { 84 return true; 85 } 86 87 private: 88 wxString type, version, options; 89 }; 90 91 92 class pgForeignServerObjFactory : public pgForeignDataWrapperObjFactory 93 { 94 public: 95 pgForeignServerObjFactory(const wxChar *tn, const wxChar *ns, const wxChar *nls, wxImage *img, wxImage *imgSm = 0) pgForeignDataWrapperObjFactory(tn,ns,nls,img,imgSm)96 : pgForeignDataWrapperObjFactory(tn, ns, nls, img, imgSm) {} 97 virtual pgCollection *CreateCollection(pgObject *obj); 98 }; 99 100 101 // Object that lives in a foreign server 102 class pgForeignServerObject : public pgForeignDataWrapperObject 103 { 104 public: 105 pgForeignServerObject(pgForeignServer *newForeignServer, pgaFactory &factory, const wxString &newName = wxEmptyString) : pgForeignDataWrapperObject(newForeignServer->GetForeignDataWrapper(), factory, newName) 106 { 107 SetForeignServer(newForeignServer); 108 } 109 pgForeignServerObject(pgForeignServer *newForeignServer, int newType, const wxString &newName = wxT("")) : pgForeignDataWrapperObject(newForeignServer->GetForeignDataWrapper(), newType, newName) 110 { 111 SetForeignServer(newForeignServer); 112 } 113 114 bool CanDrop(); CanEdit()115 bool CanEdit() 116 { 117 return true; 118 } 119 bool CanCreate(); 120 121 void SetForeignServer(pgForeignServer *newForeignServer); GetForeignServer()122 virtual pgForeignServer *GetForeignServer() const 123 { 124 return srv; 125 } 126 pgSet *ExecuteSet(const wxString &sql); 127 wxString ExecuteScalar(const wxString &sql); 128 bool ExecuteVoid(const wxString &sql); 129 130 131 protected: 132 virtual void SetContextInfo(frmMain *form); 133 134 pgForeignServer *srv; 135 }; 136 137 138 class pgForeignServerObjCollection : public pgCollection 139 { 140 public: 141 pgForeignServerObjCollection(pgaFactory *factory, pgForeignServer *newsrv); 142 wxString GetTranslatedMessage(int kindOfMessage) const; 143 }; 144 145 #endif 146