forked from bruderstein/PythonScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDynamicIDManager.h
More file actions
65 lines (42 loc) · 1.12 KB
/
DynamicIDManager.h
File metadata and controls
65 lines (42 loc) · 1.12 KB
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
#ifndef _DYNAMICIDMANAGER_H
#define _DYNAMICIDMANAGER_H
#include "IDAllocator.h"
class DynamicIDManager
{
public:
DynamicIDManager(IDAllocator *allocator)
: m_allocator (allocator),
m_capacity(0)
{
m_current = m_idList.begin();
};
DynamicIDManager(IDAllocator *allocator, int initialStart, int quantity)
: m_allocator (allocator),
m_capacity(quantity),
m_nextID(initialStart + quantity)
{
m_idList.push_back(std::pair<int, int>(initialStart, quantity));
m_current = m_idList.begin();
};
void reserve(int quantity);
void reserveAdditional(int quantity);
int begin();
int currentID();
void addBlock(int start, int quantity);
// Post-increment operator
DynamicIDManager& operator++(int);
int capacity() { return m_capacity; };
bool inRange(int id);
private:
// Methods
bool allocateIDs(int quantity, int *start);
IDAllocator* m_allocator;
// Data
typedef std::list< std::pair<int, int> > t_idList;
t_idList m_idList;
t_idList::iterator m_current;
int m_nextID;
int m_capacity;
HWND m_nppHandle;
};
#endif