annotate Lib/Form/ItemId.pm @ 24:7f00786f8210

Первая рабочая реазизация схемы и навигаторов
author Sergey
date Mon, 05 Oct 2009 00:48:49 +0400
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package Form::ItemId;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 our @ISA = qw(Object);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 BEGIN {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 DeclareProperty Name => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 DeclareProperty Canonical => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 DeclareProperty InstanceID => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 DeclareProperty Parent => ACCESS_READ;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 my ($this,$name,$instance_id,$parent) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 $this->{$Name} = $name or die new Exception('A name is required for the item id');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 $this->{$InstanceID} = $instance_id;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 $this->{$Parent} = $parent;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 $this->{$Canonical} = ($parent && !$parent->isa('Form::ItemId::Root') ? $parent->Canonical.'/':'').$name.(defined $instance_id ? $instance_id : '');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 sub ToNAVPath {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 return ($this->{$Parent} ? ($this->{$Parent}->ToNAVPath,$this) : $this);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 package Form::ItemId::Prev;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 our @ISA = qw(Form::ItemId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 my ($this,$parent) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 $this->SUPER::CTOR('(prev)',undef,$parent);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 package Form::ItemId::Root;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
38 our @ISA = qw(Form::ItemId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
40 sub CTOR {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
41 my ($this,$parent) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
42 $this->SUPER::CTOR('(root)',undef,$parent);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
43 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
44
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 1;