home *** CD-ROM | disk | FTP | other *** search
- /*
- File: LinkSpecB.cpp
-
- Contains: Implementation for ODBaseLinkSpec class.
-
- Owned by: Craig Carper
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <6> 8/3/95 RR #1257260: Collapse B classes. Remove
- somInit methods. Don't call IsInitialized
- or SubclassResponsibility
- <5> 5/26/95 VL 1251403: Multithreading naming support.
- <4> 3/10/95 CC 1225926: Added FromThisDraft().
- <3> 12/20/94 VL 1195012: Make Storage calls be
- marshallable.
- <2> 12/15/94 CC 1205709 LinkSpcB.cpp - Added implementation
- of AcquirePart(), GetPartData(),
- ReadLinkSpec(), WriteLinkSpec() methods.
- <1> 6/24/94 CC first checked in
- To Do:
- */
-
- #define VARIABLE_MACROS
-
- #define ODBaseLinkSpec_Class_Source
- #include <LinkSpcB.xih>
-
- #ifndef SOM_ODStorageUnit_xh
- #include "StorageU.xh"
- #endif
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #pragma segment ODBaseLinkSpec
-
- //==============================================================================
- // ODBaseLinkSpec
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec: somInit
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODBaseLinkSpecsomInit(ODBaseLinkSpec *somSelf)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","somInit");
-
- parent_somInit(somSelf);
-
- _fPart = kODNULL;
- _fPartData = CreateEmptyByteArrayStruct(0);
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec: somUninit
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODBaseLinkSpecsomUninit(ODBaseLinkSpec *somSelf)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","somUninit");
-
- DisposeByteArrayStruct(_fPartData);
-
- parent_somUninit(somSelf);
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec: InitBaseLinkSpec
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODBaseLinkSpecInitBaseLinkSpec(ODBaseLinkSpec *somSelf, Environment *ev,
- ODPart* part,
- ODByteArray* partData)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","InitBaseLinkSpec");
-
- SOM_CATCH return;
-
- if ( partData )
- {
- DisposeByteArrayStruct(_fPartData);
- _fPartData = CopyByteArrayStruct(partData);
- }
-
- _fPart = part;
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec::GetPart
- //------------------------------------------------------------------------------
-
- SOM_Scope ODPart* SOMLINK ODBaseLinkSpecGetPart(ODBaseLinkSpec *somSelf, Environment *ev)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","GetPart");
-
- return _fPart;
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec::GetPartData
- //------------------------------------------------------------------------------
-
- SOM_Scope ODByteArray SOMLINK ODBaseLinkSpecGetPartData(ODBaseLinkSpec *somSelf, Environment *ev)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","GetPartData");
-
- SOM_CATCH return CreateEmptyByteArrayStruct(0);
-
- return CopyByteArrayStruct(&_fPartData);
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec: WriteLinkSpec
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODBaseLinkSpecWriteLinkSpec(ODBaseLinkSpec *somSelf, Environment *ev,
- ODStorageUnit* su)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","WriteLinkSpec");
-
- SOM_CATCH return;
-
- // Assumes su has been focused to a property and link spec value
-
- StorageUnitSetValue(su, ev, sizeof(ODPart*), (ODValue) &_fPart);
- StorageUnitSetValue(su, ev, sizeof(ODULong), (ODValue) &_fPartData._length);
- StorageUnitSetValue(su, ev, _fPartData._length, (ODValue) _fPartData._buffer);
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec: ReadLinkSpec
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODBaseLinkSpecReadLinkSpec(ODBaseLinkSpec *somSelf, Environment *ev,
- ODStorageUnit* su)
- {
- ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","ReadLinkSpec");
-
- SOM_CATCH return;
-
- ODPart* part;
- ODByteArray partData;
- ODULong dataSize;
- ODULong valueSize;
-
- // Assumes su has been focused to a property and link spec value,
- // and the current offset is where the base link spec was written.
-
- valueSize = StorageUnitGetValue(su, ev, sizeof(ODPart*), (ODValue) &part);
- if ( valueSize != sizeof(ODPart*) )
- THROW(kODErrCorruptLinkSpecValue);
-
- valueSize = StorageUnitGetValue(su, ev, sizeof(ODULong), (ODValue) &dataSize);
- if ( valueSize != sizeof(ODULong) )
- THROW(kODErrCorruptLinkSpecValue);
-
- partData = CreateEmptyByteArrayStruct(dataSize);
- if ( dataSize > 0 )
- {
- valueSize = StorageUnitGetValue(su, ev, dataSize, (ODValue) partData._buffer);
- if ( valueSize != dataSize )
- {
- DisposeByteArrayStruct(partData);
- THROW(kODErrCorruptLinkSpecValue);
- }
- }
- partData._length = dataSize;
-
- _fPart = part;
- DisposeByteArrayStruct(_fPartData);
- _fPartData = partData;
- }
-
- //------------------------------------------------------------------------------
- // ODBaseLinkSpec::FromThisDraft
- //------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODBaseLinkSpecFromThisDraft(ODBaseLinkSpec *somSelf, Environment *ev)
- {
- // ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
- ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","FromThisDraft");
-
- return kODTrue;
- }