Commit 73ebfd36 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

parser: Split parser service specific bits in a separate header

parent 83470664
......@@ -165,6 +165,7 @@ noinst_HEADERS = \
src/metadata_services/vlc/VLCThumbnailer.h \
src/metadata_services/vlc/imagecompressors/IImageCompressor.h \
src/Movie.h \
src/parser/IParserService.h \
src/parser/Parser.h \
src/parser/ParserService.h \
src/parser/Task.h \
......
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2015-2018 Hugo Beauzée-Luyssen, Videolabs, VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#pragma once
#include "Task.h"
namespace medialibrary
{
class IParserService
{
public:
virtual ~IParserService() = default;
/**
* @brief run Process a specific task
* @param task The task to be processed
* @return A status code
*/
virtual parser::Task::Status run( parser::Task& task ) = 0;
/**
* @brief name returns the name of this service.
*
* This is for logging purposes only.
*/
virtual const char* name() const = 0;
/**
* @brief nbThreads Returns the number of thread this service wishes to run
*
* @return Concurrency, including database coherence, is the service's
* responsibility.
*/
virtual uint8_t nbThreads() const = 0;
/**
* @brief isCompleted Probes a task for completion with regard to this service.
* @param task The task probed for completion
* @return true if the task is completed, false otherwise.
*/
virtual bool isCompleted( const parser::Task& task ) const = 0;
/**
* @brief initialize Run service specific initialization.
*
* By the time this function is called, the database is fully initialized and
* can be used.
*
* If false is returned, the service will be released and won't be used.
*/
virtual bool initialize() = 0;
};
}
......@@ -27,6 +27,7 @@
#include <queue>
#include "Task.h"
#include "IParserService.h"
#include "medialibrary/Types.h"
#include "compat/Mutex.h"
#include "compat/Thread.h"
......@@ -39,7 +40,7 @@ class IParserCb;
class ModificationNotifier;
class MediaLibrary;
class ParserService
class ParserService : public IParserService
{
public:
ParserService();
......@@ -78,11 +79,7 @@ public:
protected:
uint8_t nbNativeThreads() const;
/// Can be overriden to run service dependent initializations
virtual bool initialize();
virtual parser::Task::Status run( parser::Task& task ) = 0;
virtual const char* name() const = 0;
virtual uint8_t nbThreads() const = 0;
virtual bool isCompleted( const parser::Task& task ) const = 0;
virtual bool initialize() override;
private:
// Thread(s) entry point
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment