| perfSONAR_PS-Services-PingER documentation | Contained in the perfSONAR_PS-Services-PingER distribution. |
perfSONAR_PS::Datatypes::NSMap - namespace mapper interface class
see each call description for details
namespace definitions,
first parameter is the current object
othe parameters:
with single paramter ( element name ) it will return
id ( not the actual URI) of the namesapce and with two parameters will set namespace
to specific element name
and without parameters it will return the whole namespaces hashref
Maxim Grigoriev (FNAL) 2007, maxim@fnal.gov
| perfSONAR_PS-Services-PingER documentation | Contained in the perfSONAR_PS-Services-PingER distribution. |
package perfSONAR_PS::Datatypes::NSMap; use strict; use warnings;
use version;our $VERSION = 0.09; use Readonly; Readonly::Scalar our $CLASSPATH => 'perfSONAR_PS::Datatypes::NSMap'; use perfSONAR_PS::Datatypes::Namespace; use fields qw( namespace ); ##use Log::Log4perl qw(get_logger); sub new { my $class = shift; $class = ref($class) || $class; my $self = fields::new($class); my $param = shift; if(ref($param) eq 'HASH') { foreach my $key (keys %{$param}) { $self->mapname($key => $param->{$key}); } } $self->{namespace} = {}; return $self; }
sub mapname { my ($self, $element, $nsid) = @_; ##my $logger = get_logger( CLASSPATH ); if ( $element && $nsid) { if(perfSONAR_PS::Datatypes::Namespace::getNsByKey($nsid)) { ##$logger->debug("Setting id=$nsid for element=$element"); $self->{namespace}->{$element} = $nsid; return $self; } } elsif($element && $self->{namespace}->{$element} && !$nsid) { ##$logger->debug("Returning namespace id for element name=$element id=". $self->{namespace}->{$element}); return $self->{namespace}->{$element}; } elsif(!$nsid && !$element ) { ##$logger->debug("Returning whole namespace hashref"); return $self->{namespace}; } return; }
1;