Back to index

lightning-sunbird  0.9+nobinonly
morkSpace.cpp
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 _MDB_
00039 #include "mdb.h"
00040 #endif
00041 
00042 #ifndef _MORK_
00043 #include "mork.h"
00044 #endif
00045 
00046 #ifndef _MORKNODE_
00047 #include "morkNode.h"
00048 #endif
00049 
00050 #ifndef _MORKMAP_
00051 #include "morkMap.h"
00052 #endif
00053 
00054 #ifndef _MORKSPACE_
00055 #include "morkSpace.h"
00056 #endif
00057 
00058 #ifndef _MORKMAP_
00059 #include "morkMap.h"
00060 #endif
00061 
00062 #ifndef _MORKENV_
00063 #include "morkEnv.h"
00064 #endif
00065 
00066 #ifndef _MORKSTORE_
00067 #include "morkStore.h"
00068 #endif
00069 
00070 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
00071 
00072 // ````` ````` ````` ````` ````` 
00073 // { ===== begin morkNode interface =====
00074 
00075 /*public virtual*/ void
00076 morkSpace::CloseMorkNode(morkEnv* ev) // CloseSpace() only if open
00077 {
00078   if ( this->IsOpenNode() )
00079   {
00080     this->MarkClosing();
00081     this->CloseSpace(ev);
00082     this->MarkShut();
00083   }
00084 }
00085 
00086 /*public virtual*/
00087 morkSpace::~morkSpace() // assert CloseSpace() executed earlier
00088 {
00089   MORK_ASSERT(SpaceScope()==0);
00090   MORK_ASSERT(mSpace_Store==0);
00091   MORK_ASSERT(this->IsShutNode());
00092 }    
00093 
00094 /*public non-poly*/
00095 //morkSpace::morkSpace(morkEnv* ev, const morkUsage& inUsage,
00096 //  nsIMdbHeap* ioNodeHeap, const morkMapForm& inForm,
00097 //  nsIMdbHeap* ioSlotHeap)
00098 //: morkNode(ev, inUsage, ioNodeHeap)
00099 //, mSpace_Map(ev, morkUsage::kMember, (nsIMdbHeap*) 0, ioSlotHeap)
00100 //{
00101 //  ev->StubMethodOnlyError();
00102 //}
00103 
00104 /*public non-poly*/
00105 morkSpace::morkSpace(morkEnv* ev,
00106   const morkUsage& inUsage, mork_scope inScope, morkStore* ioStore,
00107   nsIMdbHeap* ioHeap, nsIMdbHeap* ioSlotHeap)
00108 : morkBead(ev, inUsage, ioHeap, inScope)
00109 , mSpace_Store( 0 )
00110 , mSpace_DoAutoIDs( morkBool_kFalse )
00111 , mSpace_HaveDoneAutoIDs( morkBool_kFalse )
00112 , mSpace_CanDirty( morkBool_kFalse ) // only when store can be dirtied
00113 {
00114   if ( ev->Good() )
00115   {
00116     if ( ioStore && ioSlotHeap )
00117     {
00118       morkStore::SlotWeakStore(ioStore, ev, &mSpace_Store);
00119 
00120       mSpace_CanDirty = ioStore->mStore_CanDirty;
00121       if ( mSpace_CanDirty ) // this new space dirties the store?
00122         this->MaybeDirtyStoreAndSpace();
00123         
00124       if ( ev->Good() )
00125         mNode_Derived = morkDerived_kSpace;
00126     }
00127     else
00128       ev->NilPointerError();
00129   }
00130 }
00131 
00132 /*public non-poly*/ void
00133 morkSpace::CloseSpace(morkEnv* ev) // called by CloseMorkNode();
00134 {
00135   if ( this )
00136   {
00137     if ( this->IsNode() )
00138     {
00139       morkStore::SlotWeakStore((morkStore*) 0, ev, &mSpace_Store);
00140       mBead_Color = 0; // this->CloseBead();
00141       this->MarkShut();
00142     }
00143     else
00144       this->NonNodeError(ev);
00145   }
00146   else
00147     ev->NilPointerError();
00148 }
00149 
00150 // } ===== end morkNode methods =====
00151 // ````` ````` ````` ````` ````` 
00152 
00153 /*static*/ void 
00154 morkSpace::NonAsciiSpaceScopeName(morkEnv* ev)
00155 {
00156   ev->NewError("SpaceScope() > 0x7F");
00157 }
00158 
00159 /*static*/ void 
00160 morkSpace::NilSpaceStoreError(morkEnv* ev)
00161 {
00162   ev->NewError("nil mSpace_Store");
00163 }
00164 
00165 morkPool* morkSpace::GetSpaceStorePool() const
00166 {
00167   return &mSpace_Store->mStore_Pool;
00168 }
00169 
00170 mork_bool morkSpace::MaybeDirtyStoreAndSpace()
00171 {
00172   morkStore* store = mSpace_Store;
00173   if ( store && store->mStore_CanDirty )
00174   {
00175     store->SetStoreDirty();
00176     mSpace_CanDirty = morkBool_kTrue;
00177   }
00178   
00179   if ( mSpace_CanDirty )
00180   {
00181     this->SetSpaceDirty();
00182     return morkBool_kTrue;
00183   }
00184   
00185   return morkBool_kFalse;
00186 }
00187 
00188 
00189 //3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789