diff options
author | dakkar <dakkar@luxion> | 2006-02-21 14:16:59 +0000 |
---|---|---|
committer | dakkar <dakkar@luxion> | 2006-02-21 14:16:59 +0000 |
commit | 05cf426e43ebbc4aa167a07129284b38d636ed7f (patch) | |
tree | 34b87db0a12c38813c7c36dd304b80d93cb750fb /lib/WebCoso/Config.pm | |
parent | r1349@narval: dakkar | 2006-02-21 12:47:25 +0100 (diff) | |
download | WebCoso-05cf426e43ebbc4aa167a07129284b38d636ed7f.tar.gz WebCoso-05cf426e43ebbc4aa167a07129284b38d636ed7f.tar.bz2 WebCoso-05cf426e43ebbc4aa167a07129284b38d636ed7f.zip |
r1350@narval: dakkar | 2006-02-21 13:05:07 +0100
fatto il naming, almeno alla buona
git-svn-id: svn://luxion/repos/WebCoso/trunk@203 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso/Config.pm')
-rw-r--r-- | lib/WebCoso/Config.pm | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/lib/WebCoso/Config.pm b/lib/WebCoso/Config.pm index 1b4d6d8..018c3c7 100644 --- a/lib/WebCoso/Config.pm +++ b/lib/WebCoso/Config.pm @@ -9,6 +9,8 @@ use utf8; my @resources; my $collections=WebCoso::Collections->new(); my %resource_to_pipeline; +my %name_to_resource; +my %name_to_collection; sub read_scalar { my ($class,$content,$filename)=@_; @@ -25,9 +27,18 @@ EOF nested => $@, ); } - else { - return 1; + my $symbols=\%WEBCOSO::CONFIG::; + for my $name (keys %$symbols) { + my $object=${*{$symbols->{$name}}{SCALAR}}; + my $type=ref($object); + if ($type eq 'WebCoso::Resource') { + $name_to_resource{$name}=$object; + } + elsif ($type eq 'WebCoso::Collection') { + $name_to_collection{$name}=$object; + } } + return 1; } sub add_resource { @@ -39,6 +50,19 @@ sub get_all_resources { return @resources; } +sub get_res_by_name { + my ($class,$name)=@_; + + if (exists $name_to_resource{$name}) { + return $name_to_resource{$name}; + } + else { + WebCoso::X::NoSuchResource->throw( + resource => $name + ); + } +} + sub add_collection { my ($class,$collection)=@_; $collections->add_collection($collection); @@ -48,6 +72,19 @@ sub get_collections { return $collections; } +sub get_coll_by_name { + my ($class,$name)=@_; + + if (exists $name_to_collection{$name}) { + return $name_to_collection{$name}; + } + else { + WebCoso::X::NoSuchCollection->throw( + collection => $name + ); + } +} + sub get_pipeline_for { my ($class, $resource)=@_; |