-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrategyMgr.cpp
26 lines (22 loc) · 1.32 KB
/
strategyMgr.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
#include "strategyMgr.hpp"
shared_ptr<StrategyMgr> StrategyMgr::strategyMgrInstance = nullptr;
mutex StrategyMgr::mtx;
shared_ptr<StrategyMgr> StrategyMgr::getStrategyMgr() {
lock_guard<mutex> lock(mtx); // Used lock_guard for RAII
if (!strategyMgrInstance) {
strategyMgrInstance = shared_ptr<StrategyMgr>(new StrategyMgr());
}
return strategyMgrInstance;
}
shared_ptr<#Strategy> StrategyMgr::determine#Strategy(const shared_ptr<TripMetaData>& metaData) {
cout << "Based on location and other factors, setting # strategy" << endl;
/*no logic is being implemented to determine # strategy just because objective of the
project is to learn design patterns, OOPS, modularity and modern cpp features in C++*/
return make_shared<Default#Strategy>();
}
shared_ptr<DriverMatchingStrategy> StrategyMgr::determineMatchingStrategy(const shared_ptr<TripMetaData>& metaData) {
cout << "Based on location and other factors, setting matching strategy" << endl;
/*no logic is being implemented to determine driver strategy (however, we have only one driver matching strategy!)
just because objective of the project is to learn design patterns, OOPS, modularity and modern cpp features in C++*/
return make_shared<LeastTimeBasedMatchingStrategy>();
}