CellParentTreeStrategy.h
Go to the documentation of this file.
1#ifndef GfxTL__CELLPARENTTREESTRATEGY_HEADER__
2#define GfxTL__CELLPARENTTREESTRATEGY_HEADER__
3
4namespace GfxTL
5{
6
7 template <class InheritedStrategyT>
9 {
10 typedef typename InheritedStrategyT::value_type value_type;
11
12 template <class BaseT>
13 class StrategyBase;
14
15 class CellData : public InheritedStrategyT::CellData
16 {
17 public:
18 template <class BaseT>
19 friend class StrategyBase;
20 typedef typename InheritedStrategyT::CellData BaseType;
21
22 private:
23 CellData* m_parent;
24 };
25
26 template <class BaseT>
27 class StrategyBase : public InheritedStrategyT::template StrategyBase<BaseT>
28 {
29 public:
30 typedef typename InheritedStrategyT::template StrategyBase<BaseT> BaseType;
31 typedef typename BaseType::CellType CellType;
32
33 const CellType* const
34 CellParent(const CellType& c) const
35 {
36 return (const CellType* const)c.m_parent;
37 }
38
39 CellType* const
41 {
42 return (CellType*)c.m_parent;
43 }
44
45 protected:
46 class BuildInformation : public BaseType::BuildInformation
47 {
48 public:
50 Parent() const
51 {
52 return m_parent;
53 }
54
55 void
57 {
58 m_parent = p;
59 }
60
61 private:
62 CellType* m_parent;
63 };
64
65 template <class BuildInformationT>
66 void
67 InitRootBuildInformation(BuildInformationT* bi)
68 {
69 BaseType::InitRootBuildInformation(bi);
70 bi->Parent(NULL);
71 }
72
73 template <class BuildInformationT>
74 void
76 const BuildInformationT& parentInfo,
77 unsigned int childIdx,
78 BuildInformationT* bi)
79 {
80 BaseType::InitBuildInformation(parent, parentInfo, childIdx, bi);
81 bi->Parent(const_cast<CellType*>(&parent));
82 }
83
84 template <class BuildInformationT>
85 void
86 InitCell(const CellType& parent,
87 const BuildInformationT& parentInfo,
88 unsigned int childIdx,
89 const BuildInformationT& bi,
90 CellType* cell)
91 {
92 BaseType::InitCell(parent, parentInfo, childIdx, bi, cell);
93 cell->m_parent = bi.Parent();
94 }
95 };
96 };
97
98}; // namespace GfxTL
99
100#endif
constexpr T c
void InitBuildInformation(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, BuildInformationT *bi)
InheritedStrategyT::template StrategyBase< BaseT > BaseType
const CellType *const CellParent(const CellType &c) const
void InitCell(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, const BuildInformationT &bi, CellType *cell)
Definition AABox.h:10
InheritedStrategyT::value_type value_type