InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IMemoryManager.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: ?
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 
24 #include "PMTypes.h"
25 #include "IPMUnknown.h"
26 
27 #ifndef __IMemoryManager__
28 #define __IMemoryManager__
29 
33 typedef void (*MemoryNotificationFunction)(int32 level, void *refPtr);
34 
45 typedef void (*NewMemoryNotificationFunction)(int32 level, void *refPtr, bool16 bInGrowZone);
46 
49 typedef void (*AdviseMemoryStateNotificationFunction)(int32 state, void *refPtr);
50 
54 class IMemoryManager : public IPMUnknown
55 {
56  public:
57  enum { kDefaultIID = IID_IMEMORYMANAGER };
58 
59  virtual void Init() = 0;
60 
63  typedef enum
64  {
66  kNoPurge = -1,
68  kSwitchingDocuments = 0, // release document oriented caches
70  kSwitchingApplications = 1, // release temporary memory
78  kReleaseEverything = 5, // release all you can
82  } PurgeLevel;
83 
85  typedef enum
86  {
88  kNormalMemoryState = 0, // Normal state, there is plenty of memory
90  kConstrainedMemoryState = 1, // Heap is relatively full, around 10-20% free (a good time to fix sizes of caches)
92  kLowMemoryState = 2 // Heap is very full, less than 5% free (a good time to reduce memory footprint)
93  } MemoryState;
94 
99  virtual void PurgeObjects(PurgeLevel purgeLevel) = 0;
100 
104  virtual void CheckMemoryState() = 0;
105 
113  virtual bool16 MemoryPanic() = 0;
114 
117  virtual bool16 CheckMemory(bool16 showAlerts = kFalse) = 0;
118 
121  virtual bool16 MemoryIsLow() = 0;
122 
125  virtual bool16 MemoryIsFailing() = 0;
126 
127 
129 
130  // NOTE that the two versions of these functions are named differently (as opposed to overloaded)
131  // *Don't* overload them, or code which calls these functions then fails to compile
132  // as the compiler cannot disambiguate the caller's first parameter which could either be
133  // a pointer to a virtual function or a static function in the caller's class
134 
139  virtual void RegisterMemoryNotification(MemoryNotificationFunction func, void *refPtr) = 0;
140 
145  virtual void RegisterNewMemoryNotification(NewMemoryNotificationFunction func, void *refPtr, bool16 bGrowZoneFailSafe) = 0;
146 
151  virtual void UnregisterMemoryNotification(MemoryNotificationFunction func, void *refPtr) = 0;
152 
157  virtual void UnregisterNewMemoryNotification(NewMemoryNotificationFunction func, void *refPtr) = 0;
159 
164  virtual void RegisterAdviseMemoryStateNotification(AdviseMemoryStateNotificationFunction func, void *refPtr) = 0;
165 
170  virtual void UnregisterAdviseMemoryStateNotification(AdviseMemoryStateNotificationFunction func, void *refPtr) = 0;
171 
174  virtual uint32 GetPurgeCount() const = 0;
175 
178  virtual uint32 GetPurgeTime() const = 0;
179 
181 
186  virtual bool16 PurgeInProgress() const = 0;
187 
193  virtual bool16 HandleAllocationFailure(size_t blockSize) = 0;
194 
198  virtual void ResetFailureHandler() = 0;
199 };
200 
201 
202 #endif // __IMemoryManager__