-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathWEAbstractContainer.h
executable file
·100 lines (62 loc) · 2.34 KB
/
WEAbstractContainer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef _WEAbstractContainer_h
#define _WEAbstractContainer_h
#include "../WEDataTypes.h"
namespace WE {
class AbstractContainer {
public:
typedef UINT32 ElementType;
typedef UINT32 Index;
class ElementAddress {
public:
virtual ~ElementAddress() {}
virtual void cloneTo(ElementAddress& target) const {}
};
class AddressBatchContext {
};
class ElementAddressBatch {
public:
ElementAddressBatch() : mElementCount(0) {}
virtual ~ElementAddressBatch() {}
virtual void initWith(AbstractContainer& container) = 0;
virtual void cloneTo(ElementAddressBatch& target) const {}
virtual void destroy() = 0;
virtual void clear() = 0; //might keep memory allocated
virtual void add(const ElementAddress& address, AddressBatchContext* pCtx) = 0;
const Index& getElementCount() { return mElementCount; }
virtual Index getBatchCount() = 0; //not element count, can be used to estimate batching efficiency, the smaller the better
protected:
Index mElementCount;
};
struct ElementProcessorInfo;
enum FunctionSignature {
FS_1 = 0
};
typedef void (*fct_process_1) (const Index& processingIndex, void* pArg, void* context, const ElementAddress* pAddress, AddressBatchContext* pCtx);
//typedef void (*fct_process_2) (void* pElement, void* context);
struct ElementProcessorInfo {
FunctionSignature functionSignature;
union {
fct_process_1 function;
};
void* context;
ElementType argType;
ElementProcessorInfo() {};
ElementProcessorInfo(fct_process_1 function, void* context, ElementType argType) {
init(function, context, argType);
};
void init(fct_process_1 function, void* context, ElementType argType) {
this->functionSignature = FS_1;
this->function = function;
this->context = context;
this->argType = argType;
};
};
virtual bool isCompatibleWith(const ElementType& type) = 0;
virtual Index getElementCount() = 0;
virtual ElementAddressBatch* createElementAddressBatch() = 0;
virtual void process(ElementProcessorInfo& processor) = 0;
virtual void process(ElementProcessorInfo& processor, const ElementAddress& address) = 0;
virtual void process(ElementProcessorInfo& processor, const ElementAddressBatch& address) = 0;
};
}
#endif