SlideShare una empresa de Scribd logo
1 de 28
Event dispatching in MAF v3
Summary
Why creating an event bus?
Event Bus inside MAF3 Architecture
Characteristics
How register a signal and a callback
Local vs Remote Dispatching.
2
Event Bus - Reasons
Communication between modules
Independency between modules
Need of flexibility
3
MAF3 Architecture
4
Communication
There are several types of communication:
Publish-Subscribe: Modules may subscribe to certain
message types. Whenever a module publishes a message
to the bus, it will be delivered to all modules that
subscribed to its message type.
Broadcast: The message will be delivered to all (other)
modules.
Point-to-point: The message has one and only one
recipient.
5
Examples of Event Bus
Enterprise Service Bus:
6
D-Bus
Mbus
http://www.mbus.org/
Signal/Slot
7
Characteristics
mafEventBus is based on Signal/Slot connecting
mechanism implemented in Qt.
Extends the Qt mechanism to allow connection also at
run-time without to include the class that define the signal
with which the connection has to be established.
Can manage local to the application or remote events
through mafEventDispatcher exchanging event
information written into the mafEvent token.
Remote connection can be managed with different
extensible protocols through mafNetworkConnector.
Event filtering by topic.
Independent from mafCore.
Patterns involved
Façade
The class mafEventBusManager allows to access all
the functionalities of event emit and observe
registration/notification.
Observer
An event must be registered with its Topic as
signal or callback without a specific order.
A topic represents an unique string associated with
one signal.
Event Topic Taxonomy
1023
maf.local.resources.viewManager.create
Reverse DNS notation:
How it works (Basic)
Register in the Bus any Signal Emitter.
Register in the Bus any Callback associating it
to a particular Topic to observe.
Notify through the Bus an event (local or
remote) to update all the observers (with or
without arguments and return values)
Only QObjects (or inherited class) can be a
signal emitter or observer due to the
signal/slot mechanism used into the bus.
Register
Signal
Attach the
Observer/s
Notify
Events
How It Works (Remote side)
Remote notification are achieved by asking the
bus module to create a client for the given
remote communication protocol: “XMLRPC”,
“SOAP”…
Network protocols are extensible through the
plug of new mafNetworkConnector into the
mafEventBusManager:
plugNetworkConnector("SOAP", new mafNetworkConnectorQtSoap());
All these steps are accessible through the
mafEventBusManager façade class.
mafEvent
Class for storing information into a QHash.
Into the hash stores keys and values related to the
event to be notified.
Define some API to simplify the access of the event
information stored into the hash.
Signal Emitter
Register as a signal emitter:
Create a Qt Signal inside the class header used as a
signal emitter.
Define a string topic to associate to a signal.
Register to the Event Bus as emitter using the
mafRegisterLocalSignal or
mafRegisterRemoteSignal macros or giving to the
mafEventBusManager (through the call of
addEventProperty method) the mafEvent filled with
proper information.
Register as Signal Emitter
In your .h file define the signal:
...
signals:
void loadPluginLibrary(const mafString &pluginFilename);
...
… then in .cpp create the topic and register the
signal into the Event Bus:
mafString load_library_topic =
“maf.local.resources.pluginManager.loadPlugin”;
mafRegisterLocalSignal(load_library_topic, this,
"loadPluginLibrary(const mafString &)");
Observer
Register as Observer:
Define a Qt slot into the class that wants to become an
observer.
Register that slot in the bus associating it with a Signal
through the predefined topic through the macro
mafRegisterLocalCallback or giving to the
mafEventBusManager (through the call of
addEventProperty method) the mafEvent filled with
proper information.
Register as Observer
In your .h file define the slot:
public slots:
/// Loads a plugin
void loadPlugin(const mafString &pluginFilename);
… then in .cpp register it into the Event Bus:
mafRegisterLocalCallback(“maf.local.resources.pluginManager.loadPlugi
n”, this, "loadPlugin(const mafString &)");
Notify an Event
Event Notification can be done in three different way:
No Arguments and No Return Value
With Arguments and No Return Value
With Arguments and With Return Value
Notification with
No Argument and No return value
Get the mafEventBusManager instance:
mafEventBusManager *m_EventBus = mafEventBusManager::instance();
Send the notification for a given topic:
m_EventBus->notifyEvent("maf.local.eventBus.globalUpdate");
Notification with
Arguments and No Return Value
Create the list of arguments to send through the
notification:
mafEventArgumentsList arglist;
mafEventGenericArgument value = mafEventArgument(int, 35)
arglist.append(value);
Notify the event associated to the topic:
m_EventBus->notifyEvent("maf.local.myTopic", mafEventTypeLocal,
&arglist);
Notification with
Arguments and Return Value
Create the list of argument (as before)
Create the placeholder for the Return Value
(here is show an ‘int’ return value):
mafEventArgumentsList arglist;
mafEventGenericArgument value = mafEventArgument(int, 35)
arglist.append(value);
int returnValue = 0;
Notify the event associated to the topic. The
return value will be present into the variable
after the call:
mafGenericReturnArgument ret_val =
mafEventReturnArgument(int,returnValue);
m_EventBus->notifyEvent("maf.local.myTopic", mafEventTypeLocal,
&arglist, &ret_val);
Remote Notification
Same as the three cases shown in the slides before,
but instead of mafEventTypeLocal, use
mafEventTypeRemote.
mafEventDispatcherRemote will be in charge of
dispatching those events through the
mafNetworkConnector.
Remote Notification
Remote Event Pack
The local call needs the flag mafEventTypeRemote
and a list of parameters containing:
information on the topic to be called by the remote
application on its Event Bus (called remote event
parameters)
related optional parameters (called remote data
parameters)
Remote Event Unpack
Remote application receive the list of parameters (Event
and Data Parameters).
Extract from the Event Parameter the ID to be called
locally.
Extract the Data Parameters to build the local Arguments
list for the new event.
Return to the caller application the connection result: Fail
or Ok which will cause the notification of the two related
events:
maf.local.eventBus.remoteCommunicationFailed
and
maf.local.eventBus.remoteCommunicationDone
References
MAF http://www.openmaf.org
Qt http://qt.nokia.com
Design Pattern http://sourcemaking.com/design_patterns
Thank You
Authors
Paolo Quadrani: p.quadrani@scsolutions.it
Daniele Giunchi: d.giunchi@scsolutions.it
Roberto Mucci: r.mucci@cineca.it

