Back to index

lightning-sunbird  0.9+nobinonly
morkRowObject.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 _MORKROWOBJECT_
00039 #define _MORKROWOBJECT_ 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 class nsIMdbRow;
00052 #define morkDerived_kRowObject  /*i*/ 0x724F /* ascii 'rO' */
00053 
00054 class morkRowObject : public morkObject, public nsIMdbRow  { //
00055 
00056 public: // state is public because the entire Mork system is private
00057   NS_DECL_ISUPPORTS_INHERITED
00058   
00059   morkRow*    mRowObject_Row;     // non-refcounted alias to morkRow
00060   morkStore*  mRowObject_Store;   // non-refcounted ptr to store containing row
00061   
00062 // { ===== begin morkNode interface =====
00063 public: // morkNode virtual methods
00064   virtual void CloseMorkNode(morkEnv* ev); // CloseRowObject() only if open
00065   virtual ~morkRowObject(); // assert that CloseRowObject() executed earlier
00066   
00067 public: // morkRowObject construction & destruction
00068   morkRowObject(morkEnv* ev, const morkUsage& inUsage,
00069     nsIMdbHeap* ioHeap, morkRow* ioRow, morkStore* ioStore);
00070   void CloseRowObject(morkEnv* ev); // called by CloseMorkNode();
00071 
00072 // { ===== begin nsIMdbCollection methods =====
00073 
00074   // { ----- begin attribute methods -----
00075   NS_IMETHOD GetSeed(nsIMdbEnv* ev,
00076     mdb_seed* outSeed);    // member change count
00077   NS_IMETHOD GetCount(nsIMdbEnv* ev,
00078     mdb_count* outCount); // member count
00079 
00080   NS_IMETHOD GetPort(nsIMdbEnv* ev,
00081     nsIMdbPort** acqPort); // collection container
00082   // } ----- end attribute methods -----
00083 
00084   // { ----- begin cursor methods -----
00085   NS_IMETHOD GetCursor( // make a cursor starting iter at inMemberPos
00086     nsIMdbEnv* ev, // context
00087     mdb_pos inMemberPos, // zero-based ordinal pos of member in collection
00088     nsIMdbCursor** acqCursor); // acquire new cursor instance
00089   // } ----- end cursor methods -----
00090 
00091   // { ----- begin ID methods -----
00092   NS_IMETHOD GetOid(nsIMdbEnv* ev,
00093     mdbOid* outOid); // read object identity
00094   NS_IMETHOD BecomeContent(nsIMdbEnv* ev,
00095     const mdbOid* inOid); // exchange content
00096   // } ----- end ID methods -----
00097 
00098   // { ----- begin activity dropping methods -----
00099   NS_IMETHOD DropActivity( // tell collection usage no longer expected
00100     nsIMdbEnv* ev);
00101   // } ----- end activity dropping methods -----
00102 
00103 // } ===== end nsIMdbCollection methods =====
00104 // { ===== begin nsIMdbRow methods =====
00105 
00106   // { ----- begin cursor methods -----
00107   NS_IMETHOD GetRowCellCursor( // make a cursor starting iteration at inRowPos
00108     nsIMdbEnv* ev, // context
00109     mdb_pos inRowPos, // zero-based ordinal position of row in table
00110     nsIMdbRowCellCursor** acqCursor); // acquire new cursor instance
00111   // } ----- end cursor methods -----
00112 
00113   // { ----- begin column methods -----
00114   NS_IMETHOD AddColumn( // make sure a particular column is inside row
00115     nsIMdbEnv* ev, // context
00116     mdb_column inColumn, // column to add
00117     const mdbYarn* inYarn); // cell value to install
00118 
00119   NS_IMETHOD CutColumn( // make sure a column is absent from the row
00120     nsIMdbEnv* ev, // context
00121     mdb_column inColumn); // column to ensure absent from row
00122 
00123   NS_IMETHOD CutAllColumns( // remove all columns from the row
00124     nsIMdbEnv* ev); // context
00125   // } ----- end column methods -----
00126 
00127   // { ----- begin cell methods -----
00128   NS_IMETHOD NewCell( // get cell for specified column, or add new one
00129     nsIMdbEnv* ev, // context
00130     mdb_column inColumn, // column to add
00131     nsIMdbCell** acqCell); // cell column and value
00132     
00133   NS_IMETHOD AddCell( // copy a cell from another row to this row
00134     nsIMdbEnv* ev, // context
00135     const nsIMdbCell* inCell); // cell column and value
00136     
00137   NS_IMETHOD GetCell( // find a cell in this row
00138     nsIMdbEnv* ev, // context
00139     mdb_column inColumn, // column to find
00140     nsIMdbCell** acqCell); // cell for specified column, or null
00141     
00142   NS_IMETHOD EmptyAllCells( // make all cells in row empty of content
00143     nsIMdbEnv* ev); // context
00144   // } ----- end cell methods -----
00145 
00146   // { ----- begin row methods -----
00147   NS_IMETHOD AddRow( // add all cells in another row to this one
00148     nsIMdbEnv* ev, // context
00149     nsIMdbRow* ioSourceRow); // row to union with
00150     
00151   NS_IMETHOD SetRow( // make exact duplicate of another row
00152     nsIMdbEnv* ev, // context
00153     nsIMdbRow* ioSourceRow); // row to duplicate
00154   // } ----- end row methods -----
00155 
00156   // { ----- begin blob methods -----  
00157   NS_IMETHOD SetCellYarn(nsIMdbEnv* ev, // synonym for AddColumn()
00158     mdb_column inColumn, // column to write
00159     const mdbYarn* inYarn);   // reads from yarn slots
00160   // make this text object contain content from the yarn's buffer
00161   
00162   NS_IMETHOD GetCellYarn(nsIMdbEnv* ev, 
00163     mdb_column inColumn, // column to read 
00164     mdbYarn* outYarn);  // writes some yarn slots 
00165   // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
00166   
00167   NS_IMETHOD AliasCellYarn(nsIMdbEnv* ev, 
00168     mdb_column inColumn, // column to alias
00169     mdbYarn* outYarn); // writes ALL yarn slots
00170   
00171   NS_IMETHOD NextCellYarn(nsIMdbEnv* ev, // iterative version of GetCellYarn()
00172     mdb_column* ioColumn, // next column to read
00173     mdbYarn* outYarn);  // writes some yarn slots 
00174   // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
00175   //
00176   // The ioColumn argument is an inout parameter which initially contains the
00177   // last column accessed and returns the next column corresponding to the
00178   // content read into the yarn.  Callers should start with a zero column
00179   // value to say 'no previous column', which causes the first column to be
00180   // read.  Then the value returned in ioColumn is perfect for the next call
00181   // to NextCellYarn(), since it will then be the previous column accessed.
00182   // Callers need only examine the column token returned to see which cell
00183   // in the row is being read into the yarn.  When no more columns remain,
00184   // and the iteration has ended, ioColumn will return a zero token again.
00185   // So iterating over cells starts and ends with a zero column token.
00186 
00187   NS_IMETHOD SeekCellYarn( // resembles nsIMdbRowCellCursor::SeekCell()
00188     nsIMdbEnv* ev, // context
00189     mdb_pos inPos, // position of cell in row sequence
00190     mdb_column* outColumn, // column for this particular cell
00191     mdbYarn* outYarn); // writes some yarn slots
00192   // copy content into the yarn buffer, and update mYarn_Fill and mYarn_Form
00193   // Callers can pass nil for outYarn to indicate no interest in content, so
00194   // only the outColumn value is returned.  NOTE to subclasses: you must be
00195   // able to ignore outYarn when the pointer is nil; please do not crash.
00196 
00197   // } ----- end blob methods -----
00198 
00199 // } ===== end nsIMdbRow methods =====
00200 
00201 private: // copying is not allowed
00202   morkRowObject(const morkRowObject& other);
00203   morkRowObject& operator=(const morkRowObject& other);
00204 
00205 public: // dynamic type identification
00206   mork_bool IsRowObject() const
00207   { return IsNode() && mNode_Derived == morkDerived_kRowObject; }
00208 // } ===== end morkNode methods =====
00209 
00210 public: // typing
00211   static void NonRowObjectTypeError(morkEnv* ev);
00212   static void NilRowError(morkEnv* ev);
00213   static void NilStoreError(morkEnv* ev);
00214   static void RowObjectRowNotSelfError(morkEnv* ev);
00215 
00216 public: // other row node methods
00217 
00218   nsIMdbRow* AcquireRowHandle(morkEnv* ev); // mObject_Handle
00219   
00220 public: // typesafe refcounting inlines calling inherited morkNode methods
00221   static void SlotWeakRowObject(morkRowObject* me,
00222     morkEnv* ev, morkRowObject** ioSlot)
00223   { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }
00224   
00225   static void SlotStrongRowObject(morkRowObject* me,
00226     morkEnv* ev, morkRowObject** ioSlot)
00227   { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }
00228 };
00229 
00230 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00231 
00232 #endif /* _MORKROWOBJECT_ */