#ifdef __PRIVATE__
//#
//#	File:		CMDraft.idl
//#
//#	Contains:	Definition of CMDraft
//#
//#	Written by:	Vincent Lo
//#
//#	Copyright:	c 1994 by Apple Computer, Inc., all rights reserved.
//#
//#	Change History (most recent first):
//#
//#		<13>	 11/1/94	CC		1190911, 1192030, 1196908 - Removed
//#									GetWeakReferenceProp(),
//#									GetLinkSourceFromLink(),
//#									GetLinkFromLinkSource(),
//#									ConnectLinkSourceToNewPart(), fClonedLinks.
//#										Added SetOriginalID(), GetOriginalID(),
//#									ValidWeakReferenceProperty(),
//#									CompanionWasCloned(), GetCloneKind(),
//#									CopiedLinkSubstitution().
//#		<12>	 10/4/94	CC		1190858 - Added ReleaseLinkSource().
//#		<11>	 9/16/94	CC		1186957 - Added private methods
//#									GetLinkSourceFromLink() and
//#									GetLinkFromLinkSource().
//#		<10>	 9/15/94	CC		1186776 - Added fClonedLinks,
//#									StrongClone(), GetWeakReferenceProp(), and
//#									ConnectLinkSourceToNewProp(), and deleted
//#									obsoleted methods.
//#		 <9>	  9/6/94	VL		1184177: Removed GetName and SetName.
//#		 <8>	 8/26/94	VL		1183174: Added WeakClone and private field
//#									fWeakClonedSUIDs.
//#		 <7>	 8/16/94	VL		1143605: Added Clone.
//#		 <6>	 8/11/94	CC		Add override of CreateLinkIterator() and
//#									CreateLinkSourceIterator().
//#		 <5>	 7/26/94	VL		Got rid of MacStorageUnit and
//#									MacDragAndDropStorageUnit.
//#		 <4>	  7/5/94	VL		Fixed in/out.
//#		 <3>	 6/22/94	VL		Added functionprefix.
//#		 <2>	 6/14/94	CC		Changed ODHeap to ODMemoryHeap.
//#		 <1>	  6/8/94	VL		first checked in
//#
//#	To Do:
//#
#else
//#	Copyright:	c 1993-1994 by Apple Computer, Inc., all rights reserved.
#endif

#ifndef _CMDRAFT_
#define _CMDRAFT_

#ifndef _DRAFT_
#include "Draft.idl"
#endif

//==============================================================================
// Classes defined in this interface
//==============================================================================
interface  CMDraft;

//==============================================================================
// Classes used by this interface
//==============================================================================
interface ODPersistentObject;
interface ODLink;
interface ODLinkSource;
interface CMDocument;
interface ODEmbeddedContainer;
interface CMLinkIterator;
interface CMLinkSourceIterator;
interface ODStorageUnit;

//==============================================================================
// Implementation Types
//==============================================================================

#ifdef __PRIVATE__
typedef somToken LinkedList;
typedef somToken AEHashTable;
typedef somToken IDList;
typedef somToken CMContainer;
typedef somToken VersionList;
typedef somToken ODMemoryHeapID;
#endif

//==============================================================================
// ODDraft
//==============================================================================

interface CMDraft :  ODDraft
{

#ifdef __PRIVATE__

	ODStorageUnit CreateSU(in ODStorageUnitID id, 
							in ODType suType);

	void	CreateVersion();
	void	OpenVersion();
	void	CloseVersion();
	void	DestroyVersion();
	void	FlushVersion();

	ODPersistentObject GetPersistentObject(in ODStorageUnitID id);
	void	ReleasePersistentObject(in ODPersistentObject object);
	void	RemovePersistentObject(in ODPersistentObject object);
	
	void	CreateCollections();
	void	DeleteCollections();
	void	ExternalizeCollections();
	void	CloseCollections();
	void	OpenCollections();
	ODBoolean	AreEmptyCollections();
	
	void	FailIfNotExclusiveWrite();
	
	ODLink	CreateLink(in ODLinkSource linkSource);

	ODID	StrongClone(in ODDraftKey key, in ODID fromObjectID, in ODID toObjectID, in ODID scope);

	ODBoolean		ValidWeakReferenceProperty(in ODID objectID, in ODPropertyName propertyName);
	void			SetOriginalID(in ODStorageUnitID destID, in ODStorageUnitID originalID);
	ODStorageUnitID GetOriginalID(in ODStorageUnitID fromID);
	ODBoolean		CompanionWasCloned(in ODStorageUnitID fromID, in ODPropertyName prop);
	ODCloneKind		GetCloneKind();
	ODBoolean		CopiedLinkSubstitution(in ODDraftKey key, in ODID fromObjectID, in ODID toObjectID, out ODID toID);

// private by convention

