our
$VERSION
=
'0.002'
;
sub
new {
my
$this
=
shift
->X3DUniversal::new;
my
(
$sourceNode
,
$sourceFieldId
,
$destinationNode
,
$destinationFieldId
) =
@_
;
my
$sourceField
=
$sourceNode
->getValue->getField(
$sourceFieldId
);
if
(
ref
$sourceField
)
{
my
$destinationField
=
$destinationNode
->getValue->getField(
$destinationFieldId
);
if
(
ref
$destinationField
)
{
if
(
$sourceField
->getType eq
$destinationField
->getType )
{
$this
->{sourceNode} =
$sourceNode
;
$this
->{sourceField} =
$sourceField
;
$this
->{destinationNode} =
$destinationNode
;
$this
->{destinationField} =
$destinationField
;
$sourceField
->addFieldCallback(
$destinationField
);
return
$this
;
}
else
{
Carp::croak
"ROUTE types do not match\n"
,
"Bad ROUTE specification\n"
;
}
}
else
{
my
$destinationNodeId
=
$destinationNode
->getName;
Carp::croak
"Unknown destination field \"$destinationFieldId\" in node \"$destinationNodeId\"\n"
,
"Bad ROUTE specification\n"
;
}
}
else
{
my
$sourceNodeId
=
$sourceNode
->getName;
Carp::croak
"Unknown source field \"$sourceFieldId\" in node \"$sourceNodeId\"\n"
,
"Bad ROUTE specification\n"
;
}
return
;
}
sub
getSourceNode {
$_
[0]->{sourceNode} }
sub
getSourceField {
$_
[0]->{sourceField} }
sub
getDestinationNode {
$_
[0]->{destinationNode} }
sub
getDestinationField {
$_
[0]->{destinationField} }
sub
deleteRoute {
my
$this
=
shift
;
$this
->{eventOut}->deleteRoute(
$this
->{eventIn} );
}
sub
toString {
my
$this
=
shift
;
my
$string
=
""
;
$string
.= X3DGenerator->ROUTE;
$string
.= X3DGenerator->space;
$string
.=
$this
->{sourceNode}->getValue->getName;
$string
.= X3DGenerator->period;
$string
.=
$this
->{sourceField}->getName;
$string
.= X3DGenerator->space;
$string
.= X3DGenerator->TO;
$string
.= X3DGenerator->space;
$string
.=
$this
->{destinationNode}->getValue->getName;
$string
.= X3DGenerator->period;
$string
.=
$this
->{destinationField}->getName;
return
$string
;
}
1;