NAME

Data::Sofu::Reference - A Sofu Reference


DESCRIPTION

Provides a interface similar to the original SofuD (sofu.sf.net).

References present a transparent interface to the object referenced. Normally they shouldn't even bother you one bit.


Synopsis

        require Data::Sofu::Map;
        require Data::Sofu::Reference;
        my $map = Data::Sofu::Map->new();
        $map->setAttribute("myself",Data::Sofu::Reference->new($map)); #Reference to itself.
        $map->map("myself"); #Will return $map not the Reference.
        $map->object("myself")->asReference(); #Will return the Reference.
        $map->object("myself")->asMap(); #will return the Map.
        $map->object("myself")->isMap(); #True
        $map->map("myself")->isMap(); #Also true
        $map->object("myself")->isReference(); #True
        $map->map("myself")->isReference(); #false (you skipped the reference when using map());
        #You can also:
        my $map = Data::Sofu::Map->new();
        $map->setAttribute("myself",$map); #Will be converted to Reference as soon as it is written to a file or string.


SYNTAX

This Module is pure OO, exports nothing


METHODS

Also look at Data::Sofu::Object for methods, cause Reference inherits from it

new([DATA]) Creates a new Data::Sofu::Reference and returns it

        $ref = Data::Sofu::Reference->new("->myself"); #Tree form, not valid (just for saving data)
        my $map = Data::Sofu::Map->new();
        $ref = Data::Sofu::Reference->new($map); #Valid

dangle([Data])

Changes the target of the Reference to Data

valid()

Return 1 if the Reference is there and points to something that is a Data::Sofu::Object

isValid()

Return 1 if the Reference is there and points to something that is a Data::Sofu::Object

isReference()

Returns 1

follow()

Returns the referenced object, valid or not.

asValue()

Returns the referenced objects asValue() call.

Which Returns either the referenced object or throws an exception

asMap()

Returns the referenced objects asMap() call.

Which Returns either the referenced object or throws an exception

asList()

Returns the referenced objects asList() call.

Which Returns either the referenced object or throws an exception

isList()

Returns 1 if the Reference is valid and the referenced Object is a List.

isValue()

Returns 1 if the Reference is valid and the referenced Object is a Value.

isMap()

Returns 1 if the Reference is valid and the referenced Object is a Map.

isDefined()

Returns 1 if the Reference is valid and the referenced Object is defined (i.e. not a Data::Sofu::Undefined).

asReference()

Returns itself


BUGS

Referencing something else than a Data::Sofu::Object or derieved will not convert the referenced thing and it will confuse the write() to produce invalid sofu files.


SEE ALSO

the Data::Sofu manpage, the Data::Sofu::Value manpage, the Data::Sofu::Object manpage, the Data::Sofu::Map manpage, the Data::Sofu::Value manpage, the Data::Sofu::Undefined manpage, http://sofu.sf.net