NAME

Tangence::Object - base class for accessible objects in a Tangence server

DESCRIPTION

This class acts as a base class for the accessible objects in a Tangence server. All the objects actually created and made accessible to clients will be subclasses of this one, including internally-created objects such as Tangence::Registry.

These objects are not directly constructed by calling the new class method; instead the Tangence::Registry should be used to construct one.

METHODS

destroy

$obj->destroy

Requests that the object destroy itself, informing all clients that are aware of it. Once they all report that they have dropped the object, the object is deconstructed for real.

Not to be confused with Perl's own DESTROY method.

id

$id = $obj->id

Returns the object's Tangence ID number

describe

$description = $obj->describe

Returns a textual description of the object, for internal debugging purposes. Subclasses are encouraged to override this method to return something more descriptive within their domain of interest

registry

$registry = $obj->registry

Returns the Tangence::Registry that constructed this object.

class

$class = $obj->class

Returns the Tangence::Meta::Class object representing the class of this object.

can_method

$method = $obj->can_method( $name )

Returns the Tangence::Meta::Method object representing the named method, or undef if no such method exists.

can_event

$event = $obj->can_event( $name )

Returns the Tangence::Meta::Event object representing the named event, or undef if no such event exists.

can_property

$property = $obj->can_property( $name )

Returns the Tangence::Meta::Property object representing the named property, or undef if no such property exists.

fire_event

$obj->fire_event( $event, @args )

Fires the named event on the object. Each event subscription function will be invoked with the given arguments.

subscribe_event

$id = $obj->subscribe_event( $event, $callback )

Subscribes an event-handling callback CODE ref to the named event. When the event is fired by fire_event this callback will be invoked, being passed the object reference and the event's arguments.

$callback->( $obj, @args )

Returns an opaque ID value that can be used to remove this subscription by calling unsubscribe_event.

unsubscribe_event

$obj->unsubscribe_event( $event, $id )

Removes an event-handling callback previously registered with subscribe_event.

watch_property

$id = $obj->watch_property( $prop, %callbacks )

Watches a named property for changes, registering a set of callback functions to be invoked when the property changes in certain ways. The set of callbacks required depends on the dimension of the property being watched.

For all property types:

$on_set->( $obj, $value )

For hash properties:

$on_add->( $obj, $key, $value )
$on_del->( $obj, $key )

For queue properties:

$on_push->( $obj, @values )
$on_shift->( $obj, $count )

For array properties:

$on_push->( $obj, @values )
$on_shift->( $obj, $count )
$on_splice->( $obj, $index, $count, @values )
$on_move->( $obj, $index, $delta )

For objset properties:

$on_add->( $obj, $added_object )
$on_del->( $obj, $deleted_object_id )

Alternatively, a single callback may be installed that is invoked after any change of the property, being passed the new value entirely:

$on_updated->( $obj, $value )

Returns an opaque ID value that can be used to remove this watch by calling unwatch_property.

unwatch_property

$obj->unwatch_property( $prop, $id )

Removes the set of callback functions previously registered with watch_property.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>