1 /**************** tdbvir H Declares Source Code File (.H) **************/ 2 /* Name: TDBVIR.H Version 1.1 */ 3 /* */ 4 /* (C) Copyright to the author Olivier BERTRAND 2006-2014 */ 5 /* */ 6 /* This file contains the VIR classes declare code. */ 7 /***********************************************************************/ 8 typedef class VIRDEF *PVIRDEF; 9 typedef class TDBVIR *PTDBVIR; 10 11 /***********************************************************************/ 12 /* Return the unique column definition to MariaDB. */ 13 /***********************************************************************/ 14 PQRYRES VirColumns(PGLOBAL g, bool info); 15 16 /* --------------------------- VIR classes --------------------------- */ 17 18 /***********************************************************************/ 19 /* VIR: Virtual table used to select constant values. */ 20 /***********************************************************************/ 21 class DllExport VIRDEF : public TABDEF { /* Logical table description */ 22 public: 23 // Constructor VIRDEF(void)24 VIRDEF(void) {} 25 26 // Implementation GetType(void)27 virtual const char *GetType(void) {return "VIRTUAL";} 28 29 // Methods DefineAM(PGLOBAL,LPCSTR,int)30 virtual bool DefineAM(PGLOBAL, LPCSTR, int) {Pseudo = 3; return false;} Indexable(void)31 virtual int Indexable(void) {return 3;} 32 virtual PTDB GetTable(PGLOBAL g, MODE m); 33 34 protected: 35 // Members 36 }; // end of VIRDEF 37 38 /***********************************************************************/ 39 /* This is the class declaration for the Virtual table. */ 40 /***********************************************************************/ 41 class DllExport TDBVIR : public TDBASE { 42 public: 43 // Constructors 44 TDBVIR(PVIRDEF tdp); 45 46 // Implementation GetAmType(void)47 virtual AMT GetAmType(void) {return TYPE_AM_VIR;} 48 49 // Methods GetRecpos(void)50 virtual int GetRecpos(void) {return N;} SetRecpos(PGLOBAL g,int recpos)51 virtual bool SetRecpos(PGLOBAL g, int recpos) 52 {N = recpos - 2; return false;} 53 virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} 54 int TestFilter(PFIL filp, bool nop); 55 56 // Database routines 57 virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); Cardinality(PGLOBAL g)58 virtual int Cardinality(PGLOBAL g) {return (g) ? Size : 1;} GetMaxSize(PGLOBAL g)59 virtual int GetMaxSize(PGLOBAL g) {return Size;} 60 virtual bool OpenDB(PGLOBAL g); 61 virtual int ReadDB(PGLOBAL g); 62 virtual int WriteDB(PGLOBAL g); 63 virtual int DeleteDB(PGLOBAL g, int irc); CloseDB(PGLOBAL g)64 virtual void CloseDB(PGLOBAL g) {} 65 66 protected: 67 // Members 68 int Size; // Table size 69 int N; // The VIR table current position 70 }; // end of class TDBVIR 71 72 /***********************************************************************/ 73 /* Class VIRCOL: VIRTUAL access method column descriptor. */ 74 /***********************************************************************/ 75 class VIRCOL : public COLBLK { 76 friend class TDBVIR; 77 public: 78 // Constructors 79 VIRCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "VIRTUAL"); 80 81 // Implementation GetAmType(void)82 virtual int GetAmType(void) {return TYPE_AM_VIR;} 83 84 // Methods 85 virtual void ReadColumn(PGLOBAL g); 86 87 protected: 88 // Default constructor not to be used VIRCOL(void)89 VIRCOL(void) {} 90 91 // No additional members 92 }; // end of class VIRCOL 93 94 /***********************************************************************/ 95 /* This is the class declaration for the VIR column catalog table. */ 96 /***********************************************************************/ 97 class TDBVICL : public TDBCAT { 98 public: 99 // Constructor TDBVICL(PVIRDEF tdp)100 TDBVICL(PVIRDEF tdp) : TDBCAT(tdp) {} 101 102 // Methods Cardinality(PGLOBAL g)103 virtual int Cardinality(PGLOBAL g) {return 2;} // Avoid DBUG_ASSERT 104 105 protected: 106 // Specific routines 107 virtual PQRYRES GetResult(PGLOBAL g); 108 109 // Members 110 }; // end of class TDBVICL 111