You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.0 KiB

  1. // TABOCCUR.H Olivier Bertrand 2013
  2. // Defines the OCCUR tables
  3. #include "tabutil.h"
  4. #define TYPE_AM_OCCUR (AMT)128
  5. typedef class OCCURDEF *POCCURDEF;
  6. typedef class TDBOCCUR *PTDBOCCUR;
  7. typedef class OCCURCOL *POCCURCOL;
  8. typedef class RANKCOL *PRANKCOL;
  9. typedef class SRTCOL *PSRTCOL;
  10. /* -------------------------- OCCUR classes -------------------------- */
  11. /***********************************************************************/
  12. /* OCCUR: OEM table that provides a view of a source table where the */
  13. /* contain of several columns of the source table is placed in only */
  14. /* one column, the OCCUR column, this resulting into several rows. */
  15. /***********************************************************************/
  16. /***********************************************************************/
  17. /* OCCUR table. */
  18. /***********************************************************************/
  19. class OCCURDEF : public PRXDEF { /* Logical table description */
  20. friend class TDBOCCUR;
  21. public:
  22. // Constructor
  23. OCCURDEF(void) {Pseudo = 3; Colist = Xcol = NULL;}
  24. // Implementation
  25. virtual const char *GetType(void) {return "OCCUR";}
  26. // Methods
  27. virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
  28. virtual PTDB GetTable(PGLOBAL g, MODE m);
  29. protected:
  30. // Members
  31. //char *Tabname; /* The source table name */
  32. char *Colist; /* The source column list */
  33. char *Xcol; /* The multiple occurence column */
  34. char *Rcol; /* The rank column */
  35. }; // end of OCCURDEF
  36. /***********************************************************************/
  37. /* This is the class declaration for the OCCUR table. */
  38. /***********************************************************************/
  39. class TDBOCCUR : public TDBPRX {
  40. friend class OCCURCOL;
  41. friend class RANKCOL;
  42. friend class SRTCOL;
  43. public:
  44. // Constructor
  45. TDBOCCUR(POCCURDEF tdp);
  46. // Implementation
  47. virtual AMT GetAmType(void) {return TYPE_AM_OCCUR;}
  48. void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;}
  49. // Methods
  50. //virtual int GetRecpos(void) {return N;}
  51. virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();}
  52. virtual int RowNumber(PGLOBAL g, bool b = FALSE);
  53. PTDB GetSourceTable(PGLOBAL g);
  54. int MakeColumnList(PGLOBAL g);
  55. // Database routines
  56. //virtual PCOL ColDB(PGLOBAL g, PSZ colname, int num);
  57. virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
  58. virtual int GetMaxSize(PGLOBAL g);
  59. virtual bool OpenDB(PGLOBAL g);
  60. virtual int ReadDB(PGLOBAL g);
  61. protected:
  62. // Members
  63. //PTDBASE Tdbp; // To the source table or view
  64. LPCSTR Tabname; // Name of source table
  65. char *Colist; // Source column list
  66. char *Xcolumn; // Occurence column name
  67. char *Rcolumn; // Rank column name
  68. POCCURCOL Xcolp; // To the OCCURCOL column
  69. PCOL *Col; // To source multiple columns
  70. int Mult; // Multiplication factor
  71. int N; // The current table index
  72. int M; // The occurence rank
  73. BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
  74. }; // end of class TDBOCCUR
  75. /***********************************************************************/
  76. /* Class OCCURCOL: for the multiple occurence column. */
  77. /***********************************************************************/
  78. class OCCURCOL : public COLBLK {
  79. public:
  80. // Constructors
  81. OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n);
  82. //OCCURCOL(OCCURCOL *colp, PTDB tdbp); // Constructor used in copy process
  83. // Implementation
  84. virtual int GetAmType(void) {return TYPE_AM_OCCUR;}
  85. int GetI(void) {return I;}
  86. // Methods
  87. virtual void Reset(void) {} // Evaluated only by TDBOCCUR
  88. virtual void ReadColumn(PGLOBAL g);
  89. void Xreset(void) {I = 0;};
  90. protected:
  91. // Default constructor not to be used
  92. OCCURCOL(void) {}
  93. // Members
  94. int I;
  95. }; // end of class OCCURCOL
  96. /***********************************************************************/
  97. /* Class RANKCOL: for the multiple occurence column ranking. */
  98. /***********************************************************************/
  99. class RANKCOL : public COLBLK {
  100. public:
  101. // Constructors
  102. RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {}
  103. //RANKCOL(RANKCOL *colp, PTDB tdbp); // Constructor used in copy process
  104. // Implementation
  105. virtual int GetAmType(void) {return TYPE_AM_OCCUR;}
  106. // Methods
  107. virtual void ReadColumn(PGLOBAL g);
  108. protected:
  109. // Default constructor not to be used
  110. RANKCOL(void) {}
  111. // Members
  112. }; // end of class RANKCOL
  113. /***********************************************************************/
  114. /* Definition of class XCOLDEF. */
  115. /* This class purpose is just to access COLDEF protected items! */
  116. /***********************************************************************/
  117. class XCOLDEF: public COLDEF {
  118. friend class TDBOCCUR;
  119. }; // end of class XCOLDEF