Back to index

lightning-sunbird  0.9+nobinonly
orkinThumb.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 _ORKINTHUMB_
00039 #define _ORKINTHUMB_ 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 _MORKTHUMB_
00058 #include "morkThumb.h"
00059 #endif
00060 
00061 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00062 
00063 #define morkMagic_kThumb 0x54686D62 /* ascii 'Thmb' */
00064 
00065 /*| orkinThumb: 
00066 |*/
00067 class orkinThumb : public morkHandle, public nsIMdbThumb { // nsIMdbObject
00068 
00069 // { ===== begin morkNode interface =====
00070 public: // morkNode virtual methods
00071   // virtual void CloseMorkNode(morkEnv* ev); // morkHandle is fine
00072   virtual ~orkinThumb(); // morkHandle destructor does everything
00073   
00074 protected: // construction is protected (use the static Make() method)
00075   orkinThumb(morkEnv* ev, // note morkUsage is always morkUsage_kPool
00076     morkHandleFace* ioFace,    // must not be nil, cookie for this handle
00077     morkThumb* 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   orkinThumb(const morkHandle& other);
00083   orkinThumb& operator=(const morkHandle& 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 orkinThumb* MakeThumb(morkEnv* ev, morkThumb* ioObject);
00104 
00105 public: // utilities:
00106 
00107   morkEnv* CanUseThumb(nsIMdbEnv* mev, mork_bool inMutable,
00108     mdb_err* outErr) const;
00109 
00110 public: // type identification
00111   mork_bool IsOrkinThumb() const
00112   { return mHandle_Magic == morkMagic_kThumb; }
00113 
00114   mork_bool IsOrkinThumbHandle() const
00115   { return this->IsHandle() && this->IsOrkinThumb(); }
00116 
00117 public: // nsIMdbThumb
00118 
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 nsIMdbThumb methods =====
00151   NS_IMETHOD GetProgress(nsIMdbEnv* ev, mdb_count* outTotal,
00152     mdb_count* outCurrent, mdb_bool* outDone, mdb_bool* outBroken);
00153   
00154   NS_IMETHOD DoMore(nsIMdbEnv* ev, mdb_count* outTotal,
00155     mdb_count* outCurrent, mdb_bool* outDone, mdb_bool* outBroken);
00156   
00157   NS_IMETHOD CancelAndBreakThumb(nsIMdbEnv* ev);
00158 // } ===== end nsIMdbThumb methods =====
00159 };
00160 
00161 
00162 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00163 
00164 #endif /* _ORKINTHUMB_ */