1 //-------------------------------------------------------------------------
2 //
3 //  For conditions of distribution and use, see copyright notice
4 //  in Flashpix.h
5 //
6 //  Copyright (c) 1999 Digital Imaging Group, Inc.
7 //
8 //  Contents: Double-indirect Fat class headers
9 //
10 //  Classes:  CDIFat
11 //    CDIFatVector
12 //
13 //  Functions:
14 //
15 //--------------------------------------------------------------------------
16 
17 #ifndef __DIFAT_HXX__
18 #define __DIFAT_HXX__
19 
20 //+-------------------------------------------------------------------------
21 //
22 //  Class:      CDIFat (dif)
23 //
24 //  Purpose:    Double Indirect Fat class for MSF
25 //
26 //  Interface:  See below.
27 //
28 //--------------------------------------------------------------------------
29 
30 class CDIFat
31 {
32 
33 public:
34     CDIFat(USHORT cbSector);
35     inline ~CDIFat();
36 
37     VOID Empty();
38 
39 
40     SCODE   GetFatSect(const FSINDEX oSect, SECT *psect);
41     SCODE   SetFatSect(const FSINDEX oSect, const SECT sect);
42 
43     SCODE   GetSect(const FSINDEX oSect, SECT *psect);
44 
45     SCODE   Init(CMStream *pmsParent, const FSINDEX cFatSect);
46     SCODE   InitConvert(CMStream *pmsParent, SECT sectMax);
47     inline SCODE InitNew(CMStream *pmsParent);
48 
49 
50     SCODE   Flush(void);
51 
52     inline void SetParent(CMStream *pms);
53 private:
54 
55     CFatVector _fv;
56     CMStream  * _pmsParent;
57     FSINDEX _cfsTable;
58 
59     SCODE   Resize(FSINDEX fsiSize);
60 
61     inline VOID SectToPair(
62             SECT sect,
63             FSINDEX *pipfs,
64             FSOFFSET *pisect) const;
65 
66     SECT    PairToSect(FSINDEX ipfs, FSOFFSET isect) const;
67 #ifdef _MSC_VER
68 #pragma warning(disable:4512)
69 // since there is a const member, there should be no assignment operator
70 #endif // _MSC_VER
71 };
72 #ifdef _MSC_VER
73 #pragma warning(default:4512)
74 // since there is a const member, there should be no assignment operator
75 #endif // _MSC_VER
76 
77 //+-------------------------------------------------------------------------
78 //
79 //  Method:     CDIFat::~CDIFat, public
80 //
81 //  Synopsis:   CDIFat destructor
82 //
83 //--------------------------------------------------------------------------
84 
~CDIFat()85 inline CDIFat::~CDIFat()
86 {
87     msfDebugOut((DEB_TRACE,"In CDIFat destructor\n"));
88 }
89 
90 
SectToPair(FSINDEX sect,FSINDEX * pipfs,FSOFFSET * pisect) const91 inline VOID CDIFat::SectToPair(FSINDEX sect, FSINDEX *pipfs, FSOFFSET *pisect) const
92 {
93     msfAssert(sect >= CSECTFAT);
94 
95     sect = sect - CSECTFAT;
96     *pipfs = (FSINDEX)(sect / _fv.GetSectTable());
97     *pisect = (FSOFFSET)(sect % _fv.GetSectTable());
98 }
99 
PairToSect(FSINDEX ipfs,FSOFFSET isect) const100 inline SECT CDIFat::PairToSect(FSINDEX ipfs, FSOFFSET isect) const
101 {
102     return ipfs * _fv.GetSectTable() + isect + CSECTFAT;
103 }
104 
105 //+-------------------------------------------------------------------------
106 //
107 //  Method:     CDIFat::InitNew, public
108 //
109 //  Synopsis:   Init function for new DIFat
110 //
111 //  Arguments:  None.
112 //
113 //  Returns:    S_OK if call completed successfully.
114 //
115 //  Algorithm:  Doesn't do anything at present.
116 //
117 //--------------------------------------------------------------------------
118 
InitNew(CMStream * pmsParent)119 inline SCODE CDIFat::InitNew(CMStream  *pmsParent)
120 {
121     _pmsParent = pmsParent;
122     _fv.Init(_pmsParent, 0);
123     _cfsTable = 0;
124     return S_OK;
125 }
126 
127 
SetParent(CMStream * pms)128 inline void CDIFat::SetParent(CMStream  *pms)
129 {
130     _pmsParent = pms;
131     _fv.SetParent(pms);
132 }
133 
134 
135 
136 
137 #endif //__DIFAT_HXX__
138