InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DBUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Roey Horns
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Purpose:
24 // Utility class
25 //
26 //========================================================================================
27 
28 #ifndef __DBUTILS_
29 #define __DBUTILS_
30 
31 #include "IDataBase.h"
32 #include "OMFactoryCtor.h"
33 
34 
35 class IRIDXDBInterface;
36 class IInvalHandler;
37 
43 class DATABASE_DECL DBUtils
44 {
45 public:
46 
47 
48  enum {
50  kMagicByteCount = 8
51  };
52 
54  typedef char MagicBytes[kMagicByteCount];
61  static IDataBase *CreateDataBase(IDataBase::UndoSupport undoSupport, bool hasContentMgr = true);
62 
63  static IDataBase* CreateCloudDataBase(IDataBase::UndoSupport undoSupport, bool hasContentMgr = true,const std::string & assetRef = "");
64 
65  // Create a clone from a database snapshot(for internal use only)
66  static IDataBase* CreateCloneFromDatabaseSnapshot(DatabaseSnapshotPtr dbSnapshot, IDataBase::UndoSupport undosupport = IDataBase::kPartialUndoSupport) ;
67 
83  static void SetMagicBytes(const MagicBytes bytes);
84 
97  static uint32 GetAvailableNewDatabases ();
98 
105  static bool16 IsValidDataBase (IDataBase *db);
106 
107 
108  // Inval handler management fuctions.
109 
128  static bool16 AttachInvalHandler(IDataBase* db, IInvalHandler*, InvalHandlerID id);
129 
137  static void DetachInvalHandler(IDataBase* db, IInvalHandler* );
138 
145  static IInvalHandler* GetInvalHandler(const IDataBase* db, InvalHandlerID id); // For purges. When interfaces come back to life after a purge,
146  // they can enquire if the were already registerred with the sequence.
147 
161  static bool16 StartCollectingInvals (IDataBase* db, IInvalHandler* handler);
162 
163  // Lazy notification functions
164 
175  static void DiscardLazyNotificationSubject(IDataBase* db, const UIDRef& subject);
176 
178  typedef void (*CUIDFilterFunction) (void *buffer, uint32 size, uint16 type);
179 
181  static void SetCUIDImportFilter (CUIDFilterFunction functor);
183  static void SetCUIDExportFilter (CUIDFilterFunction functor);
185  static CUIDFilterFunction GetCUIDImportFilter ();
187  static CUIDFilterFunction GetCUIDExportFilter ();
188 
189  // Set the constructor function. Returns the old one.
191  static BossConstructor SetObjectConstructor(BossConstructor newConstructor);
192 
195  static void GetUIDPersistedInterfaces(IDataBase *db, UID id, ClassID clsID, IPMPersist* obj, std::vector<ImplementationID>& implList);
196 
197  // Call this to tell the database what to stamp new files with, and
198  // what files can legally be opened.
200  static void SetBuildVersion(int32 majorVersionNumber, int32 minorVersionNumber);
201  // Call this to find out if the file is a valid database file.
202  // Currently this always returns true for unclear historical reasons, which makes it less than useful. [][]
204  static bool16 IsValidDataBase(const IDFile *fileToCheck);
205  // Defines where to put mini save files.
206  // Copies the value of newPath.
207  // A call with newPath = nil deletes the path (this is necessary to avoid a memory leak)
209  static void SetRecoveryPath(const IDFile* newPath);
211  static const IDFile *GetRecoveryPath();
212  // EnableInstanceCaches enables/disables all caches and returns kTrue
213  // if the caches were enabled before
215  static bool16 EnableInstanceCaches(bool16 enable);
217  static void AddClass(IDataBase *db, ClassID newCls, UID uid);
218  // Tell the PlugInContentMgr that a new class has been added to the document.
220  static void ProcessDeferredContent(IDataBase *db);
221 
223  static IDataBase::CachePolicy GetNewDataBaseCachePolicy();
225  static void SetNewDataBaseCachePolicy(IDataBase::CachePolicy);
226 
227  // Reference Index
229  static IRIDXDBInterface *GetRIDXDBInterface ();
231  static void SetRIDXDBInterface (IRIDXDBInterface *i);
233  static void EnableRIDXDBInterface ();
234 
235 #ifdef DEBUG
236  // limits UID to a number smaller than 0xFFFFFFFF
237  // and returns the current limit
239  static UID SetMaxUID(UID newMaxUID);
240  // returns the current limit for UIDs
242  static UID GetMaxUID();
243 
245  static void SetAssertOnInstantiateFail(bool16 showAsserts);
247  static bool16 ShowInstantiateAsserts();
248 
249 #endif
250 
251  //internal use only
252  static void ShutdownSUIDS();
253  static void PreShutdownSUIDS();
254  static void InitializeSUIDS();
255  static uint32 GetTotalCurrentNetworkCacheSize();
256 };
257 
258 
259 #endif //__DBUTILS_