Back to index

lightning-sunbird  0.9+nobinonly
orkinSorting.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 _ORKINSORTING_
00039 #define _ORKINSORTING_ 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 _MORKSORTING_
00058 #include "morkSorting.h"
00059 #endif
00060 
00061 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00062 
00063 #define morkMagic_kSorting 0x536F7274 /* ascii 'Sort' */
00064 
00065 /*| orkinSorting: 
00066 |*/
00067 class orkinSorting : public morkHandle, public nsIMdbSorting { // nsIMdbSorting
00068 
00069 // { ===== begin morkNode interface =====
00070 public: // morkNode virtual methods
00071   // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
00072   virtual ~orkinSorting(); // morkHandle destructor does everything
00073   
00074 protected: // construction is protected (use the static Make() method)
00075   orkinSorting(morkEnv* ev, // note morkUsage is always morkUsage_kPool
00076     morkHandleFace* ioFace,    // must not be nil, cookie for this handle
00077     morkSorting* ioObject); // must not be nil, the object for this handle
00078     
00079   // void CloseHandle(morkEnv* ev); // don't need to specialize closing
00080 
00081 private: // copying is not allowed
00082   orkinSorting(const orkinSorting& other);
00083   orkinSorting& operator=(const orkinSorting& other);
00084 
00085 // public: // dynamic type identification
00086   // mork_bool IsHandle() const //
00087   // { return IsNode() && mNode_Derived == morkDerived_kHandle; }
00088 // } ===== end morkNode methods =====
00089 
00090 protected: // morkHandle memory management operators
00091   void* operator new(size_t inSize, morkPool& ioPool, morkZone& ioZone, morkEnv* ev) CPP_THROW_NEW
00092   { return ioPool.NewHandle(ev, inSize, &ioZone); }
00093   
00094   void* operator new(size_t inSize, morkPool& ioPool, morkEnv* ev) CPP_THROW_NEW
00095   { return ioPool.NewHandle(ev, inSize, (morkZone*) 0); }
00096   
00097   void* operator new(size_t inSize, morkHandleFace* ioFace) CPP_THROW_NEW
00098   { MORK_USED_1(inSize); return ioFace; }
00099   
00100   
00101 public: // construction:
00102 
00103   static orkinSorting* MakeSorting(morkEnv* ev, morkSorting* ioObject);
00104 
00105 public: // utilities:
00106 
00107   morkEnv* CanUseSorting(nsIMdbEnv* mev, mork_bool inMutable,
00108     mdb_err* outErr) const;
00109 
00110 public: // type identification
00111   mork_bool IsOrkinSorting() const
00112   { return mHandle_Magic == morkMagic_kSorting; }
00113 
00114   mork_bool IsOrkinSortingHandle() const
00115   { return this->IsHandle() && this->IsOrkinSorting(); }
00116 
00117   NS_DECL_ISUPPORTS
00118 // { ===== begin nsIMdbObject methods =====
00119 
00120   // { ----- begin attribute methods -----
00121   NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
00122   // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
00123   // } ----- end attribute methods -----
00124 
00125   // { ----- begin factory methods -----
00126   NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory); 
00127   // } ----- end factory methods -----
00128 
00129   // { ----- begin ref counting for well-behaved cyclic graphs -----
00130   NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
00131     mdb_count* outCount);  
00132   NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
00133     mdb_count* outCount);
00134 
00135   NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
00136   NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
00137 
00138   NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
00139   NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
00140   
00141   NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
00142   NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
00143   // } ----- end ref counting -----
00144   
00145 // } ===== end nsIMdbObject methods =====
00146 
00147 // { ===== begin nsIMdbSorting methods =====
00148 
00149   // { ----- begin attribute methods -----
00150   // sorting: note all rows are assumed sorted by row ID as a secondary
00151   // sort following the primary column sort, when table rows are sorted.
00152   
00153   NS_IMETHOD GetTable(nsIMdbEnv* ev, nsIMdbTable** acqTable);
00154   NS_IMETHOD GetSortColumn( // query which col is currently sorted
00155     nsIMdbEnv* ev, // context
00156     mdb_column* outColumn); // col the table uses for sorting (or zero)
00157 
00158   NS_IMETHOD SetNewCompare(nsIMdbEnv* ev,
00159     nsIMdbCompare* ioNewCompare);
00160     // Setting the sorting's compare object will typically cause the rows
00161     // to be resorted, presumably in a lazy fashion when the sorting is
00162     // next required to be in a valid row ordering state, such as when a
00163     // call to PosToOid() happens.  ioNewCompare can be nil, in which case
00164     // implementations should revert to the default sort order, which must
00165     // be equivalent to whatever is used by nsIMdbFactory::MakeCompare().
00166 
00167   NS_IMETHOD GetOldCompare(nsIMdbEnv* ev,
00168     nsIMdbCompare** acqOldCompare);
00169     // Get this sorting instance's compare object, which handles the
00170     // ordering of rows in the sorting, by comparing yarns from the cells
00171     // in the column being sorted.  Since nsIMdbCompare has no interface
00172     // to query the state of the compare object, it is not clear what you
00173     // would do with this object when returned, except maybe compare it
00174     // as a pointer address to some other instance, to check identities.
00175   
00176   // } ----- end attribute methods -----
00177 
00178   // { ----- begin cursor methods -----
00179   NS_IMETHOD GetSortingRowCursor( // make a cursor, starting at inRowPos
00180     nsIMdbEnv* ev, // context
00181     mdb_pos inRowPos, // zero-based ordinal position of row in table
00182     nsIMdbTableRowCursor** acqCursor); // acquire new cursor instance
00183     // A cursor interface turning same info as PosToOid() or PosToRow().
00184   // } ----- end row position methods -----
00185 
00186   // { ----- begin row position methods -----
00187   NS_IMETHOD PosToOid( // get row member for a table position
00188     nsIMdbEnv* ev, // context
00189     mdb_pos inRowPos, // zero-based ordinal position of row in table
00190     mdbOid* outOid); // row oid at the specified position
00191     
00192   NS_IMETHOD PosToRow( // test for the table position of a row member
00193     nsIMdbEnv* ev, // context
00194     mdb_pos inRowPos, // zero-based ordinal position of row in table
00195     nsIMdbRow** acqRow); // acquire row at table position inRowPos
00196   // } ----- end row position methods -----
00197 
00198 // } ===== end nsIMdbSorting methods =====
00199 
00200 };
00201  
00202 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00203 
00204 #endif /* _ORKINSORTING_ */