InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MResourceShell.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Michael Burbidge, Robin Briggs
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 #ifndef __MResourceShell_h__
25 #define __MResourceShell_h__
26 
27 #include "RsrcSpec.h"
28 #include "PMLocaleId.h"
29 #include "CResourceShell.h"
30 
31 #ifdef PUBLIC_BUILD
32 #endif
33 
37 {
38 public:
39 
40 #ifdef ID_DEPRECATED
41 
44  static void LockResourceHandle( SysHandle rsrcHandle);
45 
49  static void UnlockResourceHandle( SysHandle rsrcHandle);
50 #endif
51 
55  static void ReleaseResource(const SysHandle rsrcHandle);
56 
60  static void DetachResource(const SysHandle rsrcHandle);
61 
66  static int32 GetSizeofResource(const SysHandle rsrcHandle);
67 
73  static SysHandle GetResourceByID(RsrcType type, RsrcID id);
74 
80  static SysHandle GetResourceByIndex(RsrcType type, RsrcID index /*1-based*/);
81 
86  static int16 CountResources(RsrcType type);
87 private:
88 
89  MResourceShell(){} // don't make one please
90 };
91 
92 //========================================================================================
93 // INLINES MResourceShell
94 //========================================================================================
95 #define MTOOLBOX
96 #ifdef DEBUG
97  extern int64 ts_TotalNumResourceAccesses;
98 #endif
99 
102 inline void MResourceShell::LockResourceHandle(SysHandle /*rsrcHandle*/)
103 {
104  // This assert no longer means anything because HLOCK is a no-op
105  // ASSERT_MSG(!(::HGetState(rsrcHandle) & kHandleLockedMask),"Trying to lock already locked handle - could be bad");
106  //HLOCK(rsrcHandle);
107 }
108 
111 inline void MResourceShell::UnlockResourceHandle(SysHandle /*rsrcHandle*/)
112 {
113  // This assert no longer means anything because HUNLOCK is a no-op
114  //ASSERT_MSG((::HGetState(rsrcHandle) & kHandleLockedMask),"Trying to unlock handle which is not locked!");
115  //HUNLOCK(rsrcHandle);
116 }
117 
120 inline void MResourceShell::ReleaseResource(const SysHandle rsrcHandle)
121 {
122  MTOOLBOX::ReleaseResource(rsrcHandle);
123 }
124 
127 inline void MResourceShell::DetachResource(const SysHandle rsrcHandle)
128 {
129  MTOOLBOX::DetachResource(rsrcHandle);
130 }
131 
134 inline int32 MResourceShell::GetSizeofResource(const SysHandle rsrcHandle)
135 {
136  return MTOOLBOX::GetHandleSize(rsrcHandle);
137 }
138 
141 inline int16 MResourceShell::CountResources(RsrcType rsrcType)
142 {
143 #ifdef DEBUG
144  ts_TotalNumResourceAccesses++;
145 // ASSERT_MSG(IDThreading::IsMainThreadDomain(),"Making non-threadsafe call to mac resource manager from non-main thread");
146 #endif
147 
148  return MTOOLBOX::Count1Resources(rsrcType);
149 }
150 
153 inline SysHandle MResourceShell::GetResourceByID(RsrcType type, RsrcID id)
154 {
155 #ifdef DEBUG
156  ts_TotalNumResourceAccesses++;
157 // ASSERT_MSG(IDThreading::IsMainThreadDomain(),"Making non-threadsafe call to mac resource manager from non-main thread");
158 #endif
159  return MTOOLBOX::Get1Resource(type, id);
160 }
161 
164 inline SysHandle MResourceShell::GetResourceByIndex(RsrcType type, RsrcID index)
165 {
166 #ifdef DEBUG
167  ts_TotalNumResourceAccesses++;
168 // ASSERT_MSG(IDThreading::IsMainThreadDomain(),"Making non-threadsafe call to mac resource manager from non-main thread");
169 #endif
170  return MTOOLBOX::Get1IndResource(type, index);
171 }
172 
173 
174 #endif // __MResourceShell_h__