[plug] [PATCH] changed provider due to change of pass.h.
Vladislav Ivanishin
vlad at ispras.ru
Fri Apr 6 13:03:34 MSK 2018
Здравствуйте,
Комментарии внутри.
> ---
> provider.cpp | 6 +++---
> provider.h | 5 +++--
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/provider.cpp b/provider.cpp
> index 54f13b7..625d6d3 100644
> --- a/provider.cpp
> +++ b/provider.cpp
> @@ -8,8 +8,8 @@ void PassKeeper::launchPass(passGetter G) {
> P->launch();
> }
>
> -Pass * PassKeeper::getPass(const char * const PlugName) const {
> +const Pass * PassKeeper::getPass(const std::string *PlugName) {
Использование string* мне кажется неверным. Можно в двух разных местах
создать string("foo"), тогда они будут иметь разные адреса и
соответствующий Pass не будет найден. Почему не использовать просто
std::string?
> if (Plug.find(PlugName) != Plug.end())
> - return &(Plug[PlugName]);
> - return nullptr;
> + return Plug[PlugName];
> + return NULL;
> }
> \ No newline at end of file
> diff --git a/provider.h b/provider.h
> index 6b416c8..c22ed7b 100644
> --- a/provider.h
> +++ b/provider.h
> @@ -3,6 +3,7 @@
>
> #include "pass.h"
> #include <map>
> +#include <string>
>
> typedef Pass * (*passGetter)(); // pointer to [Pass * getPass()] function
>
> @@ -10,9 +11,9 @@ class PassKeeper {
> public:
> PassKeeper() {}
> void launchPass(passGetter G); // knowing address, I can launch relevant pass
> - Pass * getPass(const char * const PlugName) const; // return executed pass
> + const Pass * getPass(const std::string *PlugName); // return executed pass
> private:
> - std::map<const char * const, Pass> Plug; // executed passes
> + std::map<const std::string *, Pass *> Plug; // executed passes
> };
>
> #endif /* PROVIDER_H */
> \ No newline at end of file
--
Влад
More information about the plug
mailing list