Más contenido relacionado

Similar a Event Dispatching in MAF v3: How to Register Signals and Callbacks

Azure Service Bus Performance Checklist
Azure Service Bus Performance ChecklistAzure Service Bus Performance Checklist
Azure Service Bus Performance ChecklistSalim M Bhonhariya
 
Iot hub agent
Iot hub agentIot hub agent
Iot hub agentrtfmpliz1
 
Observer design pattern
Observer design patternObserver design pattern
Observer design patternSameer Rathoud
 
INTERNET OF THINGS & AZURE
INTERNET OF THINGS & AZUREINTERNET OF THINGS & AZURE
INTERNET OF THINGS & AZUREDotNetCampus
 
Estendere applicazioni extbase
Estendere applicazioni extbaseEstendere applicazioni extbase
Estendere applicazioni extbaseCristian Buja
 
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...VMware Tanzu
 
WiMAX implementation in ns3
WiMAX implementation in ns3WiMAX implementation in ns3
WiMAX implementation in ns3Mustafa Khaleel
 
Ibm mq with c# sending and receiving messages
Ibm mq with c# sending and receiving messagesIbm mq with c# sending and receiving messages
Ibm mq with c# sending and receiving messagesShreesha Rao
 
quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqjorgesimao71
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI IntroductionRohit Banga
 
Android development training programme , Day 3
Android development training programme , Day 3Android development training programme , Day 3
Android development training programme , Day 3DHIRAJ PRAVIN
 

Similar a Event Dispatching in MAF v3: How to Register Signals and Callbacks (20)

