Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLAScommon
Commits
31b03c0d
Commit
31b03c0d
authored
Jun 11, 2020
by
Steffen Vogel
🎅🏼
Browse files
plugin: do not store plugin name/desc in member variables
parent
50713278
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/villas/plugin.hpp
View file @
31b03c0d
...
...
@@ -75,7 +75,7 @@ public:
{
for
(
Plugin
*
p
:
*
plugins
)
{
T
*
t
=
dynamic_cast
<
T
*>
(
p
);
if
(
!
t
||
t
->
n
ame
!=
name
)
if
(
!
t
||
t
->
getN
ame
()
!=
name
)
continue
;
return
t
;
...
...
@@ -118,7 +118,7 @@ class Plugin {
friend
plugin
::
Registry
;
public:
Plugin
(
const
std
::
string
&
name
,
const
std
::
string
&
desc
);
Plugin
();
virtual
~
Plugin
();
// copying a plugin doesn't make sense, so explicitly deny it
...
...
@@ -127,18 +127,21 @@ public:
virtual
void
dump
();
const
std
::
string
&
getName
()
const
;
const
std
::
string
&
getDescription
()
const
;
/// Get plugin name
virtual
std
::
string
getName
()
const
=
0
;
// Get plugin description
virtual
std
::
string
getDescription
()
const
=
0
;
protected:
std
::
string
name
;
std
::
string
description
;
std
::
string
path
;
Logger
getLogger
()
{
return
logging
.
get
(
"plugin:"
+
n
ame
);
return
logging
.
get
(
"plugin:"
+
getN
ame
()
);
}
};
...
...
@@ -146,10 +149,12 @@ template<typename T = Plugin>
void
Registry
::
dumpList
()
{
getLogger
()
->
info
(
"Available plugins:"
);
for
(
Plugin
*
p
:
*
plugins
)
{
T
*
t
=
dynamic_cast
<
T
*>
(
p
);
if
(
t
)
std
::
cout
<<
" - "
<<
p
->
getName
()
<<
": "
<<
p
->
getDescription
()
<<
std
::
endl
;
getLogger
()
->
info
(
" - {}: {}"
,
p
->
getName
()
,
p
->
getDescription
()
)
;
}
}
...
...
lib/plugin.cpp
View file @
31b03c0d
...
...
@@ -32,9 +32,7 @@ using namespace villas::plugin;
List
<>
*
Registry
::
plugins
;
Plugin
::
Plugin
(
const
std
::
string
&
name
,
const
std
::
string
&
desc
)
:
name
(
name
),
description
(
desc
)
Plugin
::
Plugin
()
{
Registry
::
add
(
this
);
}
...
...
@@ -97,15 +95,5 @@ void
Plugin
::
dump
()
{
Logger
logger
=
Registry
::
getLogger
();
logger
->
info
(
"Name: '{}' Description: '{}'"
,
name
,
description
);
}
const
std
::
string
&
Plugin
::
getName
()
const
{
return
name
;
}
const
std
::
string
&
Plugin
::
getDescription
()
const
{
return
description
;
logger
->
info
(
"Name: '{}' Description: '{}'"
,
getName
(),
getDescription
());
}
Write
Preview
Supports
Markdown
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