InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WBaseResourceAccess.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Lonnie Millett
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 __WBASERESOURCEACCESS__
25 #define __WBASERESOURCEACCESS__
26 
27 
28 #include "IResourceAccess.h"
29 #include "IDFile.h"
30 #include <boost/thread/recursive_mutex.hpp>
31 
32 class IControlView;
33 
34 
44 {
45 public:
48  {
49  public:
51  bool16 fNoOp;
53  bool16 fDefaultAccess;
55  int16 fOpenCount;
60  };
61 
75  WBaseResourceAccess(const PMString& pluginName, ResourceFileInfo*);
80 
82  virtual ~WBaseResourceAccess();
83 
85  virtual const IDFile *GetResourceFile();
86 
89  ResourceFileInfo *GetResourceFileInfo() { return(fResourceFileInfo); }
90 
93  HRSRC GetResourceHandle() const;
94 
95 private:
96  void OpenResourceFile();
97  void CloseResourceFile();
98 
99  ResourceFileInfo *fResourceFileInfo;
100  ResourceFileInfo *fPluginResourceFileInfo;
101  HRSRC fPreviousResourceHandle;
102 
103  // Lock to block multiple threads to access resources in the same time
104  // This is not really needed on Windows - we should remove this when we will get rid of the shared handle
105  // and make resources accessible only from ResourceEnablers
106  class ResourceLock : private boost::noncopyable
107  {
108  public:
109  ResourceLock(boost::recursive_mutex& mutex, int32& lockCounter);
110  ~ResourceLock();
111  private:
112  boost::recursive_mutex::scoped_lock fLock;
113  int32& fCounter;
114  };
115 
116  ResourceLock fResourceLock; // needed because of the shared global resource handler
117 };
118 
119 
120 #endif