Workspace 7.0.2
Classes | Namespaces | Macros
observableevent.h File Reference
#include <QString>
#include "Workspace/api_workspace.h"
Include dependency graph for observableevent.h:
This graph shows which files directly or indirectly include this file:

Classes

class  AllObservableEvents
 Special event type for observers to use when they want all events, not just a specific event type. More...
 
class  EventID
 Subclassed and instantiated exactly once for each event type. More...
 
class  EventIDSingleton< T >
 
class  ObservableEvent
 Each instance of an ObservableEvent subclass can be used as a unique event designator. More...
 
class  ObservableEventType< T >
 All events must be a subclass of this template. More...
 

Namespaces

namespace  CSIRO
 Top level namespace for all Workspace code.
 
namespace  CSIRO::DataExecution
 Base workspace functionality not requiring a user interface.
 

Macros

#define DECLARE_WORKSPACE_EVENT_INSTANCE(T, WORKSPACE_EXPORT_SYMBOL)
 
#define DEFINE_WORKSPACE_EVENT_INSTANCE(T)
 
#define DEFINE_WORKSPACE_EVENT_INSTANCE_LOCAL(T)
 

Macro Definition Documentation

◆ DECLARE_WORKSPACE_EVENT_INSTANCE

#define DECLARE_WORKSPACE_EVENT_INSTANCE (   T,
  WORKSPACE_EXPORT_SYMBOL 
)
Value:
namespace CSIRO \
{ \
namespace DataExecution \
{ \
template<> \
WORKSPACE_EXPORT_SYMBOL const EventIDSingleton<T>& ObservableEventType<T>::eventID(); \
} \
}
static const EventIDSingleton< T > & eventID()
Top level namespace for all Workspace code.
Definition: applicationsupportplugin.cpp:32
Parameters
TThe event class you want to declare the event instance for. It should include the full namespace scope if nested within a workspace rather than relying on using namespace ... directives.
WORKSPACE_EXPORT_SYMBOLThe export symbol for the plugin. See the documentation for DECLARE_WORKSPACE_DATA_FACTORY for more detail about what this means. The workings of the two DECLARE_... and DEFINE_... macros for event instances is similar to those for the data factories.

Only use this in header files. It normally appears at the bottom of the header defining the event class T.

◆ DEFINE_WORKSPACE_EVENT_INSTANCE

#define DEFINE_WORKSPACE_EVENT_INSTANCE (   T)
Value:
namespace CSIRO \
{ \
namespace DataExecution \
{ \
template<> \
/* The two sets of brackets around #T is a workaround for */ /* the "most vexing parse". It breaks early gcc versions */ /* but appears to be okay at least from 4.1.0 onwards. */ \
EventIDSingleton<T> EventIDSingleton<T>::singleton_((#T)); \
template<> \
CSIRO_EXPORTSPEC const EventIDSingleton<T>& ObservableEventType<T>::eventID() \
{ \
return EventIDSingleton<T>::singleton_; \
} \
} \
}
#define CSIRO_EXPORTSPEC
Definition: api_workspace.h:80
Parameters
TThe event class you want to define the event instance for. It should include the full namespace scope if nested within a workspace rather than relying on using namespace ... directives.

This macro is analogous to DEFINE_WORKSPACE_DATA_FACTORY. It does for event classes what DEFINE_WORKSPACE_DATA_FACTORY does for data factories. It ensures that there is only one instance of the EventID subclass for the event type T.

◆ DEFINE_WORKSPACE_EVENT_INSTANCE_LOCAL

#define DEFINE_WORKSPACE_EVENT_INSTANCE_LOCAL (   T)
Value:
namespace CSIRO \
{ \
namespace DataExecution \
{ \
template<> \
/* The two sets of brackets around #T is a workaround for */ /* the "most vexing parse". It breaks early gcc versions */ /* but appears to be okay at least from 4.1.0 onwards. */ \
EventIDSingleton<T> EventIDSingleton<T>::singleton_((#T)); \
template<> \
CSIRO_LOCALSPEC const EventIDSingleton<T>& ObservableEventType<T>::eventID() \
{ \
return EventIDSingleton<T>::singleton_; \
} \
} \
}
#define CSIRO_LOCALSPEC
Definition: api_workspace.h:81

This is entirely analogous to the DEFINE_WORKSPACE_EVENT_INSTANCE macro except that the event cannot be used outside of the plugin in which it is defined. This is because the ObservableEventType<T>::eventID() function is not exported to the public interface of the plugin, which can be useful if multiple plugins define the same event class but need to operate on different instances (this situation arises when event classes are defined in static libraries which are linked to by multiple workspace plugins). Even though there is a getEventID() function in the event class itself, this still cannot be used to get to the EventID instance because its implementation still relies on calling eventID(). Thus, only code within the plugin can call it and as a result no code outside the plugin can get the event ID to be able to observe it.