Back to index

lightning-sunbird  0.9+nobinonly
orkinRow.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 _ORKINROW_
00039 #define _ORKINROW_ 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 _MORKROW_
00058 #include "morkRow.h"
00059 #endif
00060 
00061 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00062 
00063 #define morkMagic_kRow 0x526F774D /* ascii 'RowM' */
00064 
00065 /*| orkinRow: a collection of cells
00066 **|
00067 |*/
00068 class orkinRow : public morkHandle, public nsIMdbRow { // nsIMdbCollection
00069 
00070 // { ===== begin morkNode interface =====
00071 public: // morkNode virtual methods
00072   // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
00073   virtual ~orkinRow(); // morkHandle destructor does everything
00074   
00075 protected: // construction is protected (use the static Make() method)
00076   orkinRow(morkEnv* ev, // note morkUsage is always morkUsage_kPool
00077     morkHandleFace* ioFace,    // must not be nil, cookie for this handle
00078     morkRowObject* ioObject); // must not be nil, the object for this handle
00079     
00080   // void CloseHandle(morkEnv* ev); // don't need to specialize closing
00081 
00082 private: // copying is not allowed
00083   orkinRow(const morkHandle& other);
00084   orkinRow& operator=(const morkHandle& other);
00085 
00086 // public: // dynamic type identification
00087   // mork_bool IsHandle() const //
00088   // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
00089 // } ===== end morkNode methods =====
00090 
00091 protected: // morkHandle memory management operators
00092   void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
00093   { return ioPool.NewHandle(ev, inSize, &ioZone); }
00094   
00095   void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
00096   { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
00097   
00098   void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
00099   { MORK_USED_1(inSize); return ioFace; }
00100   
00101   
00102 public: // construction:
00103 
00104   static orkinRow* MakeRow(morkEnv* ev, morkRowObject* ioObject);
00105 
00106 public: // utilities:
00107 
00108   morkEnv* CanUseRow(nsIMdbEnv* mev, mork_bool inMutable,
00109     mdb_err* outErr, morkRow** outRow) const;
00110 
00111   morkStore* CanUseRowStore(morkEnv* ev) const;
00112 
00113 public: // type identification
00114   mork_bool IsOrkinRow() const
00115   { return mHandle_Magic == morkMagic_kRow; }
00116 
00117   mork_bool IsOrkinRowHandle() const
00118   { return this->IsHandle() && this->IsOrkinRow(); }
00119 
00120   NS_DECL_ISUPPORTS
00121 // { ===== begin nsIMdbObject methods =====
00122 
00123   // { ----- begin attribute methods -----
00124   NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
00125   // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
00126   // } ----- end attribute methods -----
00127 
00128   // { ----- begin factory methods -----
00129   NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory); 
00130   // } ----- end factory methods -----
00131 
00132   // { ----- begin ref counting for well-behaved cyclic graphs -----
00133   NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
00134     mdb_count* outCount);  
00135   NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
00136     mdb_count* outCount);
00137 
00138   NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
00139   NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
00140 
00141   NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
00142   NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
00143   
00144   NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
00145   NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
00146   // } ----- end ref counting -----
00147   
00148 // } ===== end nsIMdbObject methods =====
00149 
00150 // { ===== begin nsIMdbCollection methods =====
00151 
00152   // { ----- begin attribute methods -----
00153   NS_IMETHOD GetSeed(nsIMdbEnv* ev,
00154     mdb_seed* outSeed);    // member change count
00155   NS_IMETHOD GetCount(nsIMdbEnv* ev,
00156     mdb_count* outCount); // member count
00157 
00158   NS_IMETHOD GetPort(nsIMdbEnv* ev,
00159     nsIMdbPort** acqPort); // collection container
00160   // } ----- end attribute methods -----
00161 
00162   // { ----- begin cursor methods -----
00163   NS_IMETHOD GetCursor( // make a cursor starting iter at inMemberPos
00164     nsIMdbEnv* ev, // context
00165     mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
00166     nsIMdbCursor** acqCursor); // acquire new cursor instance
00167   // } ----- end cursor methods -----
00168 
00169   // { ----- begin ID methods -----
00170   NS_IMETHOD GetOid(nsIMdbEnv* ev,
00171     mdbOid* outOid); // read object identity
00172   NS_IMETHOD BecomeContent(nsIMdbEnv* ev,
00173     const mdbOid* inOid); // exchange content
00174   // } ----- end ID methods -----
00175 
00176   // { ----- begin activity dropping methods -----
00177   NS_IMETHOD DropActivity( // tell collection usage no longer expected
00178     nsIMdbEnv* ev);
00179   // } ----- end activity dropping methods -----
00180 
00181 // } ===== end nsIMdbCollection methods =====
00182 
00183 // { ===== begin nsIMdbRow methods =====
00184 
00185   // { ----- begin cursor methods -----
00186   NS_IMETHOD GetRowCellCursor( // make a cursor starting iteration at inRowPos
00187     nsIMdbEnv* ev, // context
00188     mdb_pos inRowPos, // zero-based ordinal position of row in table
00189     nsIMdbRowCellCursor** acqCursor); // acquire new cursor instance
00190   // } ----- end cursor methods -----
00191 
00192   // { ----- begin column methods -----
00193   NS_IMETHOD AddColumn( // make sure a particular column is inside row
00194     nsIMdbEnv* ev, // context
00195     mdb_column inColumn, // column to add
00196     const mdbYarn* inYarn); // cell value to install
00197 
00198   NS_IMETHOD CutColumn( // make sure a column is absent from the row
00199     nsIMdbEnv* ev, // context
00200     mdb_column inColumn); // column to ensure absent from row
00201 
00202   NS_IMETHOD CutAllColumns( // remove all columns from the row
00203     nsIMdbEnv* ev); // context
00204   // } ----- end column methods -----
00205 
00206   // { ----- begin cell methods -----
00207   NS_IMETHOD NewCell( // get cell for specified column, or add new one
00208     nsIMdbEnv* ev, // context
00209     mdb_column inColumn, // column to add
00210     nsIMdbCell** acqCell); // cell column and value
00211     
00212   NS_IMETHOD AddCell( // copy a cell from another row to this row
00213     nsIMdbEnv* ev, // context
00214     const nsIMdbCell* inCell); // cell column and value
00215     
00216   NS_IMETHOD GetCell( // find a cell in this row
00217     nsIMdbEnv* ev, // context
00218     mdb_column inColumn, // column to find
00219     nsIMdbCell** acqCell); // cell for specified column, or null
00220     
00221   NS_IMETHOD EmptyAllCells( // make all cells in row empty of content
00222     nsIMdbEnv* ev); // context
00223   // } ----- end cell methods -----
00224 
00225   // { ----- begin row methods -----
00226   NS_IMETHOD AddRow( // add all cells in another row to this one
00227     nsIMdbEnv* ev, // context
00228     nsIMdbRow* ioSourceRow); // row to union with
00229     
00230   NS_IMETHOD SetRow( // make exact duplicate of another row
00231     nsIMdbEnv* ev, // context
00232     nsIMdbRow* ioSourceRow); // row to duplicate
00233   // } ----- end row methods -----
00234 
00235   // { ----- begin blob methods -----  
00236   NS_IMETHOD SetCellYarn(nsIMdbEnv* ev, // synonym for AddColumn()
00237     mdb_column inColumn, // column to write
00238     const mdbYarn* inYarn);   // reads from yarn slots
00239   // make this text object contain content from the yarn's buffer
00240   
00241   NS_IMETHOD GetCellYarn(nsIMdbEnv* ev, 
00242     mdb_column inColumn, // column to read 
00243     mdbYarn* outYarn);  // writes some yarn slots 
00244   // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
00245   
00246   NS_IMETHOD AliasCellYarn(nsIMdbEnv* ev, 
00247     mdb_column inColumn, // column to alias
00248     mdbYarn* outYarn); // writes ALL yarn slots
00249   
00250   NS_IMETHOD NextCellYarn(nsIMdbEnv* ev, // iterative version of GetCellYarn()
00251     mdb_column* ioColumn, // next column to read
00252     mdbYarn* outYarn);  // writes some yarn slots 
00253   // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
00254   //
00255   // The ioColumn argument is an inout parameter which initially contains the
00256   // last column accessed and returns the next column corresponding to the
00257   // content read into the yarn.  Callers should start with a zero column
00258   // value to say 'no previous column', which causes the first column to be
00259   // read.  Then the value returned in ioColumn is perfect for the next call
00260   // to NextCellYarn(), since it will then be the previous column accessed.
00261   // Callers need only examine the column token returned to see which cell
00262   // in the row is being read into the yarn.  When no more columns remain,
00263   // and the iteration has ended, ioColumn will return a zero token again.
00264   // So iterating over cells starts and ends with a zero column token.
00265 
00266   NS_IMETHOD SeekCellYarn( // resembles nsIMdbRowCellCursor::SeekCell()
00267     nsIMdbEnv* ev, // context
00268     mdb_pos inPos, // position of cell in row sequence
00269     mdb_column* outColumn, // column for this particular cell
00270     mdbYarn* outYarn); // writes some yarn slots
00271   // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
00272   // Callers can pass nil for outYarn to indicate no interest in content, so
00273   // only the outColumn value is returned.  NOTE to subclasses: you must be
00274   // able to ignore outYarn when the pointer is nil; please do not crash.
00275 
00276   // } ----- end blob methods -----
00277 
00278 // } ===== end nsIMdbRow methods =====
00279 };
00280 
00281 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00282 
00283 #endif /* _ORKINROW_ */
00284