Azure Service Bus Performance Checklist
Azure Service Bus Performance ChecklistAzure Service Bus Performance Checklist
Azure Service Bus Performance Checklist
 
mqttvsrest_v4.pdf
mqttvsrest_v4.pdfmqttvsrest_v4.pdf
mqttvsrest_v4.pdf
 
Iot hub agent
Iot hub agentIot hub agent
Iot hub agent
 
SignalR with asp.net
SignalR with asp.netSignalR with asp.net
SignalR with asp.net
 
Vb.net iv
Vb.net ivVb.net iv
Vb.net iv
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
INTERNET OF THINGS & AZURE
INTERNET OF THINGS & AZUREINTERNET OF THINGS & AZURE
INTERNET OF THINGS & AZURE
 
KAFKA Quickstart
KAFKA QuickstartKAFKA Quickstart
KAFKA Quickstart
 
Estendere applicazioni extbase
Estendere applicazioni extbaseEstendere applicazioni extbase
Estendere applicazioni extbase
 
Robotlegs Extensions
Robotlegs ExtensionsRobotlegs Extensions
Robotlegs Extensions
 
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
 
WiMAX implementation in ns3
WiMAX implementation in ns3WiMAX implementation in ns3
WiMAX implementation in ns3
 
Ibm mq with c# sending and receiving messages
Ibm mq with c# sending and receiving messagesIbm mq with c# sending and receiving messages
Ibm mq with c# sending and receiving messages
 
GNURAdioDoc-8
GNURAdioDoc-8GNURAdioDoc-8
GNURAdioDoc-8
 
GNURAdioDoc-8
GNURAdioDoc-8GNURAdioDoc-8
GNURAdioDoc-8
 
quickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmqquickguide-einnovator-3-rabbitmq
quickguide-einnovator-3-rabbitmq
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 
MPI
MPIMPI
MPI
 
Android development training programme , Day 3
Android development training programme , Day 3Android development training programme , Day 3
Android development training programme , Day 3
 
MPI
MPIMPI
MPI
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Event Dispatching in MAF v3: How to Register Signals and Callbacks

  • 2. Summary Why creating an event bus? Event Bus inside MAF3 Architecture Characteristics How register a signal and a callback Local vs Remote Dispatching. 2
  • 3. Event Bus - Reasons Communication between modules Independency between modules Need of flexibility 3
  • 5. Communication There are several types of communication: Publish-Subscribe: Modules may subscribe to certain message types. Whenever a module publishes a message to the bus, it will be delivered to all modules that subscribed to its message type. Broadcast: The message will be delivered to all (other) modules. Point-to-point: The message has one and only one recipient. 5
  • 6. Examples of Event Bus Enterprise Service Bus: 6 D-Bus Mbus http://www.mbus.org/
  • 8. Characteristics mafEventBus is based on Signal/Slot connecting mechanism implemented in Qt. Extends the Qt mechanism to allow connection also at run-time without to include the class that define the signal with which the connection has to be established. Can manage local to the application or remote events through mafEventDispatcher exchanging event information written into the mafEvent token. Remote connection can be managed with different extensible protocols through mafNetworkConnector. Event filtering by topic. Independent from mafCore.
  • 9. Patterns involved Façade The class mafEventBusManager allows to access all the functionalities of event emit and observe registration/notification. Observer An event must be registered with its Topic as signal or callback without a specific order. A topic represents an unique string associated with one signal.
  • 11. How it works (Basic) Register in the Bus any Signal Emitter. Register in the Bus any Callback associating it to a particular Topic to observe. Notify through the Bus an event (local or remote) to update all the observers (with or without arguments and return values) Only QObjects (or inherited class) can be a signal emitter or observer due to the signal/slot mechanism used into the bus.
  • 13. How It Works (Remote side) Remote notification are achieved by asking the bus module to create a client for the given remote communication protocol: “XMLRPC”, “SOAP”… Network protocols are extensible through the plug of new mafNetworkConnector into the mafEventBusManager: plugNetworkConnector("SOAP", new mafNetworkConnectorQtSoap()); All these steps are accessible through the mafEventBusManager façade class.
  • 14. mafEvent Class for storing information into a QHash. Into the hash stores keys and values related to the event to be notified. Define some API to simplify the access of the event information stored into the hash.
  • 15. Signal Emitter Register as a signal emitter: Create a Qt Signal inside the class header used as a signal emitter. Define a string topic to associate to a signal. Register to the Event Bus as emitter using the mafRegisterLocalSignal or mafRegisterRemoteSignal macros or giving to the mafEventBusManager (through the call of addEventProperty method) the mafEvent filled with proper information.
  • 16. Register as Signal Emitter In your .h file define the signal: ... signals: void loadPluginLibrary(const mafString &pluginFilename); ... … then in .cpp create the topic and register the signal into the Event Bus: mafString load_library_topic = “maf.local.resources.pluginManager.loadPlugin”; mafRegisterLocalSignal(load_library_topic, this, "loadPluginLibrary(const mafString &)");
  • 17. Observer Register as Observer: Define a Qt slot into the class that wants to become an observer. Register that slot in the bus associating it with a Signal through the predefined topic through the macro mafRegisterLocalCallback or giving to the mafEventBusManager (through the call of addEventProperty method) the mafEvent filled with proper information.
  • 18. Register as Observer In your .h file define the slot: public slots: /// Loads a plugin void loadPlugin(const mafString &pluginFilename); … then in .cpp register it into the Event Bus: mafRegisterLocalCallback(“maf.local.resources.pluginManager.loadPlugi n”, this, "loadPlugin(const mafString &)");
  • 19. Notify an Event Event Notification can be done in three different way: No Arguments and No Return Value With Arguments and No Return Value With Arguments and With Return Value
  • 20. Notification with No Argument and No return value Get the mafEventBusManager instance: mafEventBusManager *m_EventBus = mafEventBusManager::instance(); Send the notification for a given topic: m_EventBus->notifyEvent("maf.local.eventBus.globalUpdate");
  • 21. Notification with Arguments and No Return Value Create the list of arguments to send through the notification: mafEventArgumentsList arglist; mafEventGenericArgument value = mafEventArgument(int, 35) arglist.append(value); Notify the event associated to the topic: m_EventBus->notifyEvent("maf.local.myTopic", mafEventTypeLocal, &arglist);
  • 22. Notification with Arguments and Return Value Create the list of argument (as before) Create the placeholder for the Return Value (here is show an ‘int’ return value): mafEventArgumentsList arglist; mafEventGenericArgument value = mafEventArgument(int, 35) arglist.append(value); int returnValue = 0; Notify the event associated to the topic. The return value will be present into the variable after the call: mafGenericReturnArgument ret_val = mafEventReturnArgument(int,returnValue); m_EventBus->notifyEvent("maf.local.myTopic", mafEventTypeLocal, &arglist, &ret_val);
  • 23. Remote Notification Same as the three cases shown in the slides before, but instead of mafEventTypeLocal, use mafEventTypeRemote. mafEventDispatcherRemote will be in charge of dispatching those events through the mafNetworkConnector.
  • 25. Remote Event Pack The local call needs the flag mafEventTypeRemote and a list of parameters containing: information on the topic to be called by the remote application on its Event Bus (called remote event parameters) related optional parameters (called remote data parameters)
  • 26. Remote Event Unpack Remote application receive the list of parameters (Event and Data Parameters). Extract from the Event Parameter the ID to be called locally. Extract the Data Parameters to build the local Arguments list for the new event. Return to the caller application the connection result: Fail or Ok which will cause the notification of the two related events: maf.local.eventBus.remoteCommunicationFailed and maf.local.eventBus.remoteCommunicationDone
  • 27. References MAF http://www.openmaf.org Qt http://qt.nokia.com Design Pattern http://sourcemaking.com/design_patterns
  • 28. Thank You Authors Paolo Quadrani: p.quadrani@scsolutions.it Daniele Giunchi: d.giunchi@scsolutions.it Roberto Mucci: r.mucci@cineca.it