Author Topic: Plugin vs Module  (Read 6445 times)

feredi

  • Newbie
  • *
  • Posts: 18
    • View Profile
Plugin vs Module
« on: June 02, 2015, 02:54:43 PM »
Hi all,

I have two questions and I will be grateful if somebody could help me know the answer to them.

1) What are specific differences between Module and Plugin classes? When I want to add some more functionality, which one should I go with?
2) I have derived my module class from Plugin. When I load it with module load command in rmanager, I see other plugins I have created the same way get re-initialized along with some modules like MySql, etc. why is that so? Is it by design or is it that I might have some bug? How can two completely different plugins interfere with each other while they're doing different things.

Regards

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Plugin vs Module
« Reply #1 on: June 03, 2015, 12:57:27 AM »
Hi,

The Module class extends the Plugin (check the API for the differences). One difference is the Module is a MessageReceiver also.
The 'module load' command loads files (dynamic libraries).
If the library implements a Plugin descendent it will be inserted in Engine's list (see the Plugin constructor).
A library may implement more than 1 Plugin descendent.
When a new library is loaded the Engine will call Plugin::initialize() for all loaded plugins.

What doo you mean by "How can two completely different plugins interfere with each other while they're doing different things"?

feredi

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Plugin vs Module
« Reply #2 on: June 03, 2015, 04:45:46 AM »
When a new library is loaded the Engine will call Plugin::initialize() for all loaded plugins.
Hi,

So I understand now why all other plugins are reloaded when I want to load my plugin. At first place I thought my code is causing some interference with other plugins causing them to get reloaded. However, what's the point in calling initialize for all loaded plugins every time a new plugin is loaded?

Thanks

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Plugin vs Module
« Reply #3 on: June 03, 2015, 05:08:01 AM »
Some other plugin may need a service provided by the new one.
The initialize() method is the best place to check some other module availability (by sending a message and check the rsponse).