WIP. Database updater now has its own namespace and dedicated directory
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include "DatabaseRefreshService.hpp"
|
||||
|
||||
DatabaseRefreshService::DatabaseRefreshService(boost::asio::io_service& ioService, const boost::filesystem::path& p)
|
||||
: _metadataParser(),
|
||||
_database( p, _metadataParser)
|
||||
{
|
||||
// TODO read from the database itself!
|
||||
// Move this code in the database class
|
||||
_database.watchDirectory( Database::WatchedDirectory("/storage/common/Media/Son/Metal", Database::WatchedDirectory::Audio) );
|
||||
_database.watchDirectory( Database::WatchedDirectory("/storage/common/Media/Video", Database::WatchedDirectory::Video) );
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseRefreshService::start(void)
|
||||
{
|
||||
// _thread = boost::thread(boost::bind(&Database::refresh, &_database));
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseRefreshService::stop(void)
|
||||
{
|
||||
std::cout << "DatabaseRefreshService::stop, processing..." << std::endl;
|
||||
_thread.interrupt();
|
||||
_thread.join();
|
||||
std::cout << "DatabaseRefreshService::stop, process done" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseRefreshService::restart(void)
|
||||
{
|
||||
std::cout << "DatabaseRefreshService::restart, not implemented" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef DB_REFRESH_SERVICE_HPP
|
||||
#define DB_REFRESH_SERVICE_HPP
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include "metadata/AvFormat.hpp"
|
||||
#include "database/Database.hpp"
|
||||
|
||||
#include "Service.hpp"
|
||||
|
||||
class DatabaseRefreshService : public Service
|
||||
{
|
||||
public:
|
||||
|
||||
DatabaseRefreshService(boost::asio::io_service& ioService, const boost::filesystem::path& p);
|
||||
|
||||
void start(void);
|
||||
void stop(void);
|
||||
void restart(void);
|
||||
|
||||
private:
|
||||
|
||||
boost::thread _thread;
|
||||
|
||||
MetaData::AvFormat _metadataParser;
|
||||
Database::Database _database; // Todo use handler
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include "DatabaseUpdateService.hpp"
|
||||
|
||||
DatabaseUpdateService::DatabaseUpdateService(boost::asio::io_service& ioService, const boost::filesystem::path& p)
|
||||
: _metadataParser(),
|
||||
_databaseUpdater( p, _metadataParser)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseUpdateService::start(void)
|
||||
{
|
||||
// _thread = boost::thread(boost::bind(&Database::refresh, &_databaseUpdater.);
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseUpdateService::stop(void)
|
||||
{
|
||||
std::cout << "DatabaseUpdateService::stop, processing..." << std::endl;
|
||||
_thread.interrupt();
|
||||
_thread.join();
|
||||
std::cout << "DatabaseUpdateService::stop, process done" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
DatabaseUpdateService::restart(void)
|
||||
{
|
||||
std::cout << "DatabaseUpdateService::restart, not implemented" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef DB_UPDATE_SERVICE_HPP
|
||||
#define DB_UPDATE_SERVICE_HPP
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include "metadata/AvFormat.hpp"
|
||||
#include "database-updater/DatabaseUpdater.hpp"
|
||||
|
||||
#include "Service.hpp"
|
||||
|
||||
class DatabaseUpdateService : public Service
|
||||
{
|
||||
public:
|
||||
|
||||
DatabaseUpdateService(boost::asio::io_service& ioService, const boost::filesystem::path& p);
|
||||
|
||||
void start(void);
|
||||
void stop(void);
|
||||
void restart(void);
|
||||
|
||||
private:
|
||||
|
||||
boost::thread _thread;
|
||||
|
||||
MetaData::AvFormat _metadataParser;
|
||||
DatabaseUpdater::Updater _databaseUpdater; // Todo use handler
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
#include "av/Common.hpp"
|
||||
|
||||
#include "ServiceManager.hpp"
|
||||
#include "DatabaseRefreshService.hpp"
|
||||
#include "DatabaseUpdateService.hpp"
|
||||
#include "UserInterfaceService.hpp"
|
||||
#include "RemoteServerService.hpp"
|
||||
|
||||
@@ -32,7 +32,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
std::cout << "Starting services..." << std::endl;
|
||||
|
||||
serviceManager.startService( std::make_shared<DatabaseRefreshService>( serviceManager.getIoService(), dbPath) );
|
||||
serviceManager.startService( std::make_shared<DatabaseUpdateService>( serviceManager.getIoService(), dbPath) );
|
||||
serviceManager.startService( std::make_shared<RemoteServerService>( serviceManager.getIoService(), remoteListenEndpoint, dbPath) );
|
||||
serviceManager.startService( std::make_shared<UserInterfaceService>(argc, argv, dbPath) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user