Functions for implementing a Space Observer to monitor changes to a Space from C.
More...
Functions for implementing a Space Observer to monitor changes to a Space from C.
Space Observers permit code to monitor activity within a Space by receiving events. Additionally, custom Space implementations must notify all observers by broadcasting events to communicate activity within the space.
◆ space_event_field_t
Accessor constants, to access the fields of a space_event_t
| Enumerator |
|---|
| SPACE_EVENT_FIELD_ADD | Access the atom field of an Add event.
|
| SPACE_EVENT_FIELD_REMOVE | Access the atom field of a Remove event.
|
| SPACE_EVENT_FIELD_REPLACE_PATTERN | Access the pattern field of a Replace event.
|
| SPACE_EVENT_FIELD_REPLACE_TEMPLATE | Access the template field of a Replace event.
|
◆ space_event_type_t
Represents different types of Space Events.
| Enumerator |
|---|
| SPACE_EVENT_TYPE_ADD | The event is an Add event.
|
| SPACE_EVENT_TYPE_REMOVE | The event is a Remove event.
|
| SPACE_EVENT_TYPE_REPLACE | The event is a Replace event.
|
◆ space_event_get_field_atom()
Accesses the atom associated with a field of a space_event_t
- Parameters
-
| [in] | event | A pointer to the event to access |
| [in] | field | A space_event_field_t specifying which field to access |
- Returns
- An atom_ref_t referencing the specified atom within the event
- Warning
- The returned atom_ref_t is borrowed from the space_event_t, and it must not be modified or accessed after the event has been freed
◆ space_event_get_type()
Gets the type of a Space Event.
- Parameters
-
| [in] | event | A pointer to the event to inspect |
- Returns
- The type of the event
◆ space_observer_free()
Frees a space_observer_t
- Parameters
-
- Note
- Freeing a Space Observer will atomatically de-register it with its associated space
◆ space_observer_get_payload()
Returns a pointer to the payload associated with the space_observer_t.
- Parameters
-
- Returns
- A pointer to the payload object associated with the Space Observer
- Warning
- The returned pointer must not be accessed after the space_observer_t has been freed, or after any operations have occurred that may have caused events to occur in the associated space
-
The returned pointer should never be freed directly. Call space_observer_free() when you are finished with the observer
◆ space_register_observer()
Registers a new observer, to monitor activity within the Space.
- Parameters
-
| [in] | space | A pointer to the space_t handle of the space to observe |
| [in] | observer_api | A pointer to the table of functions that implement the observer's behavior |
| [in] | observer_payload | A pointer to a caller-defined object usable by the observer's implementation functions |
- Returns
- A space_observer_t created to observe the space
- Note
- The caller must take ownership responsibility for the returned space_observer_t, and it must be freed with space_observer_free()
- Warning
- This function takes ownership of the observer_payload, and it should not be freed after it has been provided to this function