Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / db / mork / src / morkPortTableCursor.h
bloba93445035457a3574d7c27e976e8ac8d0040459a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
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
13 * License.
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.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef _MORKPORTTABLECURSOR_
39 #define _MORKPORTTABLECURSOR_ 1
41 #ifndef _MORK_
42 #include "mork.h"
43 #endif
45 #ifndef _MORKCURSOR_
46 #include "morkCursor.h"
47 #endif
49 #ifndef _MORKROWSPACE_
50 #include "morkRowSpace.h"
51 #endif
53 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
55 class orkinPortTableCursor;
56 #define morkDerived_kPortTableCursor /*i*/ 0x7443 /* ascii 'tC' */
58 class morkPortTableCursor : public morkCursor, public nsIMdbPortTableCursor { // row iterator
59 public:
60 NS_DECL_ISUPPORTS_INHERITED
61 // public: // slots inherited from morkObject (meant to inform only)
62 // nsIMdbHeap* mNode_Heap;
63 // mork_able mNode_Mutable; // can this node be modified?
64 // mork_load mNode_Load; // is this node clean or dirty?
65 // mork_base mNode_Base; // must equal morkBase_kNode
66 // mork_derived mNode_Derived; // depends on specific node subclass
67 // mork_access mNode_Access; // kOpen, kClosing, kShut, or kDead
68 // mork_usage mNode_Usage; // kHeap, kStack, kMember, kGlobal, kNone
69 // mork_uses mNode_Uses; // refcount for strong refs
70 // mork_refs mNode_Refs; // refcount for strong refs + weak refs
72 // morkFactory* mObject_Factory; // weak ref to suite factory
74 // mork_seed mCursor_Seed;
75 // mork_pos mCursor_Pos;
76 // mork_bool mCursor_DoFailOnSeedOutOfSync;
77 // mork_u1 mCursor_Pad[ 3 ]; // explicitly pad to u4 alignment
79 public: // state is public because the entire Mork system is private
80 // { ----- begin attribute methods -----
81 NS_IMETHOD SetPort(nsIMdbEnv* ev, nsIMdbPort* ioPort); // sets pos to -1
82 NS_IMETHOD GetPort(nsIMdbEnv* ev, nsIMdbPort** acqPort);
84 NS_IMETHOD SetRowScope(nsIMdbEnv* ev, // sets pos to -1
85 mdb_scope inRowScope);
86 NS_IMETHOD GetRowScope(nsIMdbEnv* ev, mdb_scope* outRowScope);
87 // setting row scope to zero iterates over all row scopes in port
89 NS_IMETHOD SetTableKind(nsIMdbEnv* ev, // sets pos to -1
90 mdb_kind inTableKind);
91 NS_IMETHOD GetTableKind(nsIMdbEnv* ev, mdb_kind* outTableKind);
92 // setting table kind to zero iterates over all table kinds in row scope
93 // } ----- end attribute methods -----
95 // { ----- begin table iteration methods -----
96 NS_IMETHOD NextTable( // get table at next position in the db
97 nsIMdbEnv* ev, // context
98 nsIMdbTable** acqTable); // the next table in the iteration
99 // } ----- end table iteration methods -----
100 morkStore* mPortTableCursor_Store; // weak ref to store
102 mdb_scope mPortTableCursor_RowScope;
103 mdb_kind mPortTableCursor_TableKind;
105 // We only care if LastTable is non-nil, so it is not refcounted;
106 // so you must never access table state or methods using LastTable:
108 morkTable* mPortTableCursor_LastTable; // nil or last table (no refcount)
109 morkRowSpace* mPortTableCursor_RowSpace; // current space (strong ref)
111 morkRowSpaceMapIter mPortTableCursor_SpaceIter; // iter over spaces
112 morkTableMapIter mPortTableCursor_TableIter; // iter over tables
114 // these booleans indicate when the table or space iterator is exhausted:
116 mork_bool mPortTableCursor_TablesDidEnd; // no more tables?
117 mork_bool mPortTableCursor_SpacesDidEnd; // no more spaces?
118 mork_u1 mPortTableCursor_Pad[ 2 ]; // for u4 alignment
120 // { ===== begin morkNode interface =====
121 public: // morkNode virtual methods
122 virtual void CloseMorkNode(morkEnv* ev); // ClosePortTableCursor()
123 virtual ~morkPortTableCursor(); // assert that close executed earlier
125 public: // morkPortTableCursor construction & destruction
126 morkPortTableCursor(morkEnv* ev, const morkUsage& inUsage,
127 nsIMdbHeap* ioHeap, morkStore* ioStore, mdb_scope inRowScope,
128 mdb_kind inTableKind, nsIMdbHeap* ioSlotHeap);
129 void ClosePortTableCursor(morkEnv* ev); // called by CloseMorkNode();
131 private: // copying is not allowed
132 morkPortTableCursor(const morkPortTableCursor& other);
133 morkPortTableCursor& operator=(const morkPortTableCursor& other);
135 public: // dynamic type identification
136 mork_bool IsPortTableCursor() const
137 { return IsNode() && mNode_Derived == morkDerived_kPortTableCursor; }
138 // } ===== end morkNode methods =====
140 protected: // utilities
142 void init_space_tables_map(morkEnv* ev);
144 public: // other cursor methods
146 static void NilCursorStoreError(morkEnv* ev);
147 static void NonPortTableCursorTypeError(morkEnv* ev);
149 morkEnv* CanUsePortTableCursor(nsIMdbEnv* mev,
150 mork_bool inMutable, mdb_err* outErr) const;
153 morkRowSpace* NextSpace(morkEnv* ev);
154 morkTable* NextTable(morkEnv* ev);
156 mork_bool SetRowScope(morkEnv* ev, mork_scope inRowScope);
157 mork_bool SetTableKind(morkEnv* ev, mork_kind inTableKind);
159 public: // typesafe refcounting inlines calling inherited morkNode methods
160 static void SlotWeakPortTableCursor(morkPortTableCursor* me,
161 morkEnv* ev, morkPortTableCursor** ioSlot)
162 { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
164 static void SlotStrongPortTableCursor(morkPortTableCursor* me,
165 morkEnv* ev, morkPortTableCursor** ioSlot)
166 { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
171 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
173 #endif /* _MORKPORTTABLECURSOR_ */