1 #$Id: Registration.pm,v 1.10 2004/12/14 20:47:04 kawas Exp $
5 MOBY::Client::Registration - an object to wrap the registration XML from MOBY Central
11 my $reg = $Central->registerService(%args);
13 print "registered successfully ",$reg->registration_id,"\n";
15 print "registration failed ",$reg->message,"\n";
22 simply turns the registration XML into a hash
26 Mark Wilkinson (markw@illuminae.com)
28 BioMOBY Project: http://www.biomoby.org
38 Usage : my $MOBY = MOBY::Client::Registration->new(%args)
40 Returns : MOBY::Client::Registration object
41 Args : registration_id => $id
51 =head2 registration_id
55 =head2 id (same as registration_id)
69 package MOBY
::Client
::Registration
;
72 use vars
qw($AUTOLOAD);
75 #Encapsulated class data
76 #___________________________________________________________
78 my %_attr_data = # DEFAULT ACCESSIBILITY
80 success => [ 0, 'read/write' ],
81 message => [ "OK", 'read/write' ],
82 registration_id => [ undef, 'read/write' ],
83 RDF => [ undef, 'read/write' ],
86 #_____________________________________________________________
87 # METHODS, to operate on encapsulated class data
88 # Is a specified object attribute accessible in a given mode
90 my ( $self, $attr, $mode ) = @_;
91 $_attr_data{$attr}[1] =~ /$mode/;
94 # Classwide default value for a specified object attribute
96 my ( $self, $attr ) = @_;
97 $_attr_data{$attr}[0];
100 # List of names of all specified object attributes
107 my ( $self, $val ) = @_;
108 $self->registration_id( $val ) if defined $val;
109 return $self->registration_id;
113 my ( $caller, %args ) = @_;
114 my $caller_is_obj = ref( $caller );
115 my $class = $caller_is_obj || $caller;
116 my $self = bless {}, $class;
117 foreach my $attrname ( $self->_standard_keys ) {
118 if ( exists $args{$attrname} && defined $args{$attrname} ) {
119 $self->{$attrname} = $args{$attrname};
120 } elsif ( $caller_is_obj ) {
121 $self->{$attrname} = $caller->{$attrname};
123 $self->{$attrname} = $self->_default_for( $attrname );
132 my ( $self, $newval ) = @_;
133 $AUTOLOAD =~ /.*::(\w+)/;
135 if ( $self->_accessible( $attr, 'write' ) ) {
137 if ( defined $_[1] ) { $_[0]->{$attr} = $_[1] }
138 return $_[0]->{$attr};
139 }; ### end of created subroutine
140 ### this is called first time only
141 if ( defined $newval ) {
142 $self->{$attr} = $newval;
144 return $self->{$attr};
145 } elsif ( $self->_accessible( $attr, 'read' ) ) {
147 return $_[0]->{$attr};
148 }; ### end of created subroutine
149 return $self->{$attr};
152 # Must have been a mistake then...
153 croak "No such method: $AUTOLOAD";