-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCluster.h
83 lines (74 loc) · 1.81 KB
/
Cluster.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
#pragma once
#include <windows.h>
#include "BaseFileSystem.h"
enum class ClusterEnum { PNG, None };
class Cluster
{
private:
unsigned int number;
BaseFileSystem *fs;
public:
Cluster();
Cluster(int clusterNumber, BaseFileSystem *fsPtr);
int getNumber();
void readCluster(BYTE *pBuffer);
ClusterEnum getClusterType();
};
const int maxCount = 100000;
template<class Type> class Iterator
{
protected:
Iterator() {};
public:
virtual ~Iterator() {};
virtual void first() = 0;
virtual void next() = 0;
virtual bool isDone() const = 0;
virtual Type getCurrent() const = 0;
};
class ClusterContainer
{
private:
Cluster *clusters;
int count;
public:
ClusterContainer();
void addCluster(const Cluster &newCluster);
int getCount() const;
Cluster getByIndex(int clusterIndex) const;
Iterator<Cluster> *getIterator();
};
class ClusterContainerIterator : public Iterator<Cluster>
{
private:
const Cluster *clusters;
int count;
int position;
public:
ClusterContainerIterator(const Cluster *containerItems, int clustersCount);
void first();
void next();
bool isDone() const;
Cluster getCurrent() const;
};
template<class Type> class IteratorDecorator : public Iterator<Type>
{
protected:
Iterator<Type> *it;
public:
IteratorDecorator(Iterator<Type> *iterator) { it = iterator; };
virtual ~IteratorDecorator() { delete it; };
virtual void first() { it->first(); };
virtual void next() { it->next(); };
virtual bool isDone() const { return it->isDone(); };
virtual Type getCurrent() const { return it->getCurrent(); };
};
class ClusterContainerIteratorDecorator : public IteratorDecorator<Cluster>
{
private:
ClusterEnum targetClusterType;
public:
ClusterContainerIteratorDecorator(Iterator<Cluster> *it, ClusterEnum clusterType) : IteratorDecorator(it) { targetClusterType = clusterType; }
void first();
void next();
};