CFx SDK Documentation
2026 SP0
Loading...
Searching...
No Matches
SDK
CFx
dd_inc
Tr
TrVisIdGenerator.h
Go to the documentation of this file.
1
2
// Copyright (C) 2002-2024, 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-2024 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
// GLES2 static resource ID generator
24
25
#ifndef ODTRVISIDGENERATOR
26
#define ODTRVISIDGENERATOR
27
28
#include "
TD_PackPush.h
"
29
30
#include "
TrVisDefs.h
"
31
#define STL_USING_SET
32
#include "
OdaSTL.h
"
33
37
template
<
class
T>
38
class
OdTrVisIdGeneratorImpl
39
{
40
typedef
std::set<T> IdMap;
41
mutable
IdMap m_idMap;
42
mutable
T m_idMapCounter, m_idMapSearchEx;
43
protected
:
44
T
inc
(T &counter, T &searchEx)
const
45
{
46
const
T NegativeId = (T)(-1);
47
if
(counter == NegativeId)
48
{
49
T
id
= searchEx;
50
do
51
{
52
if
(!
findId
(
id
))
53
return
searchEx = id;
54
id
++;
55
}
while
(
id
< NegativeId);
56
id
= 100;
57
while
(
id
< searchEx)
58
{
59
if
(!
findId
(
id
))
60
return
searchEx = id;
61
id
++;
62
}
63
counter = 100;
64
}
65
return
counter++;
66
}
67
public
:
68
OdTrVisIdGeneratorImpl
()
69
{
70
clean
();
71
}
72
73
void
clean
()
74
{
75
m_idMap.clear();
76
m_idMapCounter = m_idMapSearchEx = 100;
77
}
78
79
T
generateId
()
const
80
{
81
const
T freeId =
inc
(m_idMapCounter, m_idMapSearchEx);
82
m_idMap.insert(freeId);
83
return
freeId;
84
}
85
86
void
killId
(T
id
)
const
87
{
88
m_idMap.erase(
id
);
89
}
90
91
bool
findId
(T
id
)
const
92
{
93
return
m_idMap.find(
id
) != m_idMap.end();
94
}
95
};
96
100
typedef
OdTrVisIdGeneratorImpl<OdTrVisId>
OdTrVisGenericIdGenerator
;
101
102
#include "
TD_PackPop.h
"
103
104
#endif
// ODTRVISIDGENERATOR
OdaSTL.h
TD_PackPop.h
TD_PackPush.h
TrVisDefs.h
OdTrVisGenericIdGenerator
OdTrVisIdGeneratorImpl< OdTrVisId > OdTrVisGenericIdGenerator
Definition
TrVisIdGenerator.h:100
OdTrVisIdGeneratorImpl
Definition
TrVisIdGenerator.h:39
OdTrVisIdGeneratorImpl::OdTrVisIdGeneratorImpl
OdTrVisIdGeneratorImpl()
Definition
TrVisIdGenerator.h:68
OdTrVisIdGeneratorImpl::inc
T inc(T &counter, T &searchEx) const
Definition
TrVisIdGenerator.h:44
OdTrVisIdGeneratorImpl::findId
bool findId(T id) const
Definition
TrVisIdGenerator.h:91
OdTrVisIdGeneratorImpl::clean
void clean()
Definition
TrVisIdGenerator.h:73
OdTrVisIdGeneratorImpl::generateId
T generateId() const
Definition
TrVisIdGenerator.h:79
OdTrVisIdGeneratorImpl::killId
void killId(T id) const
Definition
TrVisIdGenerator.h:86
Generated on Tue Apr 15 2025 11:30:07