gwnavgeneration/containers/tlsarray.h Source File

tlsarray.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 #pragma once
9 
15 
16 
17 namespace Kaim
18 {
19 
20 // ArrayTLS is a ArrayDH that always uses GeneratorMemory::TlsHeap()
21 // This avoid to pass GeneratorMemory::TlsHeap() to ArrayDH constructors
22 template<class T>
23 class KyArrayTLS : public KyArrayDH<T, MemStat_NavDataGen>
24 {
25 public:
26  typedef T ValueType;
27  typedef KyArrayTLS SelfType;
28  typedef KyArrayDH<T, MemStat_NavDataGen> BaseType;
29 
30  KyArrayTLS() : BaseType(GeneratorMemory::TlsHeap()) {}
31  explicit KyArrayTLS(int size) : BaseType(GeneratorMemory::TlsHeap(), size) {}
32  KyArrayTLS(const SelfType& a) : BaseType(a) {}
33  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
34 
35  KyUInt32 GetCount() const { return (KyUInt32)BaseType::GetSize(); }
36  bool DoesContain(const ValueType& value) const { return ArrayAlg::DoesContain<SelfType,ValueType>(*this, value); }
37  void RemoveConsecutiveDuplicates() { return ArrayAlg::RemoveConsecutiveDuplicates<SelfType>(*this); }
38 };
39 
40 
41 // ArrayTLS_POD is a ArrayDH_POD that always uses GeneratorMemory::TlsHeap()
42 // This avoid to pass GeneratorMemory::TlsHeap() to ArrayDH_POD constructors
43 template<class T>
44 class KyArrayTLS_POD : public ArrayDH_POD<T, MemStat_NavDataGen>
45 {
46 public:
47  typedef T ValueType;
48  typedef KyArrayTLS_POD SelfType;
49  typedef ArrayDH_POD<T, MemStat_NavDataGen> BaseType;
50 
51  KyArrayTLS_POD() : BaseType(GeneratorMemory::TlsHeap()) {}
52  explicit KyArrayTLS_POD(int size) : BaseType(GeneratorMemory::TlsHeap(), size) {}
53  KyArrayTLS_POD(const SelfType& a) : BaseType(a) {}
54  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
55 
56  KyUInt32 GetCount() const { return (KyUInt32)BaseType::GetSize(); }
57  bool DoesContain(const ValueType& value) const { return ArrayAlg::DoesContain<SelfType,ValueType>(*this, value); }
58  void RemoveConsecutiveDuplicates() { return ArrayAlg::RemoveConsecutiveDuplicates<SelfType>(*this); }
59 };
60 
61 // ArrayTLS_POD is a ArrayDH_POD that always uses GeneratorMemory::TlsHeap()
62 // This avoid to pass GeneratorMemory::TlsHeap() to ArrayDH_POD constructors
63 template<class T>
64 class KyArrayTLS_CPP : public ArrayDH_CPP<T, MemStat_NavDataGen>
65 {
66 public:
67  typedef T ValueType;
68  typedef KyArrayTLS_CPP SelfType;
69  typedef ArrayDH_CPP<T, MemStat_NavDataGen> BaseType;
70 
71  KyArrayTLS_CPP() : BaseType(GeneratorMemory::TlsHeap()) {}
72  explicit KyArrayTLS_CPP(int size) : BaseType(GeneratorMemory::TlsHeap(), size) {}
73  KyArrayTLS_CPP(const SelfType& a) : BaseType(a) {}
74  const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; }
75 
76  KyUInt32 GetCount() const { return (KyUInt32)BaseType::GetSize(); }
77  bool DoesContain(const ValueType& value) const { return ArrayAlg::DoesContain<SelfType,ValueType>(*this, value); }
78  void RemoveConsecutiveDuplicates() { return ArrayAlg::RemoveConsecutiveDuplicates<SelfType>(*this); }
79 };
80 
81 class BitFieldTLS : public BitFieldBase
82 {
83  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
84 public:
85  explicit BitFieldTLS() : BitFieldBase() {}
86  explicit BitFieldTLS(KyUInt32 bitsCount) : BitFieldBase() { Resize(bitsCount); }
87  void Resize(KyUInt32 newBitsCount) { Resize_(newBitsCount, MemStat_NavDataGen, GeneratorMemory::TlsHeap()); }
88  void Reserve(KyUInt32 newBitsCount) { Reserve_(newBitsCount, MemStat_NavDataGen, GeneratorMemory::TlsHeap()); }
89 };
90 
91 template <class T, typename Comparator = DefaultLess<T>, typename BinaryHeapIndexTracker = BinaryHeapIndexTracker_None<T> >
92 class BinaryHeapTls : public BinaryHeap<T, KyArrayTLS<T>, Comparator, BinaryHeapIndexTracker>
93 {
94 };
95 
96 template <class T, typename Comparator = DefaultLess<T>, typename BinaryHeapIndexTracker = BinaryHeapIndexTracker_None<T> >
97 class BinaryHeapTLS_CPP : public BinaryHeap<T, KyArrayTLS_CPP<T>, Comparator, BinaryHeapIndexTracker>
98 {
99 };
100 
101 
102 } // namespace Kaim
103 
104 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17