summaryrefslogtreecommitdiffstats
path: root/private/ole32/stg/exp/resource.hxx
blob: b4c619d62dce30a94d05b2fe11c6670a48bc20cc (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
//+---------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (C) Microsoft Corporation, 1992 - 1994.
//
//  File:	resource.hxx
//
//  Contents:	Transacted resource manager header file
//
//  Classes:	
//
//  Functions:	
//
//  History:	03-Jul-95	PhilipLa	Created
//
//----------------------------------------------------------------------------

#ifndef __RESOURCE_HXX__
#define __RESOURCE_HXX__

#include <msf.hxx>

#ifdef COORD
#include <oledb.h>
#include <dfrlist.hxx>
#include <expdf.hxx>

struct SExpDocfileList
{
    CExposedDocFile *pexp;
    SExpDocfileList *pedlNext;
};


//ITransactionResourceManagement is brought in by ITransactionResource
class CDocfileResource:
    public ITransactionResource,
    public ITransactionResourceRecover,
    public ITransactionResourceAsync
{
public:

    CDocfileResource(BOOL fStatic = FALSE);
    ~CDocfileResource();

    SCODE Init(ITransactionEnlistment *pte);
    
    //From IUnknown
    STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
    STDMETHOD_(ULONG,AddRef)(void);
    STDMETHOD_(ULONG,Release)(void);

    //From ITransactionResourceManagement
    STDMETHOD(Defect)(BOOL fInformCoordinator);

    //From ITransactionResource
    STDMETHOD(Prepare)(BOOL fRetaining,
                       DWORD grfRM,
                       BOOL fSinglePhase,
                       IMoniker **ppmk,
                       BOID **ppboidReason);
    STDMETHOD(Commit)(DWORD grfRM, XACTUOW *pNewUOW);
    STDMETHOD(Abort)(BOID *pboidReason, BOOL fRetaining, XACTUOW *pNewUOW);

    //From ITransactionResourceRecover
    STDMETHOD(GetMoniker)(IMoniker **ppmk);
    STDMETHOD(ReEnlist)(ITransactionCoordinator *pEnlistment,
                        XACTUOW *pUOWCur);

    //From ITransactionResourceAsync
    STDMETHOD(PrepareRequest)(BOOL fRetaining,
                              DWORD grfRM,
                              BOOL fWantMoniker,
                              BOOL fSinglePhase);
    STDMETHOD(CommitRequest)(DWORD grfRM, XACTUOW *pNewUOW);
    STDMETHOD(AbortRequest)(BOID *pboidReason,
                            BOOL fRetaining,
                            XACTUOW *pNewUOW);

    SCODE Enlist(ITransactionCoordinator *ptc);
    SCODE Join(CExposedDocFile *ped);
//    SCODE Leave(CExposedDocfile *ped);
    
    inline CDocfileResource * GetNext(void);
    inline CDocfileResource * GetPrev(void);

    inline void SetNext(CDocfileResource *pdrNext);
    inline void SetPrev(CDocfileResource *pdrPrev);

    inline XACTUOW GetUOW(void);
    
private:
    LONG _cReferences;
    const BOOL _fStatic;

    ITransactionEnlistment *_pte;
    XACTTRANSINFO _xti;

    SExpDocfileList *_pedlHead;
    
    //We also will maintain a list of these things.
    CDocfileResource *_pdrPrev;
    CDocfileResource *_pdrNext;
};


inline CDocfileResource * CDocfileResource::GetNext(void)
{
    return _pdrNext;
}

inline CDocfileResource * CDocfileResource::GetPrev(void)
{
    return _pdrPrev;
}

inline void CDocfileResource::SetNext(CDocfileResource *pdrNext)
{
    _pdrNext = pdrNext;
}

inline void CDocfileResource::SetPrev(CDocfileResource *pdrPrev)
{
    _pdrPrev = pdrPrev;
}

inline XACTUOW CDocfileResource::GetUOW(void)
{
    return _xti.uow;
}

//Use a static object for the head of the list, to simplify adding and
//  deleting members.
extern CDocfileResource g_dfrHead;

//BUGBUG:  This should really be defined someplace globally.
#ifndef IsEqualBOID
inline BOOL IsEqualBOID(BOID rboid1, BOID rboid2)
{
    return !memcmp(&rboid1, &rboid2, sizeof(BOID));
}
#endif

#endif //COORD
#endif // #ifndef __RESOURCE_HXX__