1/*************** FilAMap H Declares Source Code File (.H) **************/
2/* Name: FILAMAP.H Version 1.3 */
3/* */
4/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
5/* */
6/* This file contains the MAP file access method classes declares. */
7/***********************************************************************/
8#ifndef __FILAMAP_H
9#define __FILAMAP_H
10
11#include "block.h"
12#include "filamtxt.h"
13
14typedef class MAPFAM *PMAPFAM;
15
16/***********************************************************************/
17/* This is the variable file access method using file mapping. */
18/***********************************************************************/
19class DllExport MAPFAM : public TXTFAM {
20 friend class TDBJSON;
21 public:
22 // Constructor
23 MAPFAM(PDOSDEF tdp);
24 MAPFAM(PMAPFAM tmfp);
25
26 // Implementation
27 virtual AMT GetAmType(void) {return TYPE_AM_MAP;}
28 virtual int GetPos(void);
29 virtual int GetNextPos(void);
30 virtual PTXF Duplicate(PGLOBAL g)
31 {return (PTXF)new(g) MAPFAM(this);}
32
33 // Methods
34 virtual void Reset(void);
35 virtual int GetFileLength(PGLOBAL g);
36 virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
37 virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
38 virtual int GetRowID(void);
39 virtual bool RecordPos(PGLOBAL g);
40 virtual bool SetPos(PGLOBAL g, int recpos);
41 virtual int SkipRecord(PGLOBAL g, bool header);
42 virtual bool OpenTableFile(PGLOBAL g);
43 virtual bool DeferReading(void) {return false;}
44 virtual int GetNext(PGLOBAL g) {return RC_EF;}
45 virtual int ReadBuffer(PGLOBAL g);
46 virtual int WriteBuffer(PGLOBAL g);
47 virtual int DeleteRecords(PGLOBAL g, int irc);
48 virtual void CloseTableFile(PGLOBAL g, bool abort);
49 virtual void Rewind(void);
50
51 protected:
52 virtual int InitDelete(PGLOBAL g, int fpos, int spos);
53
54 // Members
55 char *Memory; // Pointer on file mapping view.
56 char *Mempos; // Position of next data to read
57 char *Fpos; // Position of last read record
58 char *Tpos; // Target Position for delete move
59 char *Spos; // Start position for delete move
60 char *Top; // Mark end of file mapping view
61 }; // end of class MAPFAM
62
63/***********************************************************************/
64/* This is the blocked file access method using file mapping. */
65/***********************************************************************/
66class DllExport MBKFAM : public MAPFAM {
67 public:
68 // Constructor
69 MBKFAM(PDOSDEF tdp);
70 MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
71
72 // Implementation
73 virtual PTXF Duplicate(PGLOBAL g)
74 {return (PTXF)new(g) MBKFAM(this);}
75
76 // Methods
77 virtual void Reset(void);
78 virtual int Cardinality(PGLOBAL g);
79 virtual int MaxBlkSize(PGLOBAL g, int s)
80 {return TXTFAM::MaxBlkSize(g, s);}
81 virtual int GetRowID(void);
82 virtual int SkipRecord(PGLOBAL g, bool header);
83 virtual int ReadBuffer(PGLOBAL g);
84 virtual void Rewind(void);
85
86 protected:
87 // No additional members
88 }; // end of class MBKFAM
89
90/***********************************************************************/
91/* This is the fixed file access method using file mapping. */
92/***********************************************************************/
93class DllExport MPXFAM : public MBKFAM {
94 public:
95 // Constructor
96 MPXFAM(PDOSDEF tdp);
97 MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {}
98
99 // Implementation
100 virtual int GetPos(void);
101 virtual PTXF Duplicate(PGLOBAL g)
102 {return (PTXF)new(g) MPXFAM(this);}
103
104 // Methods
105 virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
106 virtual int MaxBlkSize(PGLOBAL g, int s)
107 {return TXTFAM::MaxBlkSize(g, s);}
108 virtual bool SetPos(PGLOBAL g, int recpos);
109 virtual int GetNextPos(void) {return GetPos() + 1;}
110 virtual bool DeferReading(void) {return false;}
111 virtual int ReadBuffer(PGLOBAL g);
112 virtual int WriteBuffer(PGLOBAL g);
113
114 protected:
115 virtual int InitDelete(PGLOBAL g, int fpos, int spos);
116
117 // No additional members
118 }; // end of class MPXFAM
119
120#endif // __FILAMAP_H
121