	void 	SetChangedFromPrevFlag(in ODBoolean changed);

	IDList*	GetIDList();

	void Reinitialize(in ODDraftPermissions perms);
	void Open();
	void Close();
	void Abort();
	void Flush();
	
	ODBoolean	IsNewDraft();
	ODEmbeddedContainer	GetEmbeddedContainer();
	CMContainer	GetCMContainer();
	ODBoolean	NeedExternalizing();
	ODBoolean	IsChangedFromPrev(in VersionList* versionList);
	AEHashTable* GetClonedSUIDs(in ODDraft destDraft);

	ODBoolean		IsValidDraftKey(in ODDraftKey key);
	ODMemoryHeapID	GetHeap();
	
	ODLinkID				GetPersistentLinkID(in ODLink link);
	ODStorageUnitID			GetLinkID(in ODLinkID linkID);

#endif

#ifdef __SOMIDL__
  implementation
  {
  	functionprefix = CMDraft;

    override:
		somInit,
		somUninit,
        IncrementRefCount,
        Release,
		Purge,
        GetDocument,
        GetID,
        GetDraftProperties,
        GetPermissions,
        CreateStorageUnit,
        GetStorageUnit,
        RemoveStorageUnit,
        BeginClone,
        EndClone,
        AbortClone,
        Clone,
        WeakClone,
        ChangedFromPrev,
        SetChangedFromPrev,
        RemoveFromDocument,
        RemoveChanges,
        Externalize,
        SaveToAPrevious,
        CreateFrame,
        GetFrame,
        RemoveFrame,
        CreatePart,
        GetPart,
        RemovePart,
        CreateLinkSpec,
        CreateLinkSource,
        GetLinkSource,
        GetLink,
        RemoveLink,
        RemoveLinkSource,
        InitDraft,
        ReleaseFrame,
        ReleasePart,
        ReleaseLink,
        ReleaseLinkSource,
        ReleaseStorageUnit,
		CreateLinkIterator,
		CreateLinkSourceIterator;
		
	releaseorder:
		CreateSU,
		CreateVersion,
		OpenVersion,
		CloseVersion,
		DestroyVersion,
		FlushVersion,
		GetPersistentObject,
		ReleasePersistentObject,
		RemovePersistentObject,
		CreateCollections,
		DeleteCollections,
		ExternalizeCollections,
		CloseCollections,
		OpenCollections,
		AreEmptyCollections,
		FailIfNotExclusiveWrite,
		CreateLink,
		SetChangedFromPrevFlag,
		GetIDList,
		Reinitialize,
		Open,
		Close,
		Abort,
		Flush,
		IsNewDraft,
		GetEmbeddedContainer,
		GetCMContainer,
		NeedExternalizing,
		IsChangedFromPrev,
		GetClonedSUIDs,
		IsValidDraftKey,
		GetHeap,
		GetPersistentLinkID,
		GetLinkID,
		StrongClone,
		ValidWeakReferenceProperty,
		SetOriginalID,
		GetOriginalID,
		CompanionWasCloned,
		GetCloneKind,
		CopiedLinkSubstitution;

	#ifdef __PRIVATE__

		passthru C_xh =
			""
			"#include <CMAPI.h>"
			"class AEHashTable;"
			"class IDList;"
			"class VersionList;"
			"class LinkedList;"
			"#include <ODMemory.h>"
			"";

		CMDocument				fDocument;
		ODDraftID				fID;
		ODVersionID				fVersionID;
		ODVersionID				fPrevVersionID;
			
		ODDraftPermissions		fPermissions;
		ODEmbeddedContainer		fEmbeddedContainer;
		ODBoolean				fChangedFromPrev;
		ODBoolean				fIsNewDraft;
		ODBoolean				fExternalized;
	
		AEHashTable*			fPersistentObjects;
		AEHashTable*			fReleasedPersistentObjects;
		AEHashTable*			fStorageUnits;
		AEHashTable*			fReleasedStorageUnits;
		
		IDList*					fIDList;
		ODStorageUnit			fDraftProperties;
		
		AEHashTable*			fClonedSUIDs;
		AEHashTable*			fWeakClonedSUIDs;
		ODDraft					fDestDraft;
		ODDraftKey				fCurrentKey;
		ODULong					fLockCount;
		ODCloneKind				fCloneKind;
	
		ODMemoryHeapID			fHeap;
		
	#endif
  };
#endif
};

#endif  // _CMDRAFT_
