Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
f78a615c
Commit
f78a615c
authored
May 13, 2014
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a file getter in IMediaLibrary
parent
4c1ffc35
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
0 deletions
+30
-0
include/IMediaLibrary.h
include/IMediaLibrary.h
+1
-0
src/MediaLibrary.cpp
src/MediaLibrary.cpp
+21
-0
src/MediaLibrary.h
src/MediaLibrary.h
+1
-0
test/Tests.cpp
test/Tests.cpp
+7
-0
No files found.
include/IMediaLibrary.h
View file @
f78a615c
...
...
@@ -12,6 +12,7 @@ class IMediaLibrary
virtual
~
IMediaLibrary
()
{}
virtual
bool
initialize
(
const
std
::
string
&
dbPath
)
=
0
;
virtual
IFile
*
addFile
(
const
std
::
string
&
path
)
=
0
;
virtual
IFile
*
file
(
const
std
::
string
&
path
)
=
0
;
virtual
const
std
::
vector
<
IFile
*>&
files
()
=
0
;
};
...
...
src/MediaLibrary.cpp
View file @
f78a615c
...
...
@@ -42,6 +42,27 @@ const std::vector<IFile*>& MediaLibrary::files()
return
*
m_files
;
}
IFile
*
MediaLibrary
::
file
(
const
std
::
string
&
path
)
{
if
(
m_files
==
NULL
)
{
// FIXME: This is probably ineficient.
// Consider loading the file itself from the DB & eventually store it in a tmp
// vector? Or implement caching globally for each class
files
();
}
std
::
vector
<
IFile
*>::
iterator
it
=
m_files
->
begin
();
std
::
vector
<
IFile
*>::
iterator
ite
=
m_files
->
end
();
while
(
it
!=
ite
)
{
if
(
(
*
it
)
->
mrl
()
==
path
)
return
*
it
;
++
it
;
}
return
NULL
;
}
IFile
*
MediaLibrary
::
addFile
(
const
std
::
string
&
path
)
{
File
*
f
=
new
File
(
path
);
...
...
src/MediaLibrary.h
View file @
f78a615c
...
...
@@ -11,6 +11,7 @@ class MediaLibrary : public IMediaLibrary
MediaLibrary
();
virtual
bool
initialize
(
const
std
::
string
&
dbPath
);
virtual
const
std
::
vector
<
IFile
*>&
files
();
virtual
IFile
*
file
(
const
std
::
string
&
path
);
virtual
IFile
*
addFile
(
const
std
::
string
&
path
);
private:
...
...
test/Tests.cpp
View file @
f78a615c
...
...
@@ -46,6 +46,13 @@ TEST_F( MLTest, InsertFile )
delete
f
;
}
TEST_F
(
MLTest
,
FetchFile
)
{
IFile
*
f
=
ml
->
addFile
(
"/dev/null"
);
IFile
*
f2
=
ml
->
file
(
"/dev/null"
);
ASSERT_EQ
(
f
->
mrl
(),
f2
->
mrl
()
);
}
TEST_F
(
MLTest
,
AddLabel
)
{
IFile
*
f
=
ml
->
addFile
(
"/dev/null"
);
...
...
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