Sfoglia il codice sorgente

Added isNull() method to event classes.

This can be used to check if the event is valid.
Sascha Zelzer 14 anni fa
parent
commit
b3e0e4a7a6

+ 5 - 0
Libs/PluginFramework/ctkPluginEvent.cpp

@@ -53,6 +53,11 @@ ctkPluginEvent::~ctkPluginEvent()
 
 }
 
+bool ctkPluginEvent::isNull() const
+{
+  return !d;
+}
+
 ctkPluginEvent::ctkPluginEvent(Type type, ctkPlugin* plugin)
   : d(new ctkPluginEventData(type, plugin))
 {

+ 9 - 0
Libs/PluginFramework/ctkPluginEvent.h

@@ -152,6 +152,15 @@ public:
   ~ctkPluginEvent();
 
   /**
+   * Can be used to check if this ctkPluginEvent instance is valid,
+   * or if it has been constructed using the default constructor.
+   *
+   * @return <code>true</code> if this event object is valid,
+   *         <code>false</code> otherwise.
+   */
+  bool isNull() const;
+
+  /**
    * Creates a plugin event of the specified type.
    *
    * @param type The event type.

+ 5 - 0
Libs/PluginFramework/ctkPluginFrameworkEvent.cpp

@@ -68,6 +68,11 @@ ctkPluginFrameworkEvent::~ctkPluginFrameworkEvent()
 
 }
 
+bool ctkPluginFrameworkEvent::isNull() const
+{
+  return !d;
+}
+
 ctkPluginFrameworkEvent::ctkPluginFrameworkEvent(Type type, ctkPlugin* plugin, const std::exception& fwException)
   : d(new ctkPluginFrameworkEventData(type, plugin, fwException.what()))
 {

+ 9 - 0
Libs/PluginFramework/ctkPluginFrameworkEvent.h

@@ -125,6 +125,15 @@ public:
   ~ctkPluginFrameworkEvent();
 
   /**
+   * Can be used to check if this ctkPluginFrameworkEvent instance is valid,
+   * or if it has been constructed using the default constructor.
+   *
+   * @return <code>true</code> if this event object is valid,
+   *         <code>false</code> otherwise.
+   */
+  bool isNull() const;
+
+  /**
    * Creates a Framework event regarding the specified plugin and exception.
    *
    * @param type The event type.

+ 5 - 0
Libs/PluginFramework/ctkServiceEvent.cpp

@@ -53,6 +53,11 @@ ctkServiceEvent::~ctkServiceEvent()
 
 }
 
+bool ctkServiceEvent::isNull() const
+{
+  return !d;
+}
+
 ctkServiceEvent::ctkServiceEvent(Type type, const ctkServiceReference& reference)
   : d(new ctkServiceEventData(type, reference))
 {

+ 9 - 0
Libs/PluginFramework/ctkServiceEvent.h

@@ -110,6 +110,15 @@ public:
   ~ctkServiceEvent();
 
   /**
+   * Can be used to check if this ctkServiceEvent instance is valid,
+   * or if it has been constructed using the default constructor.
+   *
+   * @return <code>true</code> if this event object is valid,
+   *         <code>false</code> otherwise.
+   */
+  bool isNull() const;
+
+  /**
    * Creates a new service event object.
    *
    * @param type The event type.