summaryrefslogtreecommitdiffstats
path: root/private/ole32/stg/h/vect.hxx
blob: a37536d44b7e84f0fc94c992293bc473503e20fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1992.
//
//  File:	vect.hxx
//
//  Contents:	Vector common types
//
//  Classes:	CVectBits -- Bit fields for vectors
//
//  History:    06-Aug-92 	PhilipLa	Created.
//
//--------------------------------------------------------------------------

#ifndef __VECT_HXX__
#define __VECT_HXX__

#include <page.hxx>


//+-------------------------------------------------------------------------
//
//  Class:      CVectBits (vb)
//
//  Purpose:    Structure for Vector flags.
//
//  Interface:
//
//  History:    06-Aug-92   PhilipLa    Created.
//
//  Notes:
//
//--------------------------------------------------------------------------

struct CVectBits
{
    USHORT    full:1;
    USHORT    firstfree;
};
SAFE_DFBASED_PTR(CBasedVectBitsPtr, CVectBits);

//+-------------------------------------------------------------------------
//
//  Class:      CPagedVector (pv)
//
//  Purpose:    *Finish This*
//
//  Interface:
//
//  History:    27-Sep-92   PhilipLa    Created.
//
//  Notes:
//
//--------------------------------------------------------------------------

class CPagedVector
{
public:
    inline VECT_CLASS CPagedVector(const SID sid);

    SCODE VECT_CLASS Init(CMStream *pms, ULONG ulSize);
#ifndef REF
    void VECT_CLASS InitCopy(CPagedVector *pvectOld);
#endif //!REF

    VECT_CLASS ~CPagedVector();

    void Empty(void);


    SCODE VECT_CLASS Resize(ULONG ulSize);

    SCODE Flush(void);

    SCODE GetTableWithSect(
            const ULONG iTable,
            DWORD dwFlags,
            SECT sectKnown,
            void **ppmp);
    
    inline SCODE GetTable(const ULONG iTable, DWORD dwFlags, void **ppmp);
    inline void ReleaseTable(const ULONG iTable);

    inline void SetSect(const ULONG iTable, const SECT sect);

    inline CVectBits * GetBits(const ULONG iTable);

    inline void ResetBits(void);

    SCODE SetDirty(ULONG iTable);
    inline void ResetDirty(ULONG iTable);

    inline void FreeTable(ULONG iTable);

    inline CMStream * GetParent(void) const;
    inline void SetParent(CMStream *pms);

private:

    inline CVectBits * GetNewVectBits(ULONG ulSize);
    inline CBasedMSFPagePtr * GetNewPageArray(ULONG ulSize);

    CBasedMSFPageTablePtr _pmpt;
    const SID _sid;

    ULONG _ulSize;          //  Amount in use
    ULONG _ulAllocSize;     //  Amount allocated

    CBasedMStreamPtr    _pmsParent;

    CBasedMSFPagePtrPtr _amp;
    CBasedVectBitsPtr _avb;
};

#ifdef CODESEGMENTS
#pragma code_seg(SEG_CPagedVector_CPagedVector)
#endif

inline VECT_CLASS CPagedVector::CPagedVector(const SID sid)
: _sid(sid),
  _pmpt(NULL),
  _amp(NULL),
  _avb(NULL),
  _pmsParent(NULL)
{
    _ulSize = 0;
    _ulAllocSize = 0;
}

#ifdef CODESEGMENTS
#pragma code_seg()
#endif


//+---------------------------------------------------------------------------
//
//  Member:	CPagedVector::GetTable, public
//
//  Synopsis:	Inline function - calls through to GetTableWithSect,
//              passing a sect that indicates we don't know the
//              location of the page.
//
//  History:	28-Jun-94	PhilipLa	Created
//
//----------------------------------------------------------------------------

inline SCODE CPagedVector::GetTable(
        const ULONG iTable,
        DWORD dwFlags,
        void **ppmp)
{
    return GetTableWithSect(iTable, dwFlags, ENDOFCHAIN, ppmp);
}

#endif //__VECT_HXX__