Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
421dd7c4
Commit
421dd7c4
authored
May 21, 2014
by
Hugo Beauzée-Luyssen
Browse files
Add the foundations for IMetadataService
parent
c89a3e8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/IMediaLibrary.h
View file @
421dd7c4
...
...
@@ -7,6 +7,7 @@
class
IFile
;
class
ILabel
;
class
IMetadataService
;
typedef
std
::
shared_ptr
<
IFile
>
FilePtr
;
typedef
std
::
shared_ptr
<
ILabel
>
LabelPtr
;
...
...
@@ -24,6 +25,7 @@ class IMediaLibrary
virtual
bool
deleteLabel
(
const
std
::
string
&
label
)
=
0
;
virtual
bool
deleteLabel
(
LabelPtr
label
)
=
0
;
virtual
bool
files
(
std
::
vector
<
FilePtr
>&
res
)
=
0
;
virtual
void
addMetadataService
(
IMetadataService
*
service
)
=
0
;
};
class
MediaLibraryFactory
...
...
include/IMetadataService.h
0 → 100644
View file @
421dd7c4
#ifndef IMETADATASERVICE_H
#define IMETADATASERVICE_H
#include "IMediaLibrary.h"
class
IMetadataService
{
public:
enum
Result
{
Success
,
Failure
,
NotApplicable
// If trying to fetch the tv show summary of an album, for instance
};
virtual
~
IMetadataService
()
{}
virtual
unsigned
int
priority
()
=
0
;
virtual
Result
run
(
FilePtr
file
)
=
0
;
};
#endif // IMETADATASERVICE_H
src/MediaLibrary.cpp
View file @
421dd7c4
#include <algorithm>
#include <functional>
#include "MediaLibrary.h"
#include "IMetadataService.h"
#include "SqliteTools.h"
#include "File.h"
#include "Label.h"
...
...
@@ -77,3 +81,15 @@ bool MediaLibrary::deleteLabel( LabelPtr label )
{
return
Label
::
destroy
(
m_dbConnection
,
std
::
static_pointer_cast
<
Label
>
(
label
)
);
}
void
MediaLibrary
::
addMetadataService
(
IMetadataService
*
service
)
{
typedef
std
::
unique_ptr
<
IMetadataService
>
MdsPtr
;
std
::
function
<
bool
(
const
MdsPtr
&
,
const
MdsPtr
&
)
>
comp
=
[](
const
MdsPtr
&
a
,
const
MdsPtr
&
b
)
{
// We want higher priority first
return
a
->
priority
()
>
b
->
priority
();
};
m_mdServices
.
push_back
(
MdsPtr
(
service
)
);
std
::
push_heap
(
m_mdServices
.
begin
(),
m_mdServices
.
end
(),
comp
);
}
src/MediaLibrary.h
View file @
421dd7c4
...
...
@@ -19,7 +19,9 @@ class MediaLibrary : public IMediaLibrary
virtual
LabelPtr
createLabel
(
const
std
::
string
&
label
);
virtual
bool
deleteLabel
(
const
std
::
string
&
text
);
virtual
bool
deleteLabel
(
LabelPtr
label
);
virtual
void
addMetadataService
(
IMetadataService
*
service
);
private:
sqlite3
*
m_dbConnection
;
std
::
vector
<
std
::
unique_ptr
<
IMetadataService
>>
m_mdServices
;
};
#endif // MEDIALIBRARY_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment