Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
medialibrary
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
57
Issues
57
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VideoLAN
medialibrary
Commits
8aeae861
Commit
8aeae861
authored
May 23, 2014
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Labels: Do not store a list of files.
parent
d49b4401
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
17 deletions
+14
-17
include/ILabel.h
include/ILabel.h
+1
-1
src/Label.cpp
src/Label.cpp
+5
-12
src/Label.h
src/Label.h
+1
-2
test/Labels.cpp
test/Labels.cpp
+7
-2
No files found.
include/ILabel.h
View file @
8aeae861
...
...
@@ -13,7 +13,7 @@ class ILabel
virtual
unsigned
int
id
()
const
=
0
;
virtual
const
std
::
string
&
name
()
=
0
;
virtual
std
::
vector
<
FilePtr
>&
files
(
)
=
0
;
virtual
bool
files
(
std
::
vector
<
FilePtr
>&
files
)
=
0
;
};
#endif // ILABEL_H
src/Label.cpp
View file @
8aeae861
...
...
@@ -12,7 +12,6 @@ unsigned int Label::* const policy::LabelTable::PrimaryKey = &Label::m_id;
Label
::
Label
(
sqlite3
*
dbConnection
,
sqlite3_stmt
*
stmt
)
:
m_dbConnection
(
dbConnection
)
,
m_files
(
NULL
)
{
m_id
=
sqlite3_column_int
(
stmt
,
0
);
m_name
=
(
const
char
*
)
sqlite3_column_text
(
stmt
,
1
);
...
...
@@ -22,7 +21,6 @@ Label::Label( const std::string& name )
:
m_dbConnection
(
NULL
)
,
m_id
(
0
)
,
m_name
(
name
)
,
m_files
(
NULL
)
{
}
...
...
@@ -37,17 +35,12 @@ const std::string& Label::name()
return
m_name
;
}
std
::
vector
<
FilePtr
>&
Label
::
files
(
)
bool
Label
::
files
(
std
::
vector
<
FilePtr
>&
files
)
{
if
(
m_files
==
nullptr
)
{
m_files
=
new
std
::
vector
<
std
::
shared_ptr
<
IFile
>>
;
static
const
std
::
string
req
=
"SELECT f.* FROM "
+
policy
::
FileTable
::
Name
+
" f "
"LEFT JOIN LabelFileRelation lfr ON lfr.id_file = f.id_file "
"WHERE lfr.id_label = ?"
;
SqliteTools
::
fetchAll
<
File
>
(
m_dbConnection
,
req
.
c_str
(),
*
m_files
,
m_id
);
}
return
*
m_files
;
static
const
std
::
string
req
=
"SELECT f.* FROM "
+
policy
::
FileTable
::
Name
+
" f "
"LEFT JOIN LabelFileRelation lfr ON lfr.id_file = f.id_file "
"WHERE lfr.id_label = ?"
;
return
SqliteTools
::
fetchAll
<
File
>
(
m_dbConnection
,
req
.
c_str
(),
files
,
m_id
);
}
LabelPtr
Label
::
create
(
sqlite3
*
dbConnection
,
const
std
::
string
&
name
)
...
...
src/Label.h
View file @
8aeae861
...
...
@@ -39,7 +39,7 @@ class Label : public ILabel, public Cache<Label, ILabel, policy::LabelTable, pol
public:
virtual
unsigned
int
id
()
const
;
virtual
const
std
::
string
&
name
();
virtual
std
::
vector
<
FilePtr
>&
files
(
);
virtual
bool
files
(
std
::
vector
<
FilePtr
>&
files
);
static
LabelPtr
create
(
sqlite3
*
dbConnection
,
const
std
::
string
&
name
);
static
bool
createTable
(
sqlite3
*
dbConnection
);
...
...
@@ -47,7 +47,6 @@ class Label : public ILabel, public Cache<Label, ILabel, policy::LabelTable, pol
sqlite3
*
m_dbConnection
;
unsigned
int
m_id
;
std
::
string
m_name
;
std
::
vector
<
std
::
shared_ptr
<
IFile
>>*
m_files
;
friend
class
Cache
<
Label
,
ILabel
,
policy
::
LabelTable
>
;
friend
class
policy
::
LabelTable
;
...
...
test/Labels.cpp
View file @
8aeae861
...
...
@@ -104,8 +104,13 @@ TEST_F( Labels, Files )
f2
->
addLabel
(
l2
);
f3
->
addLabel
(
l1
);
auto
label1Files
=
l1
->
files
();
auto
label2Files
=
l2
->
files
();
std
::
vector
<
FilePtr
>
label1Files
;
std
::
vector
<
FilePtr
>
label2Files
;
bool
res
=
l1
->
files
(
label1Files
);
ASSERT_TRUE
(
res
);
res
=
l2
->
files
(
label2Files
);
ASSERT_TRUE
(
res
);
ASSERT_EQ
(
label1Files
.
size
(),
2u
);
ASSERT_EQ
(
label2Files
.
size
(),
1u
);
...
...
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