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
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.
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 _ORKINROWCELLCURSOR_
39 #define _ORKINROWCELLCURSOR_ 1
54 #include "morkHandle.h"
57 #ifndef _MORKROWCELLCURSOR_
58 #include "morkRowCellCursor.h"
61 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
63 #define morkMagic_kRowCellCursor 0x52634375 /* ascii 'RcCu' */
65 /*| orkinRowCellCursor: cursor class for iterating row cells
67 **|| row: the cursor is associated with a specific row, which can be
68 **| set to a different row (which resets the position to -1 so the
69 **| next cell acquired is the first in the row.
71 **|| NextCell: get the next cell in the row and return its position and
72 **| a new instance of a nsIMdbCell to represent this next cell.
74 class orkinRowCellCursor
:
75 public morkHandle
, public nsIMdbRowCellCursor
{ // nsIMdbCursor
77 // { ===== begin morkNode interface =====
78 public: // morkNode virtual methods
79 // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
80 virtual ~orkinRowCellCursor(); // morkHandle destructor does everything
82 protected: // construction is protected (use the static Make() method)
83 orkinRowCellCursor(morkEnv
* ev
, // note morkUsage is always morkUsage_kPool
84 morkHandleFace
* ioFace
, // must not be nil, cookie for this handle
85 morkRowCellCursor
* ioObject
); // must not be nil, the object for this handle
87 // void CloseHandle(morkEnv* ev); // don't need to specialize closing
89 private: // copying is not allowed
90 orkinRowCellCursor(const morkHandle
& other
);
91 orkinRowCellCursor
& operator=(const morkHandle
& other
);
93 // public: // dynamic type identification
94 // mork_bool IsHandle() const //
95 // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
96 // } ===== end morkNode methods =====
98 protected: // morkHandle memory management operators
99 void* operator new(size_t inSize
, morkPool
& ioPool
, morkZone
& ioZone
, morkEnv
* ev
) CPP_THROW_NEW
100 { return ioPool
.NewHandle(ev
, inSize
, &ioZone
); }
102 void* operator new(size_t inSize
, morkPool
& ioPool
, morkEnv
* ev
) CPP_THROW_NEW
103 { return ioPool
.NewHandle(ev
, inSize
, (morkZone
*) 0); }
105 void* operator new(size_t inSize
, morkHandleFace
* ioFace
) CPP_THROW_NEW
106 { MORK_USED_1(inSize
); return ioFace
; }
108 public: // construction:
110 static orkinRowCellCursor
* MakeRowCellCursor(morkEnv
* ev
,
111 morkRowCellCursor
* ioObject
);
113 public: // utilities:
115 morkEnv
* CanUseRowCellCursor(nsIMdbEnv
* mev
, mork_bool inMutable
,
116 mdb_err
* outErr
, morkRow
** outRow
) const;
118 public: // type identification
119 mork_bool
IsOrkinRowCellCursor() const
120 { return mHandle_Magic
== morkMagic_kRowCellCursor
; }
122 mork_bool
IsOrkinRowCellCursorHandle() const
123 { return this->IsHandle() && this->IsOrkinRowCellCursor(); }
126 // { ===== begin nsIMdbObject methods =====
128 // { ----- begin attribute methods -----
129 NS_IMETHOD
IsFrozenMdbObject(nsIMdbEnv
* ev
, mdb_bool
* outIsReadonly
);
130 // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
131 // } ----- end attribute methods -----
133 // { ----- begin factory methods -----
134 NS_IMETHOD
GetMdbFactory(nsIMdbEnv
* ev
, nsIMdbFactory
** acqFactory
);
135 // } ----- end factory methods -----
137 // { ----- begin ref counting for well-behaved cyclic graphs -----
138 NS_IMETHOD
GetWeakRefCount(nsIMdbEnv
* ev
, // weak refs
139 mdb_count
* outCount
);
140 NS_IMETHOD
GetStrongRefCount(nsIMdbEnv
* ev
, // strong refs
141 mdb_count
* outCount
);
143 NS_IMETHOD
AddWeakRef(nsIMdbEnv
* ev
);
144 NS_IMETHOD
AddStrongRef(nsIMdbEnv
* ev
);
146 NS_IMETHOD
CutWeakRef(nsIMdbEnv
* ev
);
147 NS_IMETHOD
CutStrongRef(nsIMdbEnv
* ev
);
149 NS_IMETHOD
CloseMdbObject(nsIMdbEnv
* ev
); // called at strong refs zero
150 NS_IMETHOD
IsOpenMdbObject(nsIMdbEnv
* ev
, mdb_bool
* outOpen
);
151 // } ----- end ref counting -----
153 // } ===== end nsIMdbObject methods =====
155 // { ===== begin nsIMdbCursor methods =====
157 // { ----- begin attribute methods -----
158 NS_IMETHOD
GetCount(nsIMdbEnv
* ev
, mdb_count
* outCount
); // readonly
159 NS_IMETHOD
GetSeed(nsIMdbEnv
* ev
, mdb_seed
* outSeed
); // readonly
161 NS_IMETHOD
SetPos(nsIMdbEnv
* ev
, mdb_pos inPos
); // mutable
162 NS_IMETHOD
GetPos(nsIMdbEnv
* ev
, mdb_pos
* outPos
);
164 NS_IMETHOD
SetDoFailOnSeedOutOfSync(nsIMdbEnv
* ev
, mdb_bool inFail
);
165 NS_IMETHOD
GetDoFailOnSeedOutOfSync(nsIMdbEnv
* ev
, mdb_bool
* outFail
);
166 // } ----- end attribute methods -----
168 // } ===== end nsIMdbCursor methods =====
170 // { ===== begin nsIMdbRowCellCursor methods =====
172 // { ----- begin attribute methods -----
173 NS_IMETHOD
SetRow(nsIMdbEnv
* ev
, nsIMdbRow
* ioRow
); // sets pos to -1
174 NS_IMETHOD
GetRow(nsIMdbEnv
* ev
, nsIMdbRow
** acqRow
);
175 // } ----- end attribute methods -----
177 // { ----- begin cell creation methods -----
178 NS_IMETHOD
MakeCell( // get cell at current pos in the row
179 nsIMdbEnv
* ev
, // context
180 mdb_column
* outColumn
, // column for this particular cell
181 mdb_pos
* outPos
, // position of cell in row sequence
182 nsIMdbCell
** acqCell
); // the cell at inPos
183 // } ----- end cell creation methods -----
185 // { ----- begin cell seeking methods -----
186 NS_IMETHOD
SeekCell( // same as SetRow() followed by MakeCell()
187 nsIMdbEnv
* ev
, // context
188 mdb_pos inPos
, // position of cell in row sequence
189 mdb_column
* outColumn
, // column for this particular cell
190 nsIMdbCell
** acqCell
); // the cell at inPos
191 // } ----- end cell seeking methods -----
193 // { ----- begin cell iteration methods -----
194 NS_IMETHOD
NextCell( // get next cell in the row
195 nsIMdbEnv
* ev
, // context
196 nsIMdbCell
* ioCell
, // changes to the next cell in the iteration
197 mdb_column
* outColumn
, // column for this particular cell
198 mdb_pos
* outPos
); // position of cell in row sequence
200 NS_IMETHOD
PickNextCell( // get next cell in row within filter set
201 nsIMdbEnv
* ev
, // context
202 nsIMdbCell
* ioCell
, // changes to the next cell in the iteration
203 const mdbColumnSet
* inFilterSet
, // col set of actual caller interest
204 mdb_column
* outColumn
, // column for this particular cell
205 mdb_pos
* outPos
); // position of cell in row sequence
207 // Note that inFilterSet should not have too many (many more than 10?)
208 // cols, since this might imply a potential excessive consumption of time
209 // over many cursor calls when looking for column and filter intersection.
210 // } ----- end cell iteration methods -----
212 // } ===== end nsIMdbRowCellCursor methods =====
215 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
217 #endif /* _ORKINROWCELLCURSOR_ */