home *** CD-ROM | disk | FTP | other *** search
- /*
- File: UpdatCtr.cpp
-
- Contains: Implementation of ODMemContainer class.
-
- Owned by: Vincent Lo
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <6> 10/8/95 TJ Fixes Recomended by Refball
- <5> 8/3/95 RR #1257260: Collapse B classes. Remove
- somInit methods. Don't call IsInitialized
- or SubclassResponsibility
- <4> 7/21/95 VL 1270320: Create PlatformFile on stack.
- <3> 5/26/95 VL 1251403: Multithreading naming support.
- <2> 3/9/95 VL 1225504: Fixed Document ref-counting
- problem.
- <1> 2/10/95 VL first checked in
- To Do:
- */
-
- #define ODUpdateContainer_Class_Source
-
- #define VARIABLE_MACROS
-
- #include <UpdatCtr.xih>
-
- #ifndef _PLFMDEF_
- #include "PlfmDef.h"
- #endif
-
- #ifndef SOM_ODStorageSystem_xh
- #include <ODStor.xh>
- #endif
-
- #ifndef SOM_CMDocument_xh
- #include <CMDoc.xh>
- #endif
-
- #ifndef _MEMHDR_
- #include "MemHdr.h"
- #endif
-
- #ifndef _TARGTHDR_
- #include "TargtHdr.h"
- #endif
-
- #ifndef __CM_API__
- #include "CMAPI.h"
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ODNEW_
- #include <ODNew.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _PLFMFILE_
- #include <PlfmFile.h>
- #endif
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #pragma segment ODUpdateContainer
-
- //==============================================================================
- // ODUpdateContainer
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: ~ODUpdateContainer
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODUpdateContainersomUninit(ODUpdateContainer *somSelf)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","somUninit");
-
- ODSafeReleaseObject(_fTargetDocument);
- ODSafeReleaseObject(_fTargetContainer);
-
- ODDisposeHandle(_fHandle);
- }
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: InitContainer
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODUpdateContainerInitContainer(ODUpdateContainer *somSelf, Environment *ev,
- ODStorageSystem* storage, ODContainerID* id)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","InitContainer");
-
- SOM_CATCH return;
-
- /* Moved from somInit. SOM itself sets fields to zero
- _fTargetContainer = kODNULL;
- _fTargetDocument = kODNULL;
- _fHandle = kODNULL;
- */
-
- ODBoolean fileLocked = kODTrue;
- PlatformFile file;
-
- ODVolatile(fileLocked);
- TRY
- file.Specify((FSSpec*) id->_buffer);
- fileLocked = file.IsLocked();
- if (fileLocked == kODFalse)
- file.Lock();
-
- _fTargetContainer = (ODBentoContainer*) GetFileContainer(ev,
- storage->GetSession(ev),
- (FSSpec*) id->_buffer);
- _fTargetDocument = (CMDocument*) _fTargetContainer->AcquireDocument(ev, kODDefaultDocument);
-
- if (fileLocked == kODFalse)
- file.Unlock();
-
- CATCH_ALL
-
- if (fileLocked == kODFalse)
- file.Unlock();
-
- RERAISE;
-
- ENDTRY
-
- _fHandle = ODNewHandle(0);
-
- ODByteArray* ba = CreateByteArray(&_fHandle, sizeof(ODHandle));
- parent_InitContainer(somSelf, ev, storage, ba);
- DisposeByteArray(ba);
- }
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: GetTargetFileContainer
- //------------------------------------------------------------------------------
-
- SOM_Scope ODBentoContainer* SOMLINK ODUpdateContainerGetTargetContainer(ODUpdateContainer *somSelf, Environment *ev)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","GetTargetContainer");
-
- return _fTargetContainer;
- }
-
- //------------------------------------------------------------------------------
- // ODUpdateContainer: GetTargetDocument
- //------------------------------------------------------------------------------
-
- SOM_Scope CMDocument* SOMLINK ODUpdateContainerGetTargetDocument(ODUpdateContainer *somSelf, Environment *ev)
- {
- ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
- ODUpdateContainerMethodDebug("ODUpdateContainer","GetTargetDocument");
-
- return _fTargetDocument;
- }
-