CFx SDK Documentation
2024 SP0
Loading...
Searching...
No Matches
SDK
CFx
dd_inc
Gi
GiTraitsCache.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 _ODGITRAITSCACHE_INCLUDED_
25
#define _ODGITRAITSCACHE_INCLUDED_
26
27
#include "
GiCommonDraw.h
"
28
29
#define STL_USING_MAP
30
#include "
OdaSTL.h
"
31
32
class
OdDbStub;
33
34
#include "
TD_PackPush.h
"
35
43
template
<
class
traitsContainer,
class
traitsTaker, OdUInt32 byMask = 0>
44
class
OdGiTraitsCache
:
public
traitsTaker
45
{
46
public
:
50
enum
CacheType
51
{
53
kCacheNone
= 0,
55
kCacheByMask
= 1,
57
kCacheAll
= 2
58
};
59
protected
:
60
struct
CacheEntry
61
{
62
traitsContainer
m_data
;
63
OdUInt32
m_flags
;
64
void
set
(
const
traitsContainer&
data
,
OdUInt32
flags) {
m_data
=
data
;
m_flags
= flags; }
65
};
66
67
protected
:
68
CacheType
m_cacheType
;
69
typedef
std::map<OdDbStub*, CacheEntry>
_mmap
;
70
_mmap
m_cacheData
;
71
OdUInt32
m_traitsAttrib
;
72
public
:
77
OdGiTraitsCache
()
78
: traitsTaker()
79
,
m_cacheType
(
kCacheNone
)
80
,
m_traitsAttrib
(0)
81
{
82
}
87
explicit
OdGiTraitsCache
(
CacheType
cacheType
)
88
: traitsTaker()
89
,
m_cacheType
(
cacheType
)
90
,
m_traitsAttrib
(0)
91
{
92
}
96
~OdGiTraitsCache
()
97
{
98
}
99
105
void
setCacheType
(
CacheType
cacheType
)
106
{
107
m_cacheType
=
cacheType
;
108
}
109
113
CacheType
cacheType
()
const
114
{
115
return
m_cacheType
;
116
}
117
124
void
setAttributes
(OdDbStub* objId,
OdGiContext
&giCtx,
bool
forceCaching =
false
)
125
{
126
if
(
m_cacheType
!=
kCacheNone
&&
m_cacheData
.size() > 0)
127
{
128
// Note: iterator won't compile in this context on all platforms.
129
typename
_mmap::iterator it =
m_cacheData
.find(objId);
130
if
(it !=
m_cacheData
.end())
131
{
132
m_traitsAttrib
= it->second.m_flags;
133
if
(!(
m_traitsAttrib
& byMask))
134
traitsTaker::setData(it->second.m_data);
135
return
;
136
}
137
}
138
OdGiDrawablePtr
drawable = giCtx.
openDrawable
(objId);
139
if
(!drawable.
isNull
())
140
{
141
m_traitsAttrib
= drawable->
setAttributes
(
this
);
142
if
(
m_cacheType
!=
kCacheNone
)
143
{
144
if
(
m_cacheType
==
kCacheAll
|| forceCaching || ((
m_traitsAttrib
& byMask) != 0))
145
{
146
m_cacheData
[objId].set(this->getData(),
m_traitsAttrib
);
147
}
148
}
149
}
150
}
151
156
void
setFlags
(
OdUInt32
uAttrib)
157
{
158
m_traitsAttrib
= uAttrib;
159
}
160
164
OdUInt32
getFlags
()
const
165
{
166
return
m_traitsAttrib
;
167
}
168
172
void
clear
()
173
{
174
m_cacheData
.clear();
175
}
176
};
177
178
// traitsContainer - must have operator =.
179
// traitsTaker - must have setData(traitsContainer), getData() methods.
180
181
#include "
TD_PackPop.h
"
182
183
#endif
// #ifndef _ODGITRAITSCACHE_INCLUDED_
GiCommonDraw.h
OdUInt32
unsigned int OdUInt32
Definition:
OdPlatformSettings.h:814
OdaSTL.h
TD_PackPop.h
TD_PackPush.h
OdBaseObjectPtr::isNull
bool isNull() const
Definition:
BaseObjectPtr.h:86
OdGiContext
Definition:
GiCommonDraw.h:113
OdGiContext::openDrawable
virtual OdGiDrawablePtr openDrawable(OdDbStub *drawableId)=0
OdGiDrawable::setAttributes
ODRX_SEALED_VIRTUAL OdUInt32 setAttributes(OdGiDrawableTraits *pTraits) const ODRX_SEALED
OdGiTraitsCache
Definition:
GiTraitsCache.h:45
OdGiTraitsCache::OdGiTraitsCache
OdGiTraitsCache()
Definition:
GiTraitsCache.h:77
OdGiTraitsCache::~OdGiTraitsCache
~OdGiTraitsCache()
Definition:
GiTraitsCache.h:96
OdGiTraitsCache::m_traitsAttrib
OdUInt32 m_traitsAttrib
Definition:
GiTraitsCache.h:71
OdGiTraitsCache::OdGiTraitsCache
OdGiTraitsCache(CacheType cacheType)
Definition:
GiTraitsCache.h:87
OdGiTraitsCache::CacheType
CacheType
Definition:
GiTraitsCache.h:51
OdGiTraitsCache::kCacheByMask
@ kCacheByMask
Definition:
GiTraitsCache.h:55
OdGiTraitsCache::kCacheNone
@ kCacheNone
Definition:
GiTraitsCache.h:53
OdGiTraitsCache::kCacheAll
@ kCacheAll
Definition:
GiTraitsCache.h:57
OdGiTraitsCache::m_cacheType
CacheType m_cacheType
Definition:
GiTraitsCache.h:68
OdGiTraitsCache::_mmap
std::map< OdDbStub *, CacheEntry > _mmap
Definition:
GiTraitsCache.h:69
OdGiTraitsCache::m_cacheData
_mmap m_cacheData
Definition:
GiTraitsCache.h:70
OdGiTraitsCache::setFlags
void setFlags(OdUInt32 uAttrib)
Definition:
GiTraitsCache.h:156
OdGiTraitsCache::cacheType
CacheType cacheType() const
Definition:
GiTraitsCache.h:113
OdGiTraitsCache::setCacheType
void setCacheType(CacheType cacheType)
Definition:
GiTraitsCache.h:105
OdGiTraitsCache::clear
void clear()
Definition:
GiTraitsCache.h:172
OdGiTraitsCache::setAttributes
void setAttributes(OdDbStub *objId, OdGiContext &giCtx, bool forceCaching=false)
Definition:
GiTraitsCache.h:124
OdGiTraitsCache::getFlags
OdUInt32 getFlags() const
Definition:
GiTraitsCache.h:164
OdSmartPtr< OdGiDrawable >
data
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition:
gles2_ext.h:110
OdGiTraitsCache::CacheEntry
Definition:
GiTraitsCache.h:61
OdGiTraitsCache::CacheEntry::m_flags
OdUInt32 m_flags
Definition:
GiTraitsCache.h:63
OdGiTraitsCache::CacheEntry::m_data
traitsContainer m_data
Definition:
GiTraitsCache.h:62
OdGiTraitsCache::CacheEntry::set
void set(const traitsContainer &data, OdUInt32 flags)
Definition:
GiTraitsCache.h:64
Generated on Wed Apr 5 2023 17:29:18