neuray Services API Programmer's Manual

mi::nservices::IEvent_context Class Reference

[Events]

Description

The event context. This is the central interface to the neuray services event system. Here we can register and remove event handlers and generate and trigger events.

Public Member Functions

virtual IMapget_attachments() const =0
Retrieves the global attachment object. More...
virtual IFactoryget_factory() const =0
Returns a factory, may be used to create neuray services data and event objects. More...
virtual Sint32 register_handler( base::Uuid event_type, const char* event_handler_name, const char* name, Sint32 priority) =0
Registers an event handler. More...
virtual Sint32 remove_handler( base::Uuid event_type, const char* name) =0
Removes an existing event handler. More...
virtual Sint32 send_event( IEvent* event) =0
Send an event to all registered handlers. More...

Member Functions

virtual IMap* mi::​nservices::​IEvent_context::get_attachments() const [pure virtual]

Retrieves the global attachment object.

Returns

an object with which to manipulate attachments

virtual IFactory* mi::​nservices::​IEvent_context::get_factory() const [pure virtual]

Returns a factory, may be used to create neuray services data and event objects.

Returns

a factory

virtual Sint32 mi::​nservices::​IEvent_context::register_handler( base::Uuid event_type, const char* event_handler_name, const char* name, Sint32 priority) [pure virtual]

Registers an event handler. Event handlers only exist for the lifetime of this event context. If multiple handlers are registered for an event they are triggered in priority order. Handlers at the same priority level are triggered in the order they were registered

Parameters

event_type
the event to handle
event_handler_name
the name of the event handler to register
name
the name to register the handler as
priority
the event priority. Events with lower priorities are executed before events with higher priorities. Note that negative priorites are reserved for internal use, users should always use a positive priority value.

Returns

  • NRS_ERROR_NONE : success.
  • NRS_ERROR_MEMORY : out of memory.
  • NRS_ERROR_INVALID_PARAMETERS : a parameter is NULL.
  • NRS_ERROR_INVALID_OPERATION : a handler called name is already registered.
  • NRS_ERROR_EVENT_HANDLER_NAME_INVALID : event_handler_name is not a known event handler.

virtual Sint32 mi::​nservices::​IEvent_context::remove_handler( base::Uuid event_type, const char* name) [pure virtual]

Removes an existing event handler.

Parameters

event_type
the event type we wish to remove
name
the name of the handler to remove

Returns

  • NRS_ERROR_NONE : success.
  • NRS_ERROR_INVALID_PARAMETERS : name is NULL.
  • NRS_ERROR_INVALID_OPERATION : if name is not a registered handler.

virtual Sint32 mi::​nservices::​IEvent_context::send_event( IEvent* event) [pure virtual]

Send an event to all registered handlers. This method will not return until all handlers have executed.

Parameters

event
the event to send

Returns

the return value of the last event handler or one of the following errors:

  • NRS_ERROR_MEMORY : out of memory.
  • NRS_ERROR_INVALID_PARAMETERS : event is NULL.
  • NRS_ERROR_EVENT_NO_HANDLERS : no handlers registered for this event type.
  • NRS_ERROR_FAILED : internal error.