home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / bento / headers / storageu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-02  |  10.0 KB  |  324 lines

  1. /*
  2.     File:        StorageU.h
  3.  
  4.     Contains:    definition of XMPStorageUnit
  5.  
  6.     Written by: Vincent Lo, Tantek I. éelik
  7.  
  8.     Copyright:    ⌐ 1992-1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <39>      2/8/94    VL        Got rid of friends.
  13.         <38>      2/4/94    VL        Moved to PPC Header and began code cleanup.
  14.         <37>     1/27/94    VL        Changed CloneTo which takes XMPDraftKey and
  15.                                     initiatingFrameSU and returns a
  16.                                     XMPStorageUnit*. Added CloneInto which also
  17.                                     takes XMPDraftKey and initiatingFrameSU.
  18.         <36>     1/12/94    VL        Added GetSession.
  19.         <35>    12/21/93    VL        Changed GetValueSize to GetValue. Added
  20.                                     GetObjectID.
  21.         <34>    12/16/93    VL        Fixed problems associated with DocSU.
  22.         <33>    12/14/93    VL        Replaced Initialize with InitStorageUnit.
  23.                                     Added GetCMContainer.
  24.         <32>    11/23/93    VL        Made XMPStorageUnit pool-aware.
  25.         <31>    11/12/93    PH        ResolveAllPromises
  26.         <30>     11/9/93    PH        Add private by convention calls
  27.         <29>     11/5/93    PH        Add Get/SetPromiseInfo calls
  28.         <28>     11/5/93    VL        Changed CopyFrom to CopyTo.
  29.         <27>     11/4/93    PH        Add new promise api calls
  30.         <26>     11/1/93    VL        Replaced GetStorageUnitRef with
  31.                                     GetStrongStorageUnitRef and
  32.                                     GetWeakStorageUnitRef. Added
  33.                                     IsStrongStorageUnitRef and
  34.                                     IsWeakStorageUnitRef. Replaced CloneFrom
  35.                                     with CloneTo.
  36.         <25>    10/21/93    PH        Add ResolvePromise method
  37.         <24>    10/20/93    PH        Add promise changes
  38.         <23>    10/18/93    CG        Added #define id for ASLM
  39.         <22>     9/23/93    VL        Added CountValues and CountProperties.
  40.         <21>     9/14/93    VL        Added Lock and Unlock to be used as
  41.                                     semaphore.
  42.         <20>      9/8/93    VL        Added new fields to handle flushing of
  43.                                     Bento Container.
  44.         <19>     8/19/93    VL        Added ::RemoveStorageUnitRef.
  45.         <18>     8/18/93    VL        Added private CleanupAndFail.
  46.         <17>     8/13/93    CG        Added ASLM define for exported class.
  47.         <16>     8/12/93    VL        Added Exists.
  48.         <15>     8/11/93    VL        XMPStorageUnitRefIterator should have
  49.                                     IsNotComplete (instead of IsComplete).
  50.         <14>      8/6/93    PH        Storage integration
  51.         <13>     7/29/93    VL        StorageUnitName should be XMPISOStr.
  52.         <12>     7/28/93    PH        Added iterator code
  53.         <11>     7/21/93    VL        Implemented Clone. Added
  54.                                     XMPStorageUnitRefIterator. Removed Revert.
  55.         <10>      7/2/93    Té        change GetName to return XMPName* not
  56.                                     XMPName
  57.          <9>      7/1/93    VL        Added fID for Prototype.
  58.          <8>     6/23/93    Té        change XMPPropertyName from XMPName to
  59.                                     XMPISOStr
  60.          <7>     6/22/93    VL        fObject is also fID.
  61.          <6>     4/29/93    VL        8.3 Name Change.
  62.          <5>      4/9/93    VL        XMPStorageUnit should be subclassed from
  63.                                     XMPRefCntObject.
  64.          <4>      4/7/93    VL        Initialize should return void.
  65.          <3>      4/7/93    VL        Added Initialize method.
  66.          <2>      4/6/93    VL        Made compilable.
  67.          <1>      4/6/93    VL        first checked in
  68.  
  69.     To Do:
  70.         1) kXMPIndexAll should be XMPValueIndex.
  71.         2) Should we separate this class to StorUM.cp and StorageU.cp?
  72. */
  73.  
  74. #ifndef _STORAGEU_
  75. #define _STORAGEU_
  76.  
  77. #ifndef _XMPTYPES_
  78. #include "XMPTypes.h"
  79. #endif
  80.  
  81. #ifndef _REFCTOBJ_
  82. #include "RefCtObj.h"
  83. #endif
  84.  
  85. #ifndef __CM_API__
  86. #include "CMAPI.h"
  87. #endif
  88.  
  89. //==============================================================================
  90. // Constants
  91. //==============================================================================
  92.  
  93. typedef enum {
  94.     kXMPPosUndefined        = -1,
  95.     kXMPPosSame                = 0x00,
  96.     kXMPPosAll                = 1,
  97.     kXMPPosFirstSib            = 2,
  98.     kXMPPosLastSib            = 3,
  99.     kXMPPosNextSib            = 4,
  100.     kXMPPosPrevSib            = 5,
  101.     kXMPPosFirstBelow        = 6,
  102.     kXMPPosLastBelow        = 7,
  103.     kXMPPosFirstAbove         = 8,
  104.     kXMPPosLastAbove        = 9,
  105.     kXMPPosReserved11         = 10,
  106.     kXMPPosReserved12        = 11,
  107.     kXMPPosReserved13        = 12,
  108.     kXMPPosReserved14        = 13,
  109.     kXMPPosReserved15        = 14,
  110.     
  111.     kXMPPosMWrap            = 0x10,
  112.     kXMPPosMOtherTypes        = 0x20
  113. } XMPPositionCode;
  114.  
  115. const    XMPID            kXMPIDAll    = 0;
  116. const    XMPID            kXMPIndexAll= 0;
  117. const    XMPValueType    kXMPTypeAll    = 0;
  118. const    XMPID            kXMPIDWild    = 0;
  119.  
  120. //==============================================================================
  121. // Scalar Types
  122. //==============================================================================
  123.  
  124. typedef    void*        XMPValue;
  125. typedef    XMPID        XMPValueIndex;
  126. typedef    XMPISOStr    XMPPropertyName;
  127. typedef XMPID        XMPStorageUnitID;
  128. typedef    XMPISOStr    XMPStorageUnitName;
  129. typedef XMPID        XMPStorageUnitRef;
  130. typedef XMPULong    XMPStorageUnitKey;
  131. typedef XMPULong    XMPDraftKey;
  132.  
  133. //==============================================================================
  134. // Classes defined in this interface
  135. //==============================================================================
  136.  
  137. class    XMPStorageUnit;
  138.  
  139. //==============================================================================
  140. // Classes used by this interface
  141. //==============================================================================
  142.  
  143. class    XMPDraft;
  144. class    XMPSession;
  145. class    XMPPart;
  146. class    XMPStorageUnitCursor;
  147. class    XMPStorageUnitView;
  148. class    XMPAEHashTable;
  149.  
  150. class    XMPRefTable;
  151. class    XMPRefCollection;
  152.  
  153. //==============================================================================
  154. // XMPStorageUnit
  155. //==============================================================================
  156.  
  157. #define kXMPStorageUnitID "appl:xmpstorageunit$class,1.0.0"
  158.  
  159. class XMPStorageUnit : public XMPRefCntObject {
  160.  
  161.     friend class XMPStorageUnitRefIterator;
  162.  
  163. public:
  164.  
  165.     XMPMethod    XMPDraft*        GetDraft();
  166.     
  167.     XMPMethod    XMPSession*        GetSession();
  168.             
  169.     XMPMethod    void IncrementRefCount();
  170.             
  171.     XMPMethod    void Release();
  172.  
  173.     XMPMethod XMPSize Purge(XMPSize size);
  174.     
  175.     XMPMethod    XMPBoolean    Exists(XMPPropertyName propertyName,
  176.                                     XMPValueType valueType,
  177.                                     XMPValueIndex valueIndex);
  178.  
  179.     XMPMethod    XMPBoolean    Exists(XMPStorageUnitCursor* cursor);
  180.  
  181.     XMPMethod    XMPULong    CountProperties();
  182.     XMPMethod    XMPULong    CountValues();
  183.     
  184.     XMPMethod    XMPStorageUnit*    Focus(XMPPropertyName propertyName,
  185.                                         XMPPositionCode propertyPosCode,
  186.                                         XMPValueType valueType,
  187.                                         XMPValueIndex valueIndex,
  188.                                         XMPPositionCode    valuePosCode);
  189.  
  190.     XMPMethod    XMPStorageUnit*    Focus(XMPStorageUnitCursor* cursor);
  191.     
  192.     XMPMethod    XMPStorageUnitCursor*    CreateCursor();
  193.     
  194.     XMPMethod    XMPStorageUnit*    Externalize();    
  195.             
  196.     XMPMethod     XMPStorageUnit*    Internalize();    
  197.         
  198.     XMPMethod    XMPID            GetID();        
  199.  
  200.     XMPMethod    XMPStorageUnitName GetName();        
  201.         
  202.     XMPMethod    void SetName(XMPStorageUnitName name);
  203.  
  204.     XMPMethod    XMPStorageUnit*    AddProperty(XMPPropertyName propertyName);    
  205.     
  206.     XMPMethod    XMPStorageUnit* AddValue(XMPValueType type);
  207.  
  208.     XMPMethod    XMPStorageUnit*    Remove();
  209.  
  210.     XMPMethod void            CopyTo(XMPStorageUnit* toSU);
  211.         
  212.     XMPMethod XMPStorageUnit*    CloneTo(XMPDraftKey key, XMPDraft* destDraft, XMPStorageUnit* initiatingFrame);
  213.  
  214.     XMPMethod void            CloneInto(XMPDraftKey key, XMPStorageUnit* destStorageUnit, XMPStorageUnit* initiatingFrame);
  215.     
  216.     XMPMethod    XMPStorageUnitView*    CreateView(XMPStorageUnitCursor* cursor);
  217.  
  218.     XMPMethod XMPPropertyName    GetProperty();
  219.  
  220.     XMPMethod XMPValueType    GetType();
  221.     XMPMethod void            SetType(XMPValueType valueType);
  222.  
  223.     XMPMethod void            SetOffset(XMPULong offset);
  224.     XMPMethod XMPULong        GetOffset();
  225.     
  226.     XMPMethod XMPULong        GetValue(XMPULong length, XMPValue value);
  227.     XMPMethod void            SetValue(XMPULong length, XMPValue value);
  228.     XMPMethod void            InsertValue(XMPULong length, XMPValue value);
  229.     XMPMethod void            DeleteValue(XMPULong length);
  230.     
  231.     XMPMethod XMPULong        GetSize();
  232.     
  233.     XMPMethod XMPStorageUnitRef    GetStrongStorageUnitRef(XMPStorageUnit* embeddedSU);
  234.     XMPMethod XMPStorageUnitRef    GetWeakStorageUnitRef(XMPStorageUnit* embeddedSU);
  235.     XMPMethod XMPBoolean        IsStrongStorageUnitRef(XMPStorageUnitRef ref);
  236.     XMPMethod XMPBoolean        IsWeakStorageUnitRef(XMPStorageUnitRef ref);
  237.     XMPMethod XMPStorageUnit*    RemoveStorageUnitRef(XMPStorageUnitRef aRef);
  238.     XMPMethod XMPStorageUnitID    GetIDFromStorageUnitRef(XMPStorageUnitRef aRef);
  239.     
  240.     XMPMethod XMPStorageUnitRefIterator* GetStorageUnitRefIterator();
  241.     
  242.     XMPMethod    XMPULong            GetGenerationNumber();
  243.     XMPMethod    XMPULong            IncrementGenerationNumber();
  244.  
  245.     XMPMethod    XMPBoolean    IsPromiseValue();
  246.     XMPMethod    void        SetPromiseValue(XMPValueType valueType,
  247.                                             XMPULong offset,
  248.                                             XMPULong length,
  249.                                             XMPValue value,
  250.                                             XMPPart *sourcePart);
  251.     XMPMethod    XMPULong    GetPromiseValue(XMPValueType valueType,
  252.                                             XMPULong offset,
  253.                                             XMPULong length,
  254.                                             XMPValue value,
  255.                                             XMPPart **sourcePart);
  256.     XMPMethod    void        ClearAllPromises();
  257.  
  258.     XMPStorageUnitKey    Lock(XMPStorageUnitKey key);
  259.     void                Unlock(XMPStorageUnitKey key);
  260.  
  261. protected:
  262.  
  263.     CMContainer            fCMContainer;
  264.     CMObject            fObject;
  265.     
  266.     XMPVMethod    void        SetChangedFromPrevFlag(XMPBoolean changed);
  267.     XMPVMethod    CMContainer    GetCMContainer();
  268.  
  269. private:
  270.  
  271.     void                CleanupAndFail(XMPError    err);
  272.     XMPStorageUnitRef     GetStorageUnitRef(XMPStorageUnit* embeddedSU, XMPBoolean strong);
  273.     XMPStorageUnitRef    GetNextStorageUnitRef();
  274.     void                 GetClonedSUs(XMPAEHashTable* clonedSUIDs, XMPStorageUnit* initiatingFrameSU);
  275.     XMPStorageUnitRef     SetStorageUnitRef(XMPStorageUnit* embeddedSU, XMPStorageUnitRef ref);
  276.     
  277.     XMPDraft*            fDraft;
  278.     XMPStorageUnitID    fID; 
  279.     
  280.     CMObjectID            fObjectID;
  281.     CMProperty            fCurProperty;
  282.     XMPBoolean            fHasPropertyLooped;
  283.     XMPValueIndex        fCurValueIndex;
  284.     CMValue                fCurValue;
  285.     XMPValueType        fCurValueType;
  286.     XMPULong            fOffset;
  287.     CMType                fCurType;
  288.     XMPBoolean            fHasValueLooped;
  289.     XMPULong            fPromiseCount;
  290.     
  291.     XMPULong            fCurrentKey;
  292.     XMPULong            fLockCount;
  293.     
  294.     XMPULong            fCurrentSURef;
  295.     
  296.     XMPHeap                fHeap;
  297.     
  298.  
  299. public: // Private by convention calls:
  300.  
  301.     XMPStorageUnit();
  302.     
  303.     XMPVMethod    ~XMPStorageUnit();
  304.  
  305.     XMPVMethod    void InitStorageUnit(XMPDraft* draft, XMPStorageUnitID suid);
  306.  
  307.     XMPMethod    void        Clone(XMPDraftKey key, XMPStorageUnit* fromSU, XMPAEHashTable* clonedSUIDs);
  308.     XMPMethod    void        ResolvePromise();
  309.     XMPMethod    void        ResolveAllPromises();
  310.     XMPMethod    XMPPtr        GetPromiseInfo();
  311.     XMPMethod    void        SetPromiseInfo(XMPPtr theInfo);
  312.     XMPMethod    void        IncrementPromiseCount();
  313.     XMPMethod    void        DecrementPromiseCount();
  314.     
  315.     XMPMethod    XMPHeap        GetHeap();
  316.     
  317.     XMPMethod    XMPID        GetObjectID();
  318.     
  319.     XMPMethod    CMValue        GetCurValue();
  320. };
  321.  
  322.  
  323. #endif    // _STORAGEU_
  324.