Back to index

lightning-sunbird  0.9+nobinonly
orkinPortTableCursor.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 _ORKINPORTTABLECURSOR_
00039 #define _ORKINPORTTABLECURSOR_ 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 _MORKPORTTABLECURSOR_
00058 #include "morkPortTableCursor.h"
00059 #endif
00060 
00061 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00062 
00063 class morkPortTableCursor;
00064 #define morkMagic_kPortTableCursor 0x50744375 /* ascii 'PtCu' */
00065 
00066 /*| orkinPortTableCursor: cursor class for iterating port tables
00067 **|
00068 **|| port: the cursor is associated with a specific port, which can be
00069 **| set to a different port (which resets the position to -1 so the
00070 **| next table acquired is the first in the port.
00071 **|
00072 |*/
00073 class orkinPortTableCursor :
00074   public morkHandle, public nsIMdbPortTableCursor { // nsIMdbCursor
00075 
00076 // { ===== begin morkNode interface =====
00077 public: // morkNode virtual methods
00078   // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
00079   virtual ~orkinPortTableCursor(); // morkHandle destructor does everything
00080   
00081 protected: // construction is protected (use the static Make() method)
00082   orkinPortTableCursor(morkEnv* ev, // note morkUsage is always morkUsage_kPool
00083     morkHandleFace* ioFace,    // must not be nil, cookie for this handle
00084     morkPortTableCursor* ioObject); // must not be nil, the object for this handle
00085     
00086   // void CloseHandle(morkEnv* ev); // don't need to specialize closing
00087 
00088 private: // copying is not allowed
00089   orkinPortTableCursor(const morkHandle& other);
00090   orkinPortTableCursor& operator=(const morkHandle& other);
00091 
00092 // public: // dynamic type identification
00093   // mork_bool IsHandle() const //
00094   // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
00095 // } ===== end morkNode methods =====
00096 
00097 protected: // morkHandle memory management operators
00098   void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
00099   { return ioPool.NewHandle(ev, inSize, &ioZone); }
00100   
00101   void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
00102   { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
00103   
00104   void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
00105   { MORK_USED_1(inSize); return ioFace; }
00106   
00107  
00108 public: // construction:
00109 
00110   static orkinPortTableCursor* MakePortTableCursor(morkEnv* ev, 
00111     morkPortTableCursor* ioObject);
00112 
00113 public: // utilities:
00114 
00115   morkEnv* CanUsePortTableCursor(nsIMdbEnv* mev, mork_bool inMutable,
00116     mdb_err* outErr) const;
00117 
00118 public: // type identification
00119   mork_bool IsOrkinPortTableCursor() const
00120   { return mHandle_Magic == morkMagic_kPortTableCursor; }
00121 
00122   mork_bool IsOrkinPortTableCursorHandle() const
00123   { return this->IsHandle() && this->IsOrkinPortTableCursor(); }
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 nsIMdbPortTableCursor methods =====
00171 
00172   // { ----- begin attribute methods -----
00173   NS_IMETHOD SetPort(nsIMdbEnv* ev, nsIMdbPort* ioPort); // sets pos to -1
00174   NS_IMETHOD GetPort(nsIMdbEnv* ev, nsIMdbPort** acqPort);
00175   
00176   NS_IMETHOD SetRowScope(nsIMdbEnv* ev, // sets pos to -1
00177     mdb_scope inRowScope);
00178   NS_IMETHOD GetRowScope(nsIMdbEnv* ev, mdb_scope* outRowScope); 
00179   // setting row scope to zero iterates over all row scopes in port
00180     
00181   NS_IMETHOD SetTableKind(nsIMdbEnv* ev, // sets pos to -1
00182     mdb_kind inTableKind);
00183   NS_IMETHOD GetTableKind(nsIMdbEnv* ev, mdb_kind* outTableKind);
00184   // setting table kind to zero iterates over all table kinds in row scope
00185   // } ----- end attribute methods -----
00186 
00187   // { ----- begin table iteration methods -----
00188   NS_IMETHOD NextTable( // get table at next position in the db
00189     nsIMdbEnv* ev, // context
00190     nsIMdbTable** acqTable); // the next table in the iteration
00191   // } ----- end table iteration methods -----
00192 
00193 // } ===== end nsIMdbPortTableCursor methods =====
00194 };
00195 
00196 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00197 
00198 #endif /* _ORKINPORTTABLECURSOR_ */