CFx SDK Documentation  2020SP3
GsEmptyMetafileCache.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef __OD_GS_EMPTY_METAFILE_CACHE__
25 #define __OD_GS_EMPTY_METAFILE_CACHE__
26 
27 #include "TD_PackPush.h"
28 
29 #include "Gs/GsEntityNode.h"
30 #define STL_USING_MAP
31 #include "OdaSTL.h"
32 
33 class OdGsLayerNode;
34 
38 {
39  private:
40  typedef std::map<OdUInt32, OdGsEntityNode::MetafilePtr> OdMmap;
41  // Global map
42  friend class OdGsModuleObject;
43  GS_STATIC_EXPORT static OdMmap * s_mfMap;
44  GS_STATIC_EXPORT static OdMutex* s_mtMfMap;
45  static void rxInit();
46  static void rxUninit();
47  // Local map
48  OdMmap m_mfMap;
49  public:
51 
52  static void get(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode = NULL);
53  protected:
54  void getLocal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode &pLayerNode);
55  static void getGlobal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode);
56  static void getImpl(OdGsEntityNode::MetafilePtr &pPtr, OdMmap &mfMap, OdUInt32 flags, OdGsLayerNode *pLayerNode);
57 };
58 
59 #define ODGS_EMFCACHE_DEFINE_MEMBERS() \
60  GS_STATIC_EXPORT OdGsEmptyMetafileCache::OdMmap* OdGsEmptyMetafileCache::s_mfMap = NULL; \
61  GS_STATIC_EXPORT OdMutex* OdGsEmptyMetafileCache::s_mtMfMap = NULL; \
62  void OdGsEmptyMetafileCache::rxInit() \
63  { \
64  s_mfMap = new OdMmap(); \
65  s_mtMfMap = new OdMutex(); \
66  } \
67  void OdGsEmptyMetafileCache::rxUninit() \
68  { \
69  delete s_mfMap; s_mfMap = NULL; \
70  delete s_mtMfMap; s_mtMfMap = NULL; \
71  }
72 
73 #include "TD_PackPop.h"
74 
75 #endif // __OD_GS_EMPTY_METAFILE_CACHE__
76 
77 // Inlines
78 
79 #if defined(__OD_GS_EMPTY_METAFILE_CACHE__) && (defined(__OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__) || !defined(__OD_GS_LAYER_NODE__))
80 
81 #ifndef __OD_GS_EMPTY_METAFILE_CACHE_INLINES__
82 #define __OD_GS_EMPTY_METAFILE_CACHE_INLINES__
83 
84 #include "Gs/GsLayerNode.h"
85 
86 inline
88 {
89 }
90 
91 inline
93 {
94  if (pLayerNode)
95  pLayerNode->m_emfCache.getLocal(pPtr, flags, *pLayerNode);
96  else
97  getGlobal(pPtr, flags, pLayerNode);
98 }
99 
100 inline
102 {
103  TD_AUTOLOCK_P_DEF(pLayerNode.m_mt);
104  getImpl(pPtr, m_mfMap, flags, &pLayerNode);
105 }
106 
107 inline
109 {
110  OdMutexPtrAutoLock autoLock(odThreadsCounter() ? s_mtMfMap : NULL);
111  getImpl(pPtr, *s_mfMap, flags, pLayerNode);
112 }
113 
114 inline
116 {
117  OdMmap::iterator it = mfMap.find(flags);
118  if (it != mfMap.end())
119  {
120  pPtr = it->second;
121  return;
122  }
124  pPtr->m_nAwareFlags = flags;
125  pPtr->m_first.m_pLayer = pLayerNode;
126  mfMap[flags] = pPtr;
127 }
128 
129 #endif // __OD_GS_EMPTY_METAFILE_CACHE_INLINES__
130 
131 #endif // defined(__OD_GS_EMPTY_METAFILE_CACHE__) && (defined(__OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__) || !defined(__OD_GS_LAYER_NODE__))
NULL
#define NULL
Definition: GsProperties.h:177
OdMutexPtrAutoLock
Definition: ThreadsCounter.h:65
OdGsEmptyMetafileCache
Definition: GsEmptyMetafileCache.h:38
OdGsEmptyMetafileCache::getImpl
static void getImpl(OdGsEntityNode::MetafilePtr &pPtr, OdMmap &mfMap, OdUInt32 flags, OdGsLayerNode *pLayerNode)
Definition: GsEmptyMetafileCache.h:115
GsLayerNode.h
OdaSTL.h
OdGsLayerNode
Definition: GsLayerNode.h:41
TD_PackPop.h
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGsEmptyMetafileCache::getGlobal
static void getGlobal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode)
Definition: GsEmptyMetafileCache.h:108
OdGsEmptyMetafileCache::get
static void get(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode=NULL)
Definition: GsEmptyMetafileCache.h:92
GsEntityNode.h
OdSmartPtr
Definition: SmartPtr.h:58
TD_AUTOLOCK_P_DEF
#define TD_AUTOLOCK_P_DEF(Mutex)
Definition: ThreadsCounter.h:281
OdGsEmptyMetafileCache::OdGsModuleObject
friend class OdGsModuleObject
Definition: GsEmptyMetafileCache.h:42
TD_PackPush.h
OdGiRxObjectReImpl::createObject
static OdSmartPtr< TInterface > createObject()
Definition: ChunkAllocator.h:172
OdGsEmptyMetafileCache::getLocal
void getLocal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode &pLayerNode)
Definition: GsEmptyMetafileCache.h:101
GS_STATIC_EXPORT
#define GS_STATIC_EXPORT
Definition: GsExport.h:38
odThreadsCounter
FIRSTDLL_EXPORT ThreadsCounter & odThreadsCounter()
OdGsEmptyMetafileCache::OdGsEmptyMetafileCache
OdGsEmptyMetafileCache()
Definition: GsEmptyMetafileCache.h:87
OdMutex
Definition: OdMutex.h:50