CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsEmptyMetafileCache.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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
33class 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:
54
55 static void get(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode = NULL);
56 protected:
57 void getLocal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode &pLayerNode);
58 static void getGlobal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode);
59 static void getImpl(OdGsEntityNode::MetafilePtr &pPtr, OdMmap &mfMap, OdUInt32 flags, OdGsLayerNode *pLayerNode);
60};
61
62#define ODGS_EMFCACHE_DEFINE_MEMBERS() \
63 GS_STATIC_EXPORT OdGsEmptyMetafileCache::OdMmap* OdGsEmptyMetafileCache::s_mfMap = NULL; \
64 GS_STATIC_EXPORT OdMutex* OdGsEmptyMetafileCache::s_mtMfMap = NULL; \
65 void OdGsEmptyMetafileCache::rxInit() \
66 { \
67 s_mfMap = new OdMmap(); \
68 s_mtMfMap = new OdMutex(); \
69 } \
70 void OdGsEmptyMetafileCache::rxUninit() \
71 { \
72 delete s_mfMap; s_mfMap = NULL; \
73 delete s_mtMfMap; s_mtMfMap = NULL; \
74 }
75
76#include "TD_PackPop.h"
77
78#endif // __OD_GS_EMPTY_METAFILE_CACHE__
79
80// Inlines
81
82#if defined(__OD_GS_EMPTY_METAFILE_CACHE__) && (defined(__OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__) || !defined(__OD_GS_LAYER_NODE__))
83
84#ifndef __OD_GS_EMPTY_METAFILE_CACHE_INLINES__
85#define __OD_GS_EMPTY_METAFILE_CACHE_INLINES__
86
87#include "Gs/GsLayerNode.h"
88
89inline
91{
92}
93
94inline
96{
97 if (pLayerNode)
98 pLayerNode->m_emfCache.getLocal(pPtr, flags, *pLayerNode);
99 else
100 getGlobal(pPtr, flags, pLayerNode);
101}
102
103inline
105{
106 TD_AUTOLOCK_P_DEF(pLayerNode.m_mt);
107 getImpl(pPtr, m_mfMap, flags, &pLayerNode);
108}
109
110inline
112{
113 OdMutexPtrAutoLock autoLock(odThreadsCounter() ? s_mtMfMap : NULL);
114 getImpl(pPtr, *s_mfMap, flags, pLayerNode);
115}
116
117inline
119{
120 OdMmap::iterator it = mfMap.find(flags);
121 if (it != mfMap.end())
122 {
123 pPtr = it->second;
124 return;
125 }
127 pPtr->m_nAwareFlags = flags;
128 pPtr->m_first.m_pLayer = pLayerNode;
129 mfMap[flags] = pPtr;
130}
131
132#endif // __OD_GS_EMPTY_METAFILE_CACHE_INLINES__
133
134#endif // defined(__OD_GS_EMPTY_METAFILE_CACHE__) && (defined(__OD_GS_EMPTY_METAFILE_CACHE_INLINES_INCLUDE__) || !defined(__OD_GS_LAYER_NODE__))
#define GS_STATIC_EXPORT
Definition: GsExport.h:38
unsigned int OdUInt32
#define TD_AUTOLOCK_P_DEF(Mutex)
FIRSTDLL_EXPORT ThreadsCounter & odThreadsCounter()
static OdSmartPtr< TInterface > createObject()
static void get(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode=NULL)
static void getImpl(OdGsEntityNode::MetafilePtr &pPtr, OdMmap &mfMap, OdUInt32 flags, OdGsLayerNode *pLayerNode)
static void getGlobal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode *pLayerNode)
void getLocal(OdGsEntityNode::MetafilePtr &pPtr, OdUInt32 flags, OdGsLayerNode &pLayerNode)