Back to index

lightning-sunbird  0.9+nobinonly
morkCursor.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 _MORKCURSOR_
00039 #define _MORKCURSOR_ 1
00040 
00041 #ifndef _MORK_
00042 #include "mork.h"
00043 #endif
00044 
00045 #ifndef _MORKOBJECT_
00046 #include "morkObject.h"
00047 #endif
00048 
00049 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00050 
00051 #define morkDerived_kCursor  /*i*/ 0x4375 /* ascii 'Cu' */
00052 
00053 class morkCursor : public morkObject, public nsIMdbCursor{ // collection iterator
00054 
00055 // public: // slots inherited from morkObject (meant to inform only)
00056   // nsIMdbHeap*     mNode_Heap;
00057   // mork_able    mNode_Mutable; // can this node be modified?
00058   // mork_load    mNode_Load;    // is this node clean or dirty?
00059   // mork_base    mNode_Base;    // must equal morkBase_kNode
00060   // mork_derived mNode_Derived; // depends on specific node subclass
00061   // mork_access  mNode_Access;  // kOpen, kClosing, kShut, or kDead
00062   // mork_usage   mNode_Usage;   // kHeap, kStack, kMember, kGlobal, kNone
00063   // mork_uses    mNode_Uses;    // refcount for strong refs
00064   // mork_refs    mNode_Refs;    // refcount for strong refs + weak refs
00065 
00066   // mork_color   mBead_Color;   // ID for this bead
00067   // morkHandle*  mObject_Handle;  // weak ref to handle for this object
00068 
00069 public: // state is public because the entire Mork system is private
00070   NS_DECL_ISUPPORTS_INHERITED
00071 
00072   // { ----- begin attribute methods -----
00073   NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
00074   // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
00075   // } ----- end attribute methods -----
00076 
00077   // { ----- begin ref counting for well-behaved cyclic graphs -----
00078   NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
00079     mdb_count* outCount);  
00080   NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
00081     mdb_count* outCount);
00082 
00083   NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
00084   NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
00085 
00086   NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
00087   NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
00088   
00089   NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
00090   NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
00091   // } ----- end ref counting -----
00092   
00093 // } ===== end nsIMdbObject methods =====
00094 
00095 // { ===== begin nsIMdbCursor methods =====
00096 
00097   // { ----- begin attribute methods -----
00098   NS_IMETHOD GetCount(nsIMdbEnv* ev, mdb_count* outCount); // readonly
00099   NS_IMETHOD GetSeed(nsIMdbEnv* ev, mdb_seed* outSeed);    // readonly
00100   
00101   NS_IMETHOD SetPos(nsIMdbEnv* ev, mdb_pos inPos);   // mutable
00102   NS_IMETHOD GetPos(nsIMdbEnv* ev, mdb_pos* outPos);
00103   
00104   NS_IMETHOD SetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool inFail);
00105   NS_IMETHOD GetDoFailOnSeedOutOfSync(nsIMdbEnv* ev, mdb_bool* outFail);
00106   // } ----- end attribute methods -----
00107 
00108 // } ===== end nsIMdbCursor methods =====
00109     
00110   // } ----- end attribute methods -----
00111 
00112   mork_seed  mCursor_Seed;
00113   mork_pos   mCursor_Pos;
00114   mork_bool  mCursor_DoFailOnSeedOutOfSync;
00115   mork_u1    mCursor_Pad[ 3 ]; // explicitly pad to u4 alignment
00116   
00117 // { ===== begin morkNode interface =====
00118 public: // morkNode virtual methods
00119   virtual void CloseMorkNode(morkEnv* ev); // CloseCursor() only if open
00120   virtual ~morkCursor(); // assert that CloseCursor() executed earlier
00121   
00122 public: // morkCursor construction & destruction
00123   morkCursor(morkEnv* ev, const morkUsage& inUsage, nsIMdbHeap* ioHeap);
00124   void CloseCursor(morkEnv* ev); // called by CloseMorkNode();
00125 
00126 private: // copying is not allowed
00127   morkCursor(const morkCursor& other);
00128   morkCursor& operator=(const morkCursor& other);
00129 
00130 public: // dynamic type identification
00131   mork_bool IsCursor() const
00132   { return IsNode() && mNode_Derived == morkDerived_kCursor; }
00133 // } ===== end morkNode methods =====
00134 
00135 public: // other cursor methods
00136 
00137 public: // typesafe refcounting inlines calling inherited morkNode methods
00138   static void SlotWeakCursor(morkCursor* me,
00139     morkEnv* ev, morkCursor** ioSlot)
00140   { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
00141   
00142   static void SlotStrongCursor(morkCursor* me,
00143     morkEnv* ev, morkCursor** ioSlot)
00144   { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
00145 };
00146 
00147 
00148 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00149 
00150 #endif /* _MORKCURSOR_ */