[Improvements] CryPluginManager

#1
Hello, Crytek.
What about add new functionality in CryPluginManager?
Very need feature "get plugin pointer"
Example :

Code: Select all

ICryPluginManager.h struct ICryPluginManager { ... virtual ICryPlugin* GetPluginById(const CryClassID &id) = 0; ... } CryPluginManager.h class CCryPluginManager final : public ICryPluginManager, public ISystemEventListener { ... ICryPlugin* GetPluginById(const CryClassID &id) override; ... } CryPluginManeger.cpp ICryPlugin* CCryPluginManager::GetPluginById(const CryClassID &id) { for (auto it = m_pluginContainer.begin(); it != m_pluginContainer.end(); ++it) { if (it->m_pluginClassId == id) return it->GetPluginPtr(); } return nullptr; }
With this simple function we can get other plugins and work with it :

Code: Select all

if (auto pFactory = gEnv->pSystem->GetCryFactoryRegistry()->GetFactory("Test_Plugin")) { if (auto pPlugin = gEnv->pSystem->GetIPluginManager()->GetPluginById(pFactory->GetClassID())) { // Do smth } }
I hope that you will add it in release 5.3.3

Best regards.

Re: [Improvements] CryPluginManager

#4
You can not get more userfriendly than this:

Code: Select all

auto pMyPlugin = pPluginManager->QueryPlugin<CMyPlugin>();
Which is whats already implemented. So about 0 need for another function that doesnt even use template parameters to cast the result. With your solution you would still need to do that manually. With more code.

so your example code would be

Code: Select all

if(auto pMyPlugin = gEnv->pSystem->GetIPluginManager()->QueryPlugin<CMyPlugin>()) pMyPlugin->DoSomething();

Re: [Improvements] CryPluginManager

#5
@sunnlok, To use QueryPlugin<T>() you need create new interface for plugin like this :

Code: Select all

#include <CrySystem/ICryPlugin.h> struct IMyPluginEnv; struct IMyPlugin : public ICryPlugin { CRYINTERFACE_DECLARE(IMyPlugin , 0x11780A2402EE4B94, 0xA80F0E9B34706316); public: virtual IMyPluginEnv* GetPluginEnv() const = 0; };
also need register interface :

Code: Select all

class CMyPlugin : public IMyPlugin , public ISystemEventListener { public: CRYINTERFACE_BEGIN() CRYINTERFACE_ADD(IMyPlugin) CRYINTERFACE_ADD(ICryPlugin) CRYINTERFACE_END() CRYGENERATE_SINGLETONCLASS(CMyPlugin , "My_Plugin", 0x2799ED0066B04E6B, 0xA5722E51345346A8) ... }
This is your best?
For each plug-in you have to make a separate interface.

Simply use the same two lines of code and plug-ins do not change at all? Or am I wrong?

Who is online

Users browsing this forum: No registered users and 1 guest