Skip to content

Commit 2fc07f5

Browse files
authored
added smart pointer implementation, some code refactoring, removal of redundant file imports and addition of virtual destructor
1 parent 24f3149 commit 2fc07f5

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

tripMetaData.hpp

+23-24
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
#pragma once
2-
#include "rider.hpp"
3-
#include "driver.hpp"
4-
5-
//This class basically has all the info that will be used by strategy
6-
//# strategy and Driver Matching strategy will need data
7-
//Even if more data is needed, only this class needs to be updated
2+
#include "location.hpp"
3+
#include "common.hpp"
84

5+
// We can add more data (if needed) here, required to make decisions of # and DriverMatchign strategy
96
class TripMetaData {
10-
Location* srcLoc;
11-
Location* dstLoc;
12-
RATING riderRating;
13-
RATING driverRating;
7+
shared_ptr<Location> srcLoc;
8+
shared_ptr<Location> dstLoc;
9+
RATING riderRating;
10+
RATING driverRating;
1411
public:
15-
TripMetaData(Location* pSrcLoc, Location* pDstLoc, RATING pRiderRating) :
16-
srcLoc(pSrcLoc), dstLoc(pDstLoc), riderRating(pRiderRating) {
17-
driverRating = RATING::UNASSIGNED;
18-
}
19-
//getters and setters should be in cpp guys, I am just lazy to that
20-
RATING getRiderRating() {
21-
return riderRating;
22-
}
23-
RATING getDriverRating() {
24-
return driverRating;
25-
}
26-
void setDriverRating(RATING pDriverRating) {
27-
driverRating = pDriverRating;
28-
}
12+
TripMetaData(shared_ptr<Location> pSrcLoc, shared_ptr<Location> pDstLoc, RATING pRiderRating) :
13+
srcLoc(std::move(pSrcLoc)), dstLoc(std::move(pDstLoc)), riderRating(pRiderRating), driverRating(RATING::UNASSIGNED) {}
14+
15+
RATING getRiderRating() const {
16+
return riderRating;
17+
}
18+
19+
RATING getDriverRating() const {
20+
return driverRating;
21+
}
22+
23+
void setDriverRating(RATING pDriverRating) {
24+
driverRating = pDriverRating;
25+
}
26+
27+
virtual ~TripMetaData() = default; // Added virtual destructor
2928
};

0 commit comments

Comments
 (0)