diff Lib/Form/ItemId.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children 16ada169ca75
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/Form/ItemId.pm	Tue Jul 14 12:54:37 2009 +0400
@@ -0,0 +1,46 @@
+package Form::ItemId;
+use strict;
+use Common;
+our @ISA = qw(Object);
+
+BEGIN {
+    DeclareProperty Name => ACCESS_READ;
+    DeclareProperty Canonical => ACCESS_READ;
+    DeclareProperty InstanceID => ACCESS_READ;
+    DeclareProperty Parent => ACCESS_READ;
+}
+
+sub CTOR {
+    my ($this,$name,$instance_id,$parent) = @_;
+    
+    $this->{$Name} = $name or die new Exception('A name is required for the item id');
+    $this->{$InstanceID} = $instance_id;
+    $this->{$Parent} = $parent;
+    
+    $this->{$Canonical} = ($parent && !$parent->isa('Form::ItemId::Root') ? $parent->Canonical.'/':'').$name.(defined $instance_id ? $instance_id : '');
+}
+
+sub ToNAVPath {
+    my ($this) = @_;
+    
+    return ($this->{$Parent} ? ($this->{$Parent}->ToNAVPath,$this) : $this);
+}
+
+package Form::ItemId::Prev;
+our @ISA = qw(Form::ItemId);
+
+sub CTOR {
+    my ($this,$parent) = @_;
+    $this->SUPER::CTOR('(prev)',undef,$parent);
+}
+
+package Form::ItemId::Root;
+our @ISA = qw(Form::ItemId);
+
+sub CTOR {
+    my ($this,$parent) = @_;
+    $this->SUPER::CTOR('(root)',undef,$parent);
+}
+
+
+1;