Back to index

lightning-sunbird  0.9+nobinonly
orkinEnv.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 _ORKINENV_
00039 #define _ORKINENV_ 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 _MORKEnv_
00058 #include "morkEnv.h"
00059 #endif
00060 
00061 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00062 
00063 #define morkMagic_kEnv 0x456E7669 /* ascii 'Envi' */
00064 
00065 /*| orkinEnv:
00066 |*/
00067 class orkinEnv : public morkHandle, public nsIMdbEnv { // nsIMdbObject
00068 
00069 // { ===== begin morkNode interface =====
00070 public: // morkNode virtual methods
00071   virtual void CloseMorkNode(morkEnv* ev); // override to clean up mork env
00072   virtual ~orkinEnv(); // morkHandle destructor does everything
00073   
00074 protected: // construction is protected (use the static Make() method)
00075   orkinEnv(morkEnv* ev, // note morkUsage is always morkUsage_kPool
00076     morkHandleFace* ioFace,    // must not be nil, cookie for this handle
00077     morkEnv* 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   orkinEnv(const morkHandle& other);
00083   orkinEnv& 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 orkinEnv* MakeEnv(morkEnv* ev, morkEnv* ioObject);
00104 
00105 public: // utilities:
00106 
00107   morkEnv* CanUseEnv(mork_bool inMutable, mdb_err* outErr) const;
00108 
00109 public: // type identification
00110   mork_bool IsOrkinEnv() const
00111   { return mHandle_Magic == morkMagic_kEnv; }
00112 
00113   mork_bool IsOrkinEnvHandle() const
00114   { return this->IsHandle() && this->IsOrkinEnv(); }
00115 
00116 public:
00117 
00118   NS_DECL_ISUPPORTS
00119 // { ===== begin nsIMdbObject methods =====
00120 
00121   // { ----- begin attribute methods -----
00122   NS_IMETHOD IsFrozenMdbObject(nsIMdbEnv* ev, mdb_bool* outIsReadonly);
00123   // same as nsIMdbPort::GetIsPortReadonly() when this object is inside a port.
00124   // } ----- end attribute methods -----
00125 
00126   // { ----- begin factory methods -----
00127   NS_IMETHOD GetMdbFactory(nsIMdbEnv* ev, nsIMdbFactory** acqFactory); 
00128   // } ----- end factory methods -----
00129 
00130   // { ----- begin ref counting for well-behaved cyclic graphs -----
00131   NS_IMETHOD GetWeakRefCount(nsIMdbEnv* ev, // weak refs
00132     mdb_count* outCount);  
00133   NS_IMETHOD GetStrongRefCount(nsIMdbEnv* ev, // strong refs
00134     mdb_count* outCount);
00135 
00136   NS_IMETHOD AddWeakRef(nsIMdbEnv* ev);
00137   NS_IMETHOD AddStrongRef(nsIMdbEnv* ev);
00138 
00139   NS_IMETHOD CutWeakRef(nsIMdbEnv* ev);
00140   NS_IMETHOD CutStrongRef(nsIMdbEnv* ev);
00141   
00142   NS_IMETHOD CloseMdbObject(nsIMdbEnv* ev); // called at strong refs zero
00143   NS_IMETHOD IsOpenMdbObject(nsIMdbEnv* ev, mdb_bool* outOpen);
00144   // } ----- end ref counting -----
00145   
00146 // } ===== end nsIMdbObject methods =====
00147 
00148 // { ===== begin nsIMdbEnv methods =====
00149 
00150   // { ----- begin attribute methods -----
00151   NS_IMETHOD GetErrorCount(mdb_count* outCount,
00152     mdb_bool* outShouldAbort);
00153   NS_IMETHOD GetWarningCount(mdb_count* outCount,
00154     mdb_bool* outShouldAbort);
00155   
00156   NS_IMETHOD GetEnvBeVerbose(mdb_bool* outBeVerbose);
00157   NS_IMETHOD SetEnvBeVerbose(mdb_bool inBeVerbose);
00158   
00159   NS_IMETHOD GetDoTrace(mdb_bool* outDoTrace);
00160   NS_IMETHOD SetDoTrace(mdb_bool inDoTrace);
00161   
00162   NS_IMETHOD GetAutoClear(mdb_bool* outAutoClear);
00163   NS_IMETHOD SetAutoClear(mdb_bool inAutoClear);
00164   
00165   NS_IMETHOD GetErrorHook(nsIMdbErrorHook** acqErrorHook);
00166   NS_IMETHOD SetErrorHook(
00167     nsIMdbErrorHook* ioErrorHook); // becomes referenced
00168   
00169   NS_IMETHOD GetHeap(nsIMdbHeap** acqHeap);
00170   NS_IMETHOD SetHeap(
00171     nsIMdbHeap* ioHeap); // becomes referenced
00172   // } ----- end attribute methods -----
00173   
00174   NS_IMETHOD ClearErrors(); // clear errors beore re-entering db API
00175   NS_IMETHOD ClearWarnings(); // clear warnings
00176   NS_IMETHOD ClearErrorsAndWarnings(); // clear both errors & warnings
00177 // } ===== end nsIMdbEnv methods =====
00178 };
00179 
00180 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00181 
00182 #endif /* _ORKINENV_ */