Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dtk
dtk
Commits
5ecef5d1
Commit
5ecef5d1
authored
Jun 10, 2016
by
KLOCZKO Thibaud
Browse files
Add support for tuner into factory.
Fix also bad tuner destructor.
parent
7306c2b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/dtkCore/dtkCorePluginFactory.h
View file @
5ecef5d1
...
...
@@ -16,6 +16,8 @@
#include
<QtCore>
template
<
typename
T
>
class
dtkCorePluginTuner
;
// ///////////////////////////////////////////////////////////////////
// dtkCorePluginFactory
// ///////////////////////////////////////////////////////////////////
...
...
@@ -28,18 +30,22 @@ public:
public:
typedef
T
*
(
*
creator
)
();
typedef
dtkCorePluginTuner
<
T
>
*
(
*
tunerCreator
)
();
public:
void
record
(
const
QString
&
key
,
creator
func
);
void
recordTuner
(
const
QString
&
key
,
tunerCreator
func
);
public:
T
*
create
(
const
QString
&
key
)
const
;
dtkCorePluginTuner
<
T
>
*
createTuner
(
const
QString
&
key
)
const
;
public:
QStringList
keys
(
void
)
const
;
private:
QHash
<
QString
,
creator
>
creators
;
QHash
<
QString
,
tunerCreator
>
tuner_creators
;
};
// ///////////////////////////////////////////////////////////////////
...
...
src/dtkCore/dtkCorePluginFactory.tpp
View file @
5ecef5d1
...
...
@@ -38,6 +38,16 @@ template <typename T> void dtkCorePluginFactory<T>::record(const QString& key, c
this
->
creators
.
insert
(
key
,
func
);
}
template
<
typename
T
>
void
dtkCorePluginFactory
<
T
>::
recordTuner
(
const
QString
&
key
,
tunerCreator
func
)
{
if
(
this
->
tuner_creators
.
contains
(
key
))
{
qDebug
()
<<
Q_FUNC_INFO
<<
"Factory already contains key"
<<
key
<<
". Nothing is done"
;
return
;
}
this
->
tuner_creators
.
insert
(
key
,
func
);
}
// /////////////////////////////////////////////////////////////////
// Type creator invokation
// /////////////////////////////////////////////////////////////////
...
...
@@ -50,6 +60,14 @@ template <typename T> T *dtkCorePluginFactory<T>::create(const QString& key) con
return
this
->
creators
.
value
(
key
)();
}
template
<
typename
T
>
dtkCorePluginTuner
<
T
>
*
dtkCorePluginFactory
<
T
>::
createTuner
(
const
QString
&
key
)
const
{
if
(
!
this
->
tuner_creators
.
contains
(
key
))
return
NULL
;
return
this
->
tuner_creators
.
value
(
key
)();
}
// /////////////////////////////////////////////////////////////////
// Type creator inspection
// /////////////////////////////////////////////////////////////////
...
...
src/dtkCore/dtkCorePluginTuner.h
View file @
5ecef5d1
...
...
@@ -24,7 +24,7 @@ template < typename T > class dtkCorePluginTuner
{
public:
dtkCorePluginTuner
(
void
);
virtual
~
dtkCorePluginTuner
(
void
)
{}
virtual
~
dtkCorePluginTuner
(
void
)
;
void
setObject
(
T
*
object
);
void
setMap
(
const
QVariantHash
&
map
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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