Back to index

lightning-sunbird  0.9+nobinonly
morkCursor.cpp
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 _MDB_
00039 #include "mdb.h"
00040 #endif
00041 
00042 #ifndef _MORK_
00043 #include "mork.h"
00044 #endif
00045 
00046 #ifndef _MORKNODE_
00047 #include "morkNode.h"
00048 #endif
00049 
00050 #ifndef _MORKMAP_
00051 #include "morkMap.h"
00052 #endif
00053 
00054 #ifndef _MORKENV_
00055 #include "morkEnv.h"
00056 #endif
00057 
00058 #ifndef _MORKCURSOR_
00059 #include "morkCursor.h"
00060 #endif
00061 
00062 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00063 
00064 // ````` ````` ````` ````` ````` 
00065 // { ===== begin morkNode interface =====
00066 
00067 /*public virtual*/ void
00068 morkCursor::CloseMorkNode(morkEnv* ev) // CloseCursor() only if open
00069 {
00070   if ( this->IsOpenNode() )
00071   {
00072     this->MarkClosing();
00073     this->CloseCursor(ev);
00074     this->MarkShut();
00075   }
00076 }
00077 
00078 /*public virtual*/
00079 morkCursor::~morkCursor() // assert CloseCursor() executed earlier
00080 {
00081 }
00082 
00083 /*public non-poly*/
00084 morkCursor::morkCursor(morkEnv* ev,
00085   const morkUsage& inUsage, nsIMdbHeap* ioHeap)
00086 : morkObject(ev, inUsage, ioHeap, morkColor_kNone, (morkHandle*) 0)
00087 , mCursor_Seed( 0 )
00088 , mCursor_Pos( -1 )
00089 , mCursor_DoFailOnSeedOutOfSync( morkBool_kFalse )
00090 {
00091   if ( ev->Good() )
00092     mNode_Derived = morkDerived_kCursor;
00093 }
00094 
00095 NS_IMPL_ISUPPORTS_INHERITED1(morkCursor, morkObject, nsIMdbCursor)
00096 
00097 /*public non-poly*/ void
00098 morkCursor::CloseCursor(morkEnv* ev) // called by CloseMorkNode();
00099 {
00100   if ( this )
00101   {
00102     if ( this->IsNode() )
00103     {
00104       mCursor_Seed = 0;
00105       mCursor_Pos = -1;
00106       this->MarkShut();
00107     }
00108     else
00109       this->NonNodeError(ev);
00110   }
00111   else
00112     ev->NilPointerError();
00113 }
00114 
00115 // { ----- begin ref counting for well-behaved cyclic graphs -----
00116 NS_IMETHODIMP
00117 morkCursor::GetWeakRefCount(nsIMdbEnv* mev, // weak refs
00118   mdb_count* outCount)
00119 {
00120   *outCount = WeakRefsOnly();
00121   return NS_OK;
00122 }  
00123 NS_IMETHODIMP
00124 morkCursor::GetStrongRefCount(nsIMdbEnv* mev, // strong refs
00125   mdb_count* outCount)
00126 {
00127   *outCount = StrongRefsOnly();
00128   return NS_OK;
00129 }
00130 // ### TODO - clean up this cast, if required
00131 NS_IMETHODIMP
00132 morkCursor::AddWeakRef(nsIMdbEnv* mev)
00133 {
00134   return morkNode::AddWeakRef((morkEnv *) mev);
00135 }
00136 NS_IMETHODIMP
00137 morkCursor::AddStrongRef(nsIMdbEnv* mev)
00138 {
00139   return morkNode::AddStrongRef((morkEnv *) mev);
00140 }
00141 
00142 NS_IMETHODIMP
00143 morkCursor::CutWeakRef(nsIMdbEnv* mev)
00144 {
00145   return morkNode::CutWeakRef((morkEnv *) mev);
00146 }
00147 NS_IMETHODIMP
00148 morkCursor::CutStrongRef(nsIMdbEnv* mev)
00149 {
00150   return morkNode::CutStrongRef((morkEnv *) mev);
00151 }
00152 
00153   
00154 NS_IMETHODIMP
00155 morkCursor::CloseMdbObject(nsIMdbEnv* mev)
00156 {
00157   return morkNode::CloseMdbObject((morkEnv *) mev);
00158 }
00159 
00160 NS_IMETHODIMP
00161 morkCursor::IsOpenMdbObject(nsIMdbEnv* mev, mdb_bool* outOpen)
00162 {
00163   *outOpen = IsOpenNode();
00164   return NS_OK;
00165 }
00166 NS_IMETHODIMP
00167 morkCursor::IsFrozenMdbObject(nsIMdbEnv* mev, mdb_bool* outIsReadonly)
00168 {
00169   *outIsReadonly = IsFrozen();
00170   return NS_OK;
00171 }
00172 // } ===== end morkNode methods =====
00173 // ````` ````` ````` ````` ````` 
00174 
00175 NS_IMETHODIMP
00176 morkCursor::GetCount(nsIMdbEnv* mev, mdb_count* outCount)
00177 {
00178   NS_ASSERTION(PR_FALSE, "not implemented");
00179   return NS_ERROR_NOT_IMPLEMENTED;
00180 }
00181 
00182 NS_IMETHODIMP
00183 morkCursor::GetSeed(nsIMdbEnv* mev, mdb_seed* outSeed)
00184 {
00185   NS_ASSERTION(PR_FALSE, "not implemented");
00186   return NS_ERROR_NOT_IMPLEMENTED;
00187 }
00188 
00189 NS_IMETHODIMP
00190 morkCursor::SetPos(nsIMdbEnv* mev, mdb_pos inPos)
00191 {
00192   NS_ASSERTION(PR_FALSE, "not implemented");
00193   return NS_ERROR_NOT_IMPLEMENTED;
00194 }
00195 
00196 NS_IMETHODIMP
00197 morkCursor::GetPos(nsIMdbEnv* mev, mdb_pos* outPos)
00198 {
00199   NS_ASSERTION(PR_FALSE, "not implemented");
00200   return NS_ERROR_NOT_IMPLEMENTED;
00201 }
00202 
00203 NS_IMETHODIMP
00204 morkCursor::SetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool inFail)
00205 {
00206   NS_ASSERTION(PR_FALSE, "not implemented");
00207   return NS_ERROR_NOT_IMPLEMENTED;
00208 }
00209 
00210 NS_IMETHODIMP
00211 morkCursor::GetDoFailOnSeedOutOfSync(nsIMdbEnv* mev, mdb_bool* outFail)
00212 {
00213   NS_ASSERTION(PR_FALSE, "not implemented");
00214   return NS_ERROR_NOT_IMPLEMENTED;
00215 }
00216 
00217 
00218 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789