-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollageLayoutManagerFactory.cpp
75 lines (60 loc) · 2.54 KB
/
CollageLayoutManagerFactory.cpp
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
///////////////////////////////////////////////////////////////////////////////////////////////
//
// Name: CollageLayoutManagerFactory.cpp
//
// Author: Mike Conway
//
// Description: Factory to create appropriate layout manager that
// subclasses CollageLayoutManager
//
///////////////////////////////////////////////////////////////////////////////////////////////
#include "CollageLayoutManagerFactory.h"
#include <iostream>
CollageLayoutManagerFactory::CollageLayoutManagerFactory(CollageGraphics* collageGraphics) {
this->collageGraphics = collageGraphics;
}
CollageLayoutManagerFactory::~CollageLayoutManagerFactory() {
}
CollageLayoutManager* CollageLayoutManagerFactory::CreateLayoutManager(CollageLayoutManagerFactory::LayoutType layoutType) {
CollageLayoutManager* selectedLayout = NULL;
switch (layoutType) {
case CollageLayoutManagerFactory::LM_SIMPLE_SINGLE:
selectedLayout = CreateSimpleSingleLayoutManager();
break;
case CollageLayoutManagerFactory::LM_SIMPLE_DOUBLE:
selectedLayout = CreateSimpleDoubleLayoutManager();
break;
case CollageLayoutManagerFactory::LM_SMART_SINGLE:
selectedLayout = CreateSmartSingleLayoutManager();
break;
case CollageLayoutManagerFactory::LM_RANDOM:
selectedLayout = CreateRandomLayoutManager();
break;
case CollageLayoutManagerFactory::LM_FILL_ROOM:
selectedLayout = CreateFillRoomLayoutManager();
break;
default:
selectedLayout = CreateSimpleSingleLayoutManager();
}
return selectedLayout;
}
// Factory method returns a simple, single-row layout
CollageLayoutManager* CollageLayoutManagerFactory::CreateSimpleSingleLayoutManager() {
return new SimpleSingleLayoutManager(collageGraphics);
}
// Factory method returns a simple, double-row layout
CollageLayoutManager* CollageLayoutManagerFactory::CreateSimpleDoubleLayoutManager() {
return new SimpleDoubleLayoutManager(collageGraphics);
}
// Factory method returns a smart, single-row layout
CollageLayoutManager* CollageLayoutManagerFactory::CreateSmartSingleLayoutManager() {
return new SmartSingleLayoutManager(collageGraphics);
}
// Factory method returns a random layout
CollageLayoutManager* CollageLayoutManagerFactory::CreateRandomLayoutManager() {
return new RandomLayoutManager(collageGraphics);
}
// Factory method returns a layout that fills the room horizontally
CollageLayoutManager* CollageLayoutManagerFactory::CreateFillRoomLayoutManager() {
return new FillRoomLayoutManager(collageGraphics);
}