Back to index

lightning-sunbird  0.9+nobinonly
orkinRowCellCursor.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-  */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _ORKINROWCELLCURSOR_
00039 #define _ORKINROWCELLCURSOR_ 1
00040 
00041 #ifndef _MDB_
00042 #include "mdb.h"
00043 #endif
00044 
00045 #ifndef _MORK_
00046 #include "mork.h"
00047 #endif
00048 
00049 #ifndef _MORKNODE_
00050 #include "morkNode.h"
00051 #endif
00052 
00053 #ifndef _MORKHANDLE_
00054 #include "morkHandle.h"
00055 #endif
00056 
00057 #ifndef _MORKROWCELLCURSOR_
00058 #include "morkRowCellCursor.h"
00059 #endif
00060 
00061 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00062 
00063 #define morkMagic_kRowCellCursor 0x52634375 /* ascii 'RcCu' */
00064 
00065 /*| orkinRowCellCursor: cursor class for iterating row cells
00066 **|
00067 **|| row: the cursor is associated with a specific row, which can be
00068 **| set to a different row (which resets the position to -1 so the
00069 **| next cell acquired is the first in the row.
00070 **|
00071 **|| NextCell: get the next cell in the row and return its position and
00072 **| a new instance of a nsIMdbCell to represent this next cell.
00073 |*/
00074 class orkinRowCellCursor :
00075   public morkHandle, public nsIMdbRowCellCursor { // nsIMdbCursor
00076 
00077 // { ===== begin morkNode interface =====
00078 public: // morkNode virtual methods
00079   // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
00080   virtual ~orkinRowCellCursor(); // morkHandle destructor does everything
00081   
00082 protected: // construction is protected (use the static Make() method)
00083   orkinRowCellCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
00084     morkHandleFace* ioFace,    // must not be nil, cookie for this handle
00085     morkRowCellCursor* ioObject); // must not be nil, the object for this handle
00086     
00087   // void CloseHandle(morkEnv* ev); // don't need to specialize closing
00088 
00089 private: // copying is not allowed
00090   orkinRowCellCursor(const morkHandle& other);
00091   orkinRowCellCursor& operator=(const morkHandle& other);
00092 
00093 // public: // dynamic type identification
00094   // mork_bool IsHandle() const //
00095   // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
00096 // } ===== end morkNode methods =====
00097 
00098 protected: // morkHandle memory management operators
00099   void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
00100   { return ioPool.NewHandle(ev, inSize, &ioZone); }
00101   
00102   void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
00103   { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
00104   
00105   void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
00106   { MORK_USED_1(inSize); return ioFace; }
00107   
00108 public: // construction:
00109 
00110   static orkinRowCellCursor* MakeRowCellCursor(morkEnv* ev, 
00111     morkRowCellCursor* ioObject);
00112 
00113 public: // utilities:
00114 
00115   morkEnv* CanUseRowCellCursor(nsIMdbEnv* mev, mork_bool inMutable,
00116     mdb_err* outErr, morkRow** outRow) const;
00117 
00118 public: // type identification
00119   mork_bool IsOrkinRowCellCursor() const
00120   { return mHandle_Magic == morkMagic_kRowCellCursor; }
00121 
00122   mork_bool IsOrkinRowCellCursorHandle() const
00123   { return this->IsHandle() && this->IsOrkinRowCellCursor(); }
00124 
00125   NS_DECL_ISUPPORTS
00126 // { ===== begin nsIMdbObject methods =====
00127 
00128   // { ----- begin attribute methods -----
00129   NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
00130   // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
00131   // } ----- end attribute methods -----
00132 
00133   // { ----- begin factory methods -----
00134   NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory); 
00135   // } ----- end factory methods -----
00136 
00137   // { ----- begin ref counting for well-behaved cyclic graphs -----
00138   NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
00139     mdb_count* outCount);  
00140   NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
00141     mdb_count* outCount);
00142 
00143   NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
00144   NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
00145 
00146   NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
00147   NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
00148   
00149   NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
00150   NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
00151   // } ----- end ref counting -----
00152   
00153 // } ===== end nsIMdbObject methods =====
00154 
00155 // { ===== begin nsIMdbCursor methods =====
00156 
00157   // { ----- begin attribute methods -----
00158   NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
00159   NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed);    // readonly
00160   
00161   NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos);   // mutable
00162   NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
00163   
00164   NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
00165   NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
00166   // } ----- end attribute methods -----
00167 
00168 // } ===== end nsIMdbCursor methods =====
00169 
00170 // { ===== begin nsIMdbRowCellCursor methods =====
00171 
00172   // { ----- begin attribute methods -----
00173   NS_IMETHOD SetRow(nsIMdbEnv* ev, nsIMdbRow* ioRow); // sets pos to -1
00174   NS_IMETHOD GetRow(nsIMdbEnv* ev, nsIMdbRow** acqRow);
00175   // } ----- end attribute methods -----
00176 
00177   // { ----- begin cell creation methods -----
00178   NS_IMETHOD MakeCell( // get cell at current pos in the row
00179     nsIMdbEnv* ev, // context
00180     mdb_column* outColumn, // column for this particular cell
00181     mdb_pos* outPos, // position of cell in row sequence
00182     nsIMdbCell** acqCell); // the cell at inPos
00183   // } ----- end cell creation methods -----
00184 
00185   // { ----- begin cell seeking methods -----
00186   NS_IMETHOD SeekCell( // same as SetRow() followed by MakeCell()
00187     nsIMdbEnv* ev, // context
00188     mdb_pos inPos, // position of cell in row sequence
00189     mdb_column* outColumn, // column for this particular cell
00190     nsIMdbCell** acqCell); // the cell at inPos
00191   // } ----- end cell seeking methods -----
00192 
00193   // { ----- begin cell iteration methods -----
00194   NS_IMETHOD NextCell( // get next cell in the row
00195     nsIMdbEnv* ev, // context
00196     nsIMdbCell* ioCell, // changes to the next cell in the iteration
00197     mdb_column* outColumn, // column for this particular cell
00198     mdb_pos* outPos); // position of cell in row sequence
00199     
00200   NS_IMETHOD PickNextCell( // get next cell in row within filter set
00201     nsIMdbEnv* ev, // context
00202     nsIMdbCell* ioCell, // changes to the next cell in the iteration
00203     const mdbColumnSet* inFilterSet, // col set of actual caller interest
00204     mdb_column* outColumn, // column for this particular cell
00205     mdb_pos* outPos); // position of cell in row sequence
00206 
00207   // Note that inFilterSet should not have too many (many more than 10?)
00208   // cols, since this might imply a potential excessive consumption of time
00209   // over many cursor calls when looking for column and filter intersection.
00210   // } ----- end cell iteration methods -----
00211 
00212 // } ===== end nsIMdbRowCellCursor methods =====
00213 };
00214 
00215 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00216 
00217 #endif /* _ORKINROWCELLCURSOR_ */