aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2005-10-19 10:18:44 +0000
committerdakkar <dakkar@luxion>2005-10-19 10:18:44 +0000
commitc212d75031ee8b5c87551b7f025e6224d1e7fd6e (patch)
treee850c106721ce7221c1ba4192151e34449d79094 /lib/WebCoso
parentaggiunto supporto per parent/child tra collezioni (diff)
downloadWebCoso-c212d75031ee8b5c87551b7f025e6224d1e7fd6e.tar.gz
WebCoso-c212d75031ee8b5c87551b7f025e6224d1e7fd6e.tar.bz2
WebCoso-c212d75031ee8b5c87551b7f025e6224d1e7fd6e.zip
aggiornamento delle relazioni tra collezioni, e relazioni circolari
git-svn-id: svn://luxion/repos/WebCoso/trunk@7 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso')
-rw-r--r--lib/WebCoso/Config.pm1
-rw-r--r--lib/WebCoso/Config/Collection.pm32
2 files changed, 21 insertions, 12 deletions
diff --git a/lib/WebCoso/Config.pm b/lib/WebCoso/Config.pm
index 929b071..3fbc597 100644
--- a/lib/WebCoso/Config.pm
+++ b/lib/WebCoso/Config.pm
@@ -10,6 +10,7 @@ sub read_scalar {
$WebCoso::Config::Helpers::FILENAME=$filename;
$content=<<'EOF'.$content;
package WEBCOSO::CONFIG;
+no strict;
WebCoso::Config::Helpers->import();
EOF
eval $content;
diff --git a/lib/WebCoso/Config/Collection.pm b/lib/WebCoso/Config/Collection.pm
index 28e1892..367a53e 100644
--- a/lib/WebCoso/Config/Collection.pm
+++ b/lib/WebCoso/Config/Collection.pm
@@ -6,9 +6,9 @@ use WebCoso::Config;
{
my %names_of :ATTR( :get<names> );
-my %parents_of :ATTR;
-my %children_of :ATTR;
-my %resources_of :ATTR( :init_arg<resources> );
+my %parents_of :ATTR( :get<parents_ref> );
+my %children_of :ATTR( :get<children_ref> );
+my %resources_of :ATTR( :init_arg<resources> :get<resources_ref> );
sub BUILD {
my ($self,$ident,$args_ref)=@_;
@@ -18,13 +18,13 @@ sub BUILD {
$names={''=>$names} unless ref($names) eq 'HASH';
$names_of{$ident}=$names;
- my $parents=$args_ref->{parents};
- $_->add_child($self) for @$parents;
+ my $parents=$args_ref->{parents} || [];
$parents_of{$ident}=$parents;
+ $_->add_child($self) for @$parents;
- my $children=$args_ref->{children};
- $_->add_parent($self) for @$children;
+ my $children=$args_ref->{children} || [];
$children_of{$ident}=$children;
+ $_->add_parent($self) for @$children;
WebCoso::Config->add_collection($self);
}
@@ -62,24 +62,32 @@ sub properties {
sub add_child {
my ($self,$child)=@_;
- push @{ $children_of{ ident($self) } },$child;
+
+ return if grep { $_ eq $child } @{ $self->get_children_ref() };
+
+ push @{ $self->get_children_ref() },$child;
+ $child->add_parent($self);
}
sub add_parent {
my ($self,$parent)=@_;
- push @{ $parents_of{ ident($self) } },$parent;
+
+ return if grep { $_ eq $parent } @{ $self->get_parents_ref() };
+
+ push @{ $self->get_parents_ref() },$parent;
+ $parent->add_child($self);
}
sub get_parents {
my ($self)=@_;
- return @{ $parents_of{ ident($self) } };
+ return @{ $self->get_parents_ref() };
}
sub get_children {
my ($self)=@_;
- return @{ $children_of{ ident($self) } };
+ return @{ $self->get_children_ref() };
}
sub get_resources {
my ($self)=@_;
- return @{ $resources_of{ ident($self) } };
+ return @{ $self->get_resources_ref() };
}
}