diff Lib/Schema/Form/Container.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/Schema/Form/Container.pm	Tue Jul 14 12:54:37 2009 +0400
@@ -0,0 +1,41 @@
+package Schema::Form::Container;
+use Form::Container;
+use Common;
+use base qw(Schema::Form::Item);
+
+BEGIN {
+    DeclareProperty Children => ACCESS_READ;
+}
+
+sub CTOR {
+    my ($this,%args) = @_;
+    
+    $this->SUPER::CTOR(@args{qw(Name isMulti Filters)});
+    
+    $this->{$Children} = [];
+    
+}
+
+sub AddChild {
+    my ($this,$child) = @_;
+    
+    not grep { $_->Name eq $child->Name } $this->Children or die new Exception("The item already exists",$child->Name);
+    
+    push @{$this->{$Children}},$child;
+}
+
+sub FindChild {
+    my ($this,$name) = @_;
+    
+    my @result = grep { $_->Name eq $name} $this->Children;
+    return $result[0];
+}
+
+sub Dispose {
+    my ($this) = @_;
+    
+    delete $this->{$Children};
+    
+    $this->SUPER::Dispose;
+}
+1;
\ No newline at end of file