ctx::VisitDetector::VisitDetector(time_t startScan, PlaceRecogMode energyMode, bool testMode) :
__testMode(testMode),
- __locationLogger(testMode ? nullptr : new LocationLogger(this)),
- __wifiLogger(testMode ? nullptr : new WifiLogger(this, energyMode)),
+ __locationLogger(testMode ? nullptr : new(std::nothrow) LocationLogger(this)),
+ __wifiLogger(testMode ? nullptr : new(std::nothrow) WifiLogger(this, energyMode)),
__currentInterval(startScan, startScan + VISIT_DETECTOR_PERIOD_SECONDS_HIGH_ACCURACY),
__stableCounter(0),
__tolerance(VISIT_DETECTOR_TOLERANCE_DEPTH),
__entranceTime(0),
__departureTime(0)
{
+ _D("CONSTRUCTOR");
__setPeriod(energyMode);
__currentInterval = Interval(startScan, startScan + __periodSeconds);
__currentMacEvents = std::make_shared<MacEvents>();
ctx::VisitDetector::~VisitDetector()
{
+ _D("DESTRUCTOR");
+ if (__locationLogger)
+ delete __locationLogger;
+ if (__wifiLogger)
+ delete __wifiLogger;
}
bool ctx::VisitDetector::__isValid(const ctx::Mac &mac)