Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

# openvrml::event_emitter Class Reference

Abstract base class of event emitters. More...

`#include <openvrml/event.h>`

Inheritance diagram for openvrml::event_emitter:
[legend]

List of all members.

## Public Types

typedef std::set < event_listener * > | listener_set
| Set of `event_listeners`.

## Public Member Functions

virtual | ~event_emitter ()=0 throw ()
| Destroy.
const field_value & | value () const throw ()
| A reference to the `field_value` for the `event_emitter`.
const std::string | eventout_id () const throw ()
| The associated `eventOut` identifier.
double | last_time () const throw ()
| The timestamp of the last event emitted.
template<typename FieldValue >
bool | add (field_value_listener< FieldValue > &listener) throw ( std::bad_alloc )
| Add an event listener.
template<typename FieldValue >
bool | remove (field_value_listener< FieldValue > &listener) throw ()
| Remove an event listener.

## Protected Member Functions

| event_emitter (const field_value &value) throw ()
| Construct.
template<typename FieldValue >
void | emit_event (double timestamp) throw ( std::bad_alloc )
| Emit an event.

## Private Member Functions

virtual const std::string | do_eventout_id () const =0 throw ()
| The associated `eventOut` identifier.
virtual void | emit_event (double timestamp)=0 throw ( std::bad_alloc )

## Private Attributes

const field_value & | value_
| A reference to the `field_value` for the `event_emitter`.
std::set< event_listener * > | listeners_
| The listeners registered for this emitter.
boost::shared_mutex | listeners_mutex_
| Mutex guarding `listeners_`.
double | last_time_
| The timestamp of the last event emitted.
boost::shared_mutex | last_time_mutex_
| Mutex guarding `last_time_`.

## Friends

class | node
| The implementation of `node` calls `event_emitter::emit_event`.

## Detailed Description

Abstract base class of event emitters.

## Member Typedef Documentation

openvrml::event_emitter::listener_set

Set of `event_listeners`.

## Constructor & Destructor Documentation

openvrml::event_emitter::~event_emitter | ( |  | ) | throw ()`[pure virtual]`

Destroy.

Implemented in openvrml::node_impl_util::abstract_node< Derived >::event_emitter< FieldValue >.

openvrml::event_emitter::event_emitter | ( | const field_value & | value | ) | throw ()`[explicit, protected]`

Construct.

Parameters:

  `[in]` | value | `field_value` associated with this emitter.

## Member Function Documentation

const openvrml::field_value & openvrml::event_emitter::value | ( |  | ) | const throw ()

A reference to the `field_value` for the `event_emitter`.

Returns:
  a reference to the `field_value` for the `event_emitter`.

const std::string openvrml::event_emitter::eventout_id | ( |  | ) | const throw ()

The associated `eventOut` identifier.

This function delegates to `event_emitter::do_eventout_id`.

Returns:
  the associated `eventOut` identifier.

double openvrml::event_emitter::last_time | ( |  | ) | const throw ()

The timestamp of the last event emitted.

Returns:
  the timestamp of the last event emitted.

template<typename FieldValue >

bool openvrml::event_emitter::add | ( | field_value_listener< FieldValue > & | listener | ) | throw ( std::bad_alloc )`[inline]`

Add an event listener.

Template Parameters:

  | FieldValue | a Field Value.

Parameters:

  `[in]` | listener | an event listener.

Exceptions:

  | std::bad_alloc | if memory allocation fails.

Reimplemented in openvrml::field_value_emitter< FieldValue >.

template<typename FieldValue >

bool openvrml::event_emitter::remove | ( | field_value_listener< FieldValue > & | listener | ) | throw ()`[inline]`

Remove an event listener.

Template Parameters:

  | FieldValue | a Field Value.

Parameters:

  `[in]` | listener | an event listener.

Reimplemented in openvrml::field_value_emitter< FieldValue >.

template<typename FieldValue >

void openvrml::event_emitter::emit_event | ( | double | timestamp | ) | throw ( std::bad_alloc )`[inline, protected]`

Emit an event.

Template Parameters:

  | FieldValue | a Field Value.

Parameters:

  `[in]` | timestamp | the current time.

Exceptions:

  | std::bad_alloc | if memory allocation fails.

Parameters:

  `[in]` | timestamp | the current time.

Exceptions:

  | std::bad_alloc | if memory allocation fails.

This function is called by `node::emit_event`.

Reimplemented in openvrml::field_value_emitter< FieldValue >, openvrml::field_value_emitter< mfstring >, and openvrml::field_value_emitter< sfnode >.

const std::string openvrml::event_emitter::do_eventout_id | ( |  | ) | const throw ()`[private, pure virtual]`

The associated `eventOut` identifier.

Concrete subclasses must implement this function.

Returns:
  the associated eventOut identifier.

Implemented in openvrml::node_impl_util::event_emitter_base< Node >, openvrml::script_node::url_changed_emitter, openvrml::script_node::metadata_changed_emitter, and openvrml::node_impl_util::event_emitter_base< Derived >.

## Friends And Related Function Documentation

class openvrml::event_emitter::node`[friend]`

The implementation of `node` calls `event_emitter::emit_event`.

The only things that should be emitting events are `nodes`. Subclasses of `node` should call `node::emit_event` to emit an event.

## Member Data Documentation

const openvrml::field_value & openvrml::event_emitter::value_`[private]`

A reference to the `field_value` for the `event_emitter`.

For internal use only.

openvrml::event_emitter::listener_set openvrml::event_emitter::listeners_`[private]`

The listeners registered for this emitter.

For internal use only.

When `emit_event` is called, each of the registered listeners will be sent an event.

boost::shared_mutex openvrml::event_emitter::listeners_mutex_`[mutable, private]`

Mutex guarding `listeners_`.

For internal use only.

double openvrml::event_emitter::last_time_`[private]`

The timestamp of the last event emitted.

For internal use only.

boost::shared_mutex openvrml::event_emitter::last_time_mutex_`[mutable, private]`

Mutex guarding `last_time_`.

For internal use only.