Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / db / mork / src / orkinSorting.h
blob498f2c03a242ad9d3705051df5427bfbf7413638
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 _ORKINSORTING_
39 #define _ORKINSORTING_ 1
41 #ifndef _MDB_
42 #include "mdb.h"
43 #endif
45 #ifndef _MORK_
46 #include "mork.h"
47 #endif
49 #ifndef _MORKNODE_
50 #include "morkNode.h"
51 #endif
53 #ifndef _MORKHANDLE_
54 #include "morkHandle.h"
55 #endif
57 #ifndef _MORKSORTING_
58 #include "morkSorting.h"
59 #endif
61 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
63 #define morkMagic_kSorting 0x536F7274 /* ascii 'Sort' */
65 /*| orkinSorting:
66 |*/
67 class orkinSorting : public morkHandle, public nsIMdbSorting { // nsIMdbSorting
69 // { ===== begin morkNode interface =====
70 public: // morkNode virtual methods
71 // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
72 virtual ~orkinSorting(); // morkHandle destructor does everything
74 protected: // construction is protected (use the static Make() method)
75 orkinSorting(morkEnv* ev, // note morkUsage is always morkUsage_kPool
76 morkHandleFace* ioFace, // must not be nil, cookie for this handle
77 morkSorting* ioObject); // must not be nil, the object for this handle
79 // void CloseHandle(morkEnv* ev); // don't need to specialize closing
81 private: // copying is not allowed
82 orkinSorting(const orkinSorting& other);
83 orkinSorting& operator=(const orkinSorting& other);
85 // public: // dynamic type identification
86 // mork_bool IsHandle() const //
87 // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
88 // } ===== end morkNode methods =====
90 protected: // morkHandle memory management operators
91 void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
92 { return ioPool.NewHandle(ev, inSize, &ioZone); }
94 void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
95 { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
97 void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
98 { MORK_USED_1(inSize); return ioFace; }
101 public: // construction:
103 static orkinSorting* MakeSorting(morkEnv* ev, morkSorting* ioObject);
105 public: // utilities:
107 morkEnv* CanUseSorting(nsIMdbEnv* mev, mork_bool inMutable,
108 mdb_err* outErr) const;
110 public: // type identification
111 mork_bool IsOrkinSorting() const
112 { return mHandle_Magic == morkMagic_kSorting; }
114 mork_bool IsOrkinSortingHandle() const
115 { return this->IsHandle() && this->IsOrkinSorting(); }
117 NS_DECL_ISUPPORTS
118 // { ===== begin nsIMdbObject methods =====
120 // { ----- begin attribute methods -----
121 NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
122 // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
123 // } ----- end attribute methods -----
125 // { ----- begin factory methods -----
126 NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory);
127 // } ----- end factory methods -----
129 // { ----- begin ref counting for well-behaved cyclic graphs -----
130 NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
131 mdb_count* outCount);
132 NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
133 mdb_count* outCount);
135 NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
136 NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
138 NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
139 NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
141 NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
142 NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
143 // } ----- end ref counting -----
145 // } ===== end nsIMdbObject methods =====
147 // { ===== begin nsIMdbSorting methods =====
149 // { ----- begin attribute methods -----
150 // sorting: note all rows are assumed sorted by row ID as a secondary
151 // sort following the primary column sort, when table rows are sorted.
153 NS_IMETHOD GetTable(nsIMdbEnv* ev, nsIMdbTable** acqTable);
154 NS_IMETHOD GetSortColumn( // query which col is currently sorted
155 nsIMdbEnv* ev, // context
156 mdb_column* outColumn); // col the table uses for sorting (or zero)
158 NS_IMETHOD SetNewCompare(nsIMdbEnv* ev,
159 nsIMdbCompare* ioNewCompare);
160 // Setting the sorting's compare object will typically cause the rows
161 // to be resorted, presumably in a lazy fashion when the sorting is
162 // next required to be in a valid row ordering state, such as when a
163 // call to PosToOid() happens. ioNewCompare can be nil, in which case
164 // implementations should revert to the default sort order, which must
165 // be equivalent to whatever is used by nsIMdbFactory::MakeCompare().
167 NS_IMETHOD GetOldCompare(nsIMdbEnv* ev,
168 nsIMdbCompare** acqOldCompare);
169 // Get this sorting instance's compare object, which handles the
170 // ordering of rows in the sorting, by comparing yarns from the cells
171 // in the column being sorted. Since nsIMdbCompare has no interface
172 // to query the state of the compare object, it is not clear what you
173 // would do with this object when returned, except maybe compare it
174 // as a pointer address to some other instance, to check identities.
176 // } ----- end attribute methods -----
178 // { ----- begin cursor methods -----
179 NS_IMETHOD GetSortingRowCursor( // make a cursor, starting at inRowPos
180 nsIMdbEnv* ev, // context
181 mdb_pos inRowPos, // zero-based ordinal position of row in table
182 nsIMdbTableRowCursor** acqCursor); // acquire new cursor instance
183 // A cursor interface turning same info as PosToOid() or PosToRow().
184 // } ----- end row position methods -----
186 // { ----- begin row position methods -----
187 NS_IMETHOD PosToOid( // get row member for a table position
188 nsIMdbEnv* ev, // context
189 mdb_pos inRowPos, // zero-based ordinal position of row in table
190 mdbOid* outOid); // row oid at the specified position
192 NS_IMETHOD PosToRow( // test for the table position of a row member
193 nsIMdbEnv* ev, // context
194 mdb_pos inRowPos, // zero-based ordinal position of row in table
195 nsIMdbRow** acqRow); // acquire row at table position inRowPos
196 // } ----- end row position methods -----
198 // } ===== end nsIMdbSorting methods =====
202 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
204 #endif /* _ORKINSORTING_ */