1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1999
20
* the Initial Developer. All Rights Reserved.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
55
#include "morkHandle.h"
62
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
64
#define morkMagic_kEnv 0x456E7669 /* ascii 'Envi' */
68
class orkinEnv : public morkHandle, public nsIMdbEnv { // nsIMdbObject
70
// { ===== begin morkNode interface =====
71
public: // morkNode virtual methods
72
virtual void CloseMorkNode(morkEnv* ev); // override to clean up mork env
73
virtual ~orkinEnv(); // morkHandle destructor does everything
75
protected: // construction is protected (use the static Make() method)
76
orkinEnv(morkEnv* ev, // note morkUsage is always morkUsage_kPool
77
morkHandleFace* ioFace, // must not be nil, cookie for this handle
78
morkEnv* ioObject); // must not be nil, the object for this handle
80
// void CloseHandle(morkEnv* ev); // don't need to specialize closing
82
private: // copying is not allowed
83
orkinEnv(const morkHandle& other);
84
orkinEnv& operator=(const morkHandle& other);
86
// public: // dynamic type identification
87
// mork_bool IsHandle() const //
88
// { return IsNode() && mNode_Derived == morkDerived_kHandle; }
89
// } ===== end morkNode methods =====
91
protected: // morkHandle memory management operators
92
void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
93
{ return ioPool.NewHandle(ev, inSize, &ioZone); }
95
void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
96
{ return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
98
void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
99
{ MORK_USED_1(inSize); return ioFace; }
102
public: // construction:
104
static orkinEnv* MakeEnv(morkEnv* ev, morkEnv* ioObject);
106
public: // utilities:
108
morkEnv* CanUseEnv(mork_bool inMutable, mdb_err* outErr) const;
110
public: // type identification
111
mork_bool IsOrkinEnv() const
112
{ return mHandle_Magic == morkMagic_kEnv; }
114
mork_bool IsOrkinEnvHandle() const
115
{ return this->IsHandle() && this->IsOrkinEnv(); }
120
// { ===== begin nsIMdbObject methods =====
122
// { ----- begin attribute methods -----
123
NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
124
// same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
125
// } ----- end attribute methods -----
127
// { ----- begin factory methods -----
128
NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
129
// } ----- end factory methods -----
131
// { ----- begin ref counting for well-behaved cyclic graphs -----
132
NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
133
mdb_count* outCount);
134
NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
135
mdb_count* outCount);
137
NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
138
NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
140
NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
141
NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
143
NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
144
NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
145
// } ----- end ref counting -----
147
// } ===== end nsIMdbObject methods =====
149
// { ===== begin nsIMdbEnv methods =====
151
// { ----- begin attribute methods -----
152
NS_IMETHOD GetErrorCount(mdb_count* outCount,
153
mdb_bool* outShouldAbort);
154
NS_IMETHOD GetWarningCount(mdb_count* outCount,
155
mdb_bool* outShouldAbort);
157
NS_IMETHOD GetEnvBeVerbose(mdb_bool* outBeVerbose);
158
NS_IMETHOD SetEnvBeVerbose(mdb_bool inBeVerbose);
160
NS_IMETHOD GetDoTrace(mdb_bool* outDoTrace);
161
NS_IMETHOD SetDoTrace(mdb_bool inDoTrace);
163
NS_IMETHOD GetAutoClear(mdb_bool* outAutoClear);
164
NS_IMETHOD SetAutoClear(mdb_bool inAutoClear);
166
NS_IMETHOD GetErrorHook(nsIMdbErrorHook** acqErrorHook);
167
NS_IMETHOD SetErrorHook(
168
nsIMdbErrorHook* ioErrorHook); // becomes referenced
170
NS_IMETHOD GetHeap(nsIMdbHeap** acqHeap);
172
nsIMdbHeap* ioHeap); // becomes referenced
173
// } ----- end attribute methods -----
175
NS_IMETHOD ClearErrors(); // clear errors beore re-entering db API
176
NS_IMETHOD ClearWarnings(); // clear warnings
177
NS_IMETHOD ClearErrorsAndWarnings(); // clear both errors & warnings
178
// } ===== end nsIMdbEnv methods =====
181
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
183
#endif /* _ORKINENV_ */