Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
85b8675e
Commit
85b8675e
authored
Feb 19, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/Interface: add attribute "plugin"
The new method IsPlugin() replaces the "is_simple" flag.
parent
ae594ad9
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
34 additions
and
16 deletions
+34
-16
Main.cxx
src/Main.cxx
+2
-3
Configured.cxx
src/db/Configured.cxx
+2
-2
Configured.hxx
src/db/Configured.hxx
+1
-1
DatabaseGlue.cxx
src/db/DatabaseGlue.cxx
+1
-2
DatabaseGlue.hxx
src/db/DatabaseGlue.hxx
+1
-3
Interface.hxx
src/db/Interface.hxx
+14
-0
LazyDatabase.cxx
src/db/plugins/LazyDatabase.cxx
+3
-0
LazyDatabase.hxx
src/db/plugins/LazyDatabase.hxx
+1
-2
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+2
-1
SimpleDatabasePlugin.cxx
src/db/plugins/SimpleDatabasePlugin.cxx
+4
-0
SimpleDatabasePlugin.hxx
src/db/plugins/SimpleDatabasePlugin.hxx
+1
-2
UpnpDatabasePlugin.cxx
src/db/plugins/UpnpDatabasePlugin.cxx
+2
-0
No files found.
src/Main.cxx
View file @
85b8675e
...
...
@@ -166,11 +166,10 @@ InitStorage(Error &error)
static
bool
glue_db_init_and_load
(
void
)
{
bool
is_simple
;
Error
error
;
instance
->
database
=
CreateConfiguredDatabase
(
*
instance
->
event_loop
,
*
instance
,
is_simple
,
error
);
error
);
if
(
instance
->
database
==
nullptr
)
{
if
(
error
.
IsDefined
())
FatalError
(
error
);
...
...
@@ -193,7 +192,7 @@ glue_db_init_and_load(void)
if
(
!
instance
->
database
->
Open
(
error
))
FatalError
(
error
);
if
(
!
i
s_simple
)
if
(
!
i
nstance
->
database
->
IsPlugin
(
simple_db_plugin
)
)
return
true
;
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
instance
->
database
;
...
...
src/db/Configured.cxx
View file @
85b8675e
...
...
@@ -28,7 +28,7 @@
Database
*
CreateConfiguredDatabase
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
bool
&
is_simple_r
,
Error
&
error
)
Error
&
error
)
{
const
struct
config_param
*
param
=
config_get_param
(
CONF_DATABASE
);
const
struct
config_param
*
path
=
config_get_param
(
CONF_DB_FILE
);
...
...
@@ -53,7 +53,7 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
return
nullptr
;
Database
*
db
=
DatabaseGlobalInit
(
loop
,
listener
,
*
param
,
is_simple_r
,
error
);
error
);
delete
allocated
;
return
db
;
}
src/db/Configured.hxx
View file @
85b8675e
...
...
@@ -34,6 +34,6 @@ class Error;
*/
Database
*
CreateConfiguredDatabase
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
bool
&
is_simple_r
,
Error
&
error
);
Error
&
error
);
#endif
src/db/DatabaseGlue.cxx
View file @
85b8675e
...
...
@@ -29,11 +29,10 @@
Database
*
DatabaseGlobalInit
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
const
config_param
&
param
,
bool
&
is_simple
,
Error
&
error
)
const
config_param
&
param
,
Error
&
error
)
{
const
char
*
plugin_name
=
param
.
GetBlockValue
(
"plugin"
,
"simple"
);
is_simple
=
strcmp
(
plugin_name
,
"simple"
)
==
0
;
const
DatabasePlugin
*
plugin
=
GetDatabasePluginByName
(
plugin_name
);
if
(
plugin
==
nullptr
)
{
...
...
src/db/DatabaseGlue.hxx
View file @
85b8675e
...
...
@@ -32,11 +32,9 @@ class Error;
* Initialize the database library.
*
* @param param the database configuration block
* @param is_simple returns whether this is the "simple" database
* plugin
*/
Database
*
DatabaseGlobalInit
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
const
config_param
&
param
,
bool
&
is_simple
,
Error
&
error
);
const
config_param
&
param
,
Error
&
error
);
#endif
src/db/Interface.hxx
View file @
85b8675e
...
...
@@ -26,18 +26,32 @@
#include <time.h>
struct
DatabasePlugin
;
struct
DatabaseStats
;
struct
DatabaseSelection
;
struct
LightSong
;
class
Error
;
class
Database
{
const
DatabasePlugin
&
plugin
;
public
:
Database
(
const
DatabasePlugin
&
_plugin
)
:
plugin
(
_plugin
)
{}
/**
* Free instance data.
*/
virtual
~
Database
()
{}
const
DatabasePlugin
&
GetPlugin
()
const
{
return
plugin
;
}
bool
IsPlugin
(
const
DatabasePlugin
&
other
)
const
{
return
&
plugin
==
&
other
;
}
/**
* Open the database. Read it into memory if applicable.
*/
...
...
src/db/plugins/LazyDatabase.cxx
View file @
85b8675e
...
...
@@ -23,6 +23,9 @@
#include <assert.h>
LazyDatabase
::
LazyDatabase
(
Database
*
_db
)
:
Database
(
_db
->
GetPlugin
()),
db
(
_db
),
open
(
false
)
{}
LazyDatabase
::~
LazyDatabase
()
{
assert
(
!
open
);
...
...
src/db/plugins/LazyDatabase.hxx
View file @
85b8675e
...
...
@@ -35,8 +35,7 @@ class LazyDatabase final : public Database {
public
:
gcc_nonnull_all
LazyDatabase
(
Database
*
_db
)
:
db
(
_db
),
open
(
false
)
{}
LazyDatabase
(
Database
*
_db
);
virtual
~
LazyDatabase
();
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
85b8675e
...
...
@@ -91,7 +91,8 @@ class ProxyDatabase final : public Database, SocketMonitor, IdleMonitor {
public
:
ProxyDatabase
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
)
:
SocketMonitor
(
_loop
),
IdleMonitor
(
_loop
),
:
Database
(
proxy_db_plugin
),
SocketMonitor
(
_loop
),
IdleMonitor
(
_loop
),
listener
(
_listener
)
{}
static
Database
*
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
...
...
src/db/plugins/SimpleDatabasePlugin.cxx
View file @
85b8675e
...
...
@@ -40,6 +40,10 @@
static
constexpr
Domain
simple_db_domain
(
"simple_db"
);
inline
SimpleDatabase
::
SimpleDatabase
()
:
Database
(
simple_db_plugin
),
path
(
AllocatedPath
::
Null
())
{}
Database
*
SimpleDatabase
::
Create
(
gcc_unused
EventLoop
&
loop
,
gcc_unused
DatabaseListener
&
listener
,
...
...
src/db/plugins/SimpleDatabasePlugin.hxx
View file @
85b8675e
...
...
@@ -50,8 +50,7 @@ class SimpleDatabase : public Database {
mutable
unsigned
borrowed_song_count
;
#endif
SimpleDatabase
()
:
path
(
AllocatedPath
::
Null
())
{}
SimpleDatabase
();
public
:
gcc_pure
...
...
src/db/plugins/UpnpDatabasePlugin.cxx
View file @
85b8675e
...
...
@@ -75,6 +75,8 @@ class UpnpDatabase : public Database {
UPnPDeviceDirectory
*
discovery
;
public
:
UpnpDatabase
()
:
Database
(
upnp_db_plugin
)
{}
static
Database
*
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
const
config_param
&
param
,
Error
&
error
);
...
...
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