Back to index

lightning-sunbird  0.9+nobinonly
morkTableRowCursor.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  *   Blake Ross (blake@blakeross.com)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef _MORKTABLEROWCURSOR_
00040 #define _MORKTABLEROWCURSOR_ 1
00041 
00042 #ifndef _MORK_
00043 #include "mork.h"
00044 #endif
00045 
00046 #ifndef _MORKCURSOR_
00047 #include "morkCursor.h"
00048 #endif
00049 
00050 #ifndef _MORKMAP_
00051 #include "morkMap.h"
00052 #endif
00053 
00054 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00055 
00056 class orkinTableRowCursor;
00057 #define morkDerived_kTableRowCursor  /*i*/ 0x7243 /* ascii 'rC' */
00058 
00059 class morkTableRowCursor : public morkCursor, public nsIMdbTableRowCursor { // row iterator
00060 
00061 // public: // slots inherited from morkObject (meant to inform only)
00062   // nsIMdbHeap*     mNode_Heap;
00063   // mork_able    mNode_Mutable; // can this node be modified?
00064   // mork_load    mNode_Load;    // is this node clean or dirty?
00065   // mork_base    mNode_Base;    // must equal morkBase_kNode
00066   // mork_derived mNode_Derived; // depends on specific node subclass
00067   // mork_access  mNode_Access;  // kOpen, kClosing, kShut, or kDead
00068   // mork_usage   mNode_Usage;   // kHeap, kStack, kMember, kGlobal, kNone
00069   // mork_uses    mNode_Uses;    // refcount for strong refs
00070   // mork_refs    mNode_Refs;    // refcount for strong refs + weak refs
00071 
00072   // morkFactory* mObject_Factory;  // weak ref to suite factory
00073 
00074   // mork_seed  mCursor_Seed;
00075   // mork_pos   mCursor_Pos;
00076   // mork_bool  mCursor_DoFailOnSeedOutOfSync;
00077   // mork_u1    mCursor_Pad[ 3 ]; // explicitly pad to u4 alignment
00078 
00079 public: // state is public because the entire Mork system is private
00080   morkTable*  mTableRowCursor_Table; // weak ref to table
00081     
00082 // { ===== begin morkNode interface =====
00083 public: // morkNode virtual methods
00084   virtual void CloseMorkNode(morkEnv* ev); // CloseTableRowCursor()
00085   virtual ~morkTableRowCursor(); // assert that close executed earlier
00086   
00087 public: // morkTableRowCursor construction & destruction
00088   morkTableRowCursor(morkEnv* ev, const morkUsage& inUsage,
00089     nsIMdbHeap* ioHeap, morkTable* ioTable, mork_pos inRowPos);
00090   void CloseTableRowCursor(morkEnv* ev); // called by CloseMorkNode();
00091 
00092 private: // copying is not allowed
00093   morkTableRowCursor(const morkTableRowCursor& other);
00094   morkTableRowCursor& operator=(const morkTableRowCursor& other);
00095 
00096 public:
00097   NS_DECL_ISUPPORTS_INHERITED
00098 
00099   // { ----- begin attribute methods -----
00100   NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
00101   NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed);    // readonly
00102   
00103   NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos);   // mutable
00104   NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
00105   
00106   NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
00107   NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
00108 
00109   // } ----- end attribute methods -----
00110     NS_IMETHOD GetTable(nsIMdbEnv* ev, nsIMdbTable** acqTable);
00111   // } ----- end attribute methods -----
00112 
00113   // { ----- begin duplicate row removal methods -----
00114   NS_IMETHOD CanHaveDupRowMembers(nsIMdbEnv* ev, // cursor might hold dups?
00115     mdb_bool* outCanHaveDups);
00116     
00117   NS_IMETHOD MakeUniqueCursor( // clone cursor, removing duplicate rows
00118     nsIMdbEnv* ev, // context
00119     nsIMdbTableRowCursor** acqCursor);    // acquire clone with no dups
00120   // } ----- end duplicate row removal methods -----
00121 
00122   // { ----- begin oid iteration methods -----
00123   NS_IMETHOD NextRowOid( // get row id of next row in the table
00124     nsIMdbEnv* ev, // context
00125     mdbOid* outOid, // out row oid
00126     mdb_pos* outRowPos);    // zero-based position of the row in table
00127   NS_IMETHOD PrevRowOid( // get row id of previous row in the table
00128     nsIMdbEnv* ev, // context
00129     mdbOid* outOid, // out row oid
00130     mdb_pos* outRowPos);    // zero-based position of the row in table
00131   // } ----- end oid iteration methods -----
00132 
00133   // { ----- begin row iteration methods -----
00134   NS_IMETHOD NextRow( // get row cells from table for cells already in row
00135     nsIMdbEnv* ev, // context
00136     nsIMdbRow** acqRow, // acquire next row in table
00137     mdb_pos* outRowPos);    // zero-based position of the row in table
00138   NS_IMETHOD PrevRow( // get row cells from table for cells already in row
00139     nsIMdbEnv* ev, // context
00140     nsIMdbRow** acqRow, // acquire previous row in table
00141     mdb_pos* outRowPos);    // zero-based position of the row in table
00142   // } ----- end row iteration methods -----
00143 
00144 
00145 public: // dynamic type identification
00146   mork_bool IsTableRowCursor() const
00147   { return IsNode() && mNode_Derived == morkDerived_kTableRowCursor; }
00148 // } ===== end morkNode methods =====
00149 
00150 public: // typing
00151   static void NonTableRowCursorTypeError(morkEnv* ev);
00152 
00153 public: // oid only iteration
00154   mdb_pos NextRowOid(morkEnv* ev, mdbOid* outOid);
00155   mdb_pos PrevRowOid(morkEnv* ev, mdbOid* outOid);
00156 
00157 public: // other table row cursor methods
00158 
00159   virtual mork_bool CanHaveDupRowMembers(morkEnv* ev);
00160   virtual mork_count GetMemberCount(morkEnv* ev);
00161 
00162   virtual morkRow* NextRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos);
00163   virtual morkRow* PrevRow(morkEnv* ev, mdbOid* outOid, mdb_pos* outPos);
00164 
00165 public: // typesafe refcounting inlines calling inherited morkNode methods
00166   static void SlotWeakTableRowCursor(morkTableRowCursor* me,
00167     morkEnv* ev, morkTableRowCursor** ioSlot)
00168   { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
00169   
00170   static void SlotStrongTableRowCursor(morkTableRowCursor* me,
00171     morkEnv* ev, morkTableRowCursor** ioSlot)
00172   { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
00173 };
00174 
00175 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00176 
00177 #endif /* _MORKTABLEROWCURSOR_ */