Update to use Libraries and fix include order

This commit is contained in:
2020-03-07 14:46:26 +01:00
parent 3b7491f57d
commit 157b1ceb51
32 changed files with 114 additions and 1405 deletions
+20 -20
View File
@@ -1,34 +1,34 @@
#include "Bluetooth/Device.h"
#include "UniFi/Device.h"
#include "Util/Device.h"
#include "Util/INIh.h"
#include <clipp.h>
#include <Logging.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>
#include <string>
#include <signal.h>
#include <syslog.h>
#include <unistd.h>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include "Util/clipp.h"
#include "Util/Device.h"
#include "Util/INIh.h"
#include "Util/Logger.h"
#include "UniFi/Device.h"
#include "Bluetooth/Device.h"
int main(int argc, char** argv)
{
try
{
setlogmask(LOG_UPTO(LOG_DEBUG));
openlog("PresenceDetection", LOG_NDELAY | LOG_PID, LOG_USER);
Logging::OpenLog();
Logging::SetLogMask(Logging::Severity::Debug);
bool daemon = false;
PresenceDetection::Util::clipp::group cli {
PresenceDetection::Util::clipp::option("-d", "--daemon").set(daemon).doc("Run the process as Daemon")
clipp::group cli {
clipp::option("-d", "--daemon").set(daemon).doc("Run the process as Daemon")
};
if (!PresenceDetection::Util::clipp::parse(argc, argv, cli))
if (!clipp::parse(argc, argv, cli))
{
std::cout << PresenceDetection::Util::clipp::make_man_page(cli, argv[0]) << std::endl;
std::cout << clipp::make_man_page(cli, argv[0]) << std::endl;
return 1;
}
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
if (daemon)
{
PresenceDetection::Util::Logger::Log(PresenceDetection::Util::Logger::Severity::Info, "Starting Daemon");
Logging::Log(Logging::Severity::Info, "Starting Daemon");
pid_t pid, sid;
pid = fork();
@@ -164,7 +164,7 @@ int main(int argc, char** argv)
int sig;
sigwait(&wset,&sig);
PresenceDetection::Util::Logger::Log(PresenceDetection::Util::Logger::Severity::Info, "Stopping...");
Logging::Log(Logging::Severity::Info, "Stopping...");
if (pUniFiDevice)
pUniFiDevice->Stop();
@@ -178,7 +178,7 @@ int main(int argc, char** argv)
if (pBluetoothDevice)
pBluetoothDevice->Wait();
closelog();
Logging::CloseLog();
}
catch (const std::exception& e)
{
@@ -186,9 +186,9 @@ int main(int argc, char** argv)
ss << "ERROR: " << e.what() << std::endl;
std::cerr << ss.str() << std::endl;
PresenceDetection::Util::Logger::Log(PresenceDetection::Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
closelog();
Logging::CloseLog();
return -1;
}
+9 -12
View File
@@ -1,14 +1,12 @@
#include <iostream>
#include <string>
#include <memory>
#include <algorithm>
#include "Util/INIh.h"
#include <Timer.h>
#include <unistd.h>
#include <algorithm>
#include <chrono>
#include <deque>
#include "Util/Timer.h"
#include "Util/INIh.h"
#include <iostream>
#include <memory>
#include <string>
void print()
@@ -18,7 +16,7 @@ void print()
void TestTimerAbort()
{
PresenceDetection::Util::Timer timer;
Timer::Timer timer;
std::function<void()> f_print = print;
std::cout << "---" << std::endl;
@@ -51,7 +49,7 @@ void TestTimerAbort()
std::cout << "---" << std::endl << std::endl;
}
typedef std::unique_ptr<PresenceDetection::Util::Timer> Pointer;
typedef std::unique_ptr<Timer::Timer> Pointer;
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
@@ -70,7 +68,7 @@ void StartNewTimer(std::deque<Pointer>& timers)
int id(10);
// Protect!
auto timer = make_unique<PresenceDetection::Util::Timer>();
auto timer = make_unique<Timer::Timer>();
timer->StartSingle(delay, static_cast<std::function<void(const std::string&, int)>>(std::bind(&OnTimerEnd, std::placeholders::_1, std::placeholders::_2)), identifier, id);
timers.push_back(std::move(timer));
}
@@ -123,4 +121,3 @@ int main(int /*argc*/, char** /*argv[]*/)
return 0;
}