Author: dylan
Date: 2005-01-05 01:55:56 -0500 (Wed, 05 Jan 2005)
New Revision: 522
Removed:
trunk/main/server/lib/Haver/Server/Object/Index.pm
Modified:
trunk/main/server/lib/Haver/Server/Object.pm
trunk/main/server/lib/Haver/Server/Object/Channel.pm
trunk/main/server/lib/Haver/Server/Object/User.pm
Log:
Doc fixups and some new methods added to ::User.
Modified: trunk/main/server/lib/Haver/Server/Object/Channel.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object/Channel.pm 2005-01-05
05:00:33 UTC (rev 521)
+++ trunk/main/server/lib/Haver/Server/Object/Channel.pm 2005-01-05
06:55:56 UTC (rev 522)
@@ -1,24 +1,5 @@
# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
# This module is copyrighted, see end of file for details.
-=head1 NAME
-
-Haver::Server::Object::Channel - A Server::Object that contains
Server::Objects.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Object::Channel;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=head1 INHERITENCE
-
-Haver::Server::Object::Channel extends L<Haver::Server::Object>.
-
-=cut
-
package Haver::Server::Object::Channel;
use strict;
use warnings;
@@ -27,12 +8,6 @@
our $VERSION = 0.10;
-=head1 METHODS
-
-Haver::Server::Object::Channel implements the following methods:
-
-=cut
-
sub initialize {
my ($me) = @_;
@@ -40,27 +15,10 @@
$me->{_contents} = {};
}
-=head2 namespace(Z<>)
-
-Returns 'channel'.
-
-=cut
-
sub namespace {
return 'channel';
}
-=head2 add($thing)
-
-This inserts the object $thing to the contents of the channel,
-provided that $thing supports both the namespace() and id() methods,
-and C<<$channel->can_contain($thing)>> returns a true value.
-
-For Haver::Server::Object::Channel, can_contain will return true
-if C<<$thing->namespace() eq 'user'>>. This can be changed in subclasses.
-
-=cut
-
sub add {
my ($me, $object) = @_;
@@ -72,25 +30,12 @@
$me->{_contents}{$ns}{$id} = $object;
}
-=head2 can_contain($thing)
-
-Returns true of C<<$thing->namespace()>> is equal to 'user'.
-
-=cut
-
sub can_contain {
my ($me, $object) = @_;
$object->namespace eq 'user';
}
-=head2 fetch($ns, $id)
-
-Returns the object with namespace $ns and id $id if such an object exists,
-undef otherwise.
-
-=cut
-
sub fetch {
my ($me, $ns, $id) = @_;
@@ -99,14 +44,6 @@
return $me->{_contents}{$ns}{$id};
}
-
-=head2 remove($ns, $id)
-
-Deletes and returns the object with namesapce $ns and id $id if it exists,
-returns undef otherwise.
-
-=cut
-
sub remove {
my ($me, $ns, $id) = @_;
@@ -115,15 +52,6 @@
return delete $me->{_contents}{$ns}{$id};
}
-=head2 contents($ns)
-
-Returns all objects under namespace $ns.
-Will return empty list if there are no object under the namespace.
-
-In scalar context, returns an arrayref. In list context, it returns a list.
-
-=cut
-
sub contents {
my ($me, $ns) = @_;
my @values = ();
@@ -135,12 +63,6 @@
return wantarray ? @values : [EMAIL PROTECTED];
}
-=head2 contains($ns, $id)
-
-Returns true if an object with namespace $ns and id $id exists, false
otherwise.
-
-=cut
-
sub contains {
my ($me, $ns, $id) = @_;
@@ -153,6 +75,68 @@
1;
+# Now for the API manual.
+__END__
+
+=head1 NAME
+
+Haver::Server::Object::Channel - A Server::Object that contains
Server::Objects.
+
+=head1 SYNOPSIS
+
+ use Haver::Server::Object::Channel;
+ # FIXME
+
+=head1 DESCRIPTION
+
+FIXME
+
+=head1 INHERITENCE
+
+Haver::Server::Object::Channel extends L<Haver::Server::Object>.
+
+=head1 METHODS
+
+Haver::Server::Object::Channel implements the following methods:
+
+=head2 namespace(Z<>)
+
+Returns 'channel'.
+
+=head2 add($thing)
+
+This inserts the object $thing to the contents of the channel,
+provided that $thing supports both the namespace() and id() methods,
+and C<<$channel->can_contain($thing)>> returns a true value.
+
+For Haver::Server::Object::Channel, can_contain will return true
+if C<<$thing->namespace() eq 'user'>>. This can be changed in subclasses.
+
+=head2 can_contain($thing)
+
+Returns true of C<<$thing->namespace()>> is equal to 'user'.
+
+=head2 fetch($ns, $id)
+
+Returns the object with namespace $ns and id $id if such an object exists,
+undef otherwise.
+
+=head2 remove($ns, $id)
+
+Deletes and returns the object with namesapce $ns and id $id if it exists,
+returns undef otherwise.
+
+=head2 contains($ns, $id)
+
+Returns true if an object with namespace $ns and id $id exists, false
otherwise.
+
+=head2 contents($ns)
+
+Returns all objects under namespace $ns.
+Will return empty list if there are no object under the namespace.
+
+In scalar context, returns an arrayref. In list context, it returns a list.
+
=head1 BUGS
None known. Bug reports are welcome. Please use our bug tracker at
@@ -164,7 +148,7 @@
=head1 SEE ALSO
-L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
+L<Haver::Server::Object::User>, L<Haver::Server::Object::User>.
=head1 COPYRIGHT and LICENSE
@@ -184,3 +168,4 @@
along with this module; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+=cut
Deleted: trunk/main/server/lib/Haver/Server/Object/Index.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object/Index.pm 2005-01-05 05:00:33 UTC
(rev 521)
+++ trunk/main/server/lib/Haver/Server/Object/Index.pm 2005-01-05 06:55:56 UTC
(rev 522)
@@ -1,33 +0,0 @@
-# Haver::Server::Object::Index - Index of objects.
-#
-# Copyright (C) 2003 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-package Haver::Server::Object::Index;
-use strict;
-use warnings;
-use Carp;
-
-
-our $VERSION = 0.05;
-our $RELOAD = 1;
-
-
-sub namespace {
- return 'container';
-}
-
-
-1;
Modified: trunk/main/server/lib/Haver/Server/Object/User.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object/User.pm 2005-01-05 05:00:33 UTC
(rev 521)
+++ trunk/main/server/lib/Haver/Server/Object/User.pm 2005-01-05 06:55:56 UTC
(rev 522)
@@ -1,20 +1,5 @@
-# Haver::Server::Object::User - OO User object thing.
-#
-# Copyright (C) 2004 Dylan William Hardison
-#
-# This module is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This module is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this module; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
+# This module is copyrighted, see end of file for details.
package Haver::Server::Object::User;
use strict;
use warnings;
@@ -22,7 +7,6 @@
use Haver::Preprocessor;
use Haver::Server::Object;
-use Haver::Server::Object::Index;
use base qw( Haver::Server::Object );
our $VERSION = 0.05;
@@ -31,12 +15,113 @@
sub initialize {
my ($me) = @_;
- $me->{_access} = {};
+ $me->{_access} = {};
+ $me->{_channels} = {};
}
+sub add_channel {
+ my ($me, $cid) = @_;
+ # ASSERT: defined $cid;
+ croak "add_channel(): channel previously added!" if exists
$me->{_channels}{$cid};
+ $me->{_channels}{$cid} = 1;
+}
+sub remove_channel {
+ my ($me, $cid) = @_;
+ # ASSERT: defined $cid;
+ croak "remove_channel(): channel not added!" if not exists
$me->{_channels}{$cid};
+
+ delete $me->{_channels}{$cid};
+}
-sub grant {
+sub has_channel {
+ my ($me, $cid) = @_;
+ # ASSERT: defined $cid;
+ exists $me->{_channels}{$cid};
}
+sub channels {
+ my ($me) = @_;
+ my @chans = keys %{ $me->{_channels} };
+
+ wantarray ? @chans : [EMAIL PROTECTED] ;
+}
+
+# Now for the API manual.
+__END__
+
+=head1 NAME
+
+Haver::Server::Object::User - An object that contains information about a user.
+
+=head1 SYNOPSIS
+
+ use Haver::Server::Object::User;
+ # FIXME
+
+=head1 DESCRIPTION
+
+FIXME
+
+=head1 INHERITENCE
+
+Haver::Server::Object::Object extends L<Haver::Server::Object>.
+
+=head1 METHODS
+
+Haver::Server::Object::Object implements the following methods:
+
+=head2 namespace(Z<>)
+
+Returns 'user';
+
+=head2 add_channel($cid)
+
+Add the channel id $cid to the list of channels the user is joined to.
+
+=head2 remove_channel($cid)
+
+Remove the channel id $cid from the list of joined channels.
+
+=head2 has_channel($cid)
+
+Returns true if the user is joined to the channel $cid. False otherwise.
+
+=head2 channels()
+
+In scalar context, returns an arrayref of the channels this user is joined to.
+In list context, returns a list.
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2004, 2005 by Dylan Hardison
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+=cut
Modified: trunk/main/server/lib/Haver/Server/Object.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object.pm 2005-01-05 05:00:33 UTC
(rev 521)
+++ trunk/main/server/lib/Haver/Server/Object.pm 2005-01-05 06:55:56 UTC
(rev 522)
@@ -1,21 +1,5 @@
# vim: set ts=4 sw=4 expandtab si ai sta tw=104:
# This module is copyrighted, see end of file for details.
-
-=head1 NAME
-
-Haver::Server::Object - Base class for Users and Channels.
-
-=head1 SYNOPSIS
-
- use Haver::Server::Object;
- # FIXME
-
-=head1 DESCRIPTION
-
-FIXME
-
-=cut
-
package Haver::Server::Object;
use strict;
use warnings;
@@ -32,21 +16,6 @@
use base 'Haver::Base';
-=head1 INHERITENCE
-
-Haver::Server::Object extends L<Haver::Base>.
-
-=head1 METHODS
-
-Haver::Server::Object supports the following methods:
-
-=head2 new(%params | \%params)
-
-This is the constructor, inherited from L<Haver::Base>.
-The parameter "id" is required.
-
-=cut
-
sub initialize {
my ($me) = @_;
@@ -54,30 +23,12 @@
$me->{_attribs} = { };
}
-=head2 id(Z<>)
-
-Returns the id (name) of the object.
-
-=cut
-
sub id {
my ($me) = @_;
return $me->{id};
}
-=head2 namespace(Z<>)
-
-Returns the namespace of the object.
-
-This method B<must> be implemented by subclasses.
-
-=head2 set($key, $val)
-
-Set the attribute C<$key> to C<$val> on the current object.
-
-=cut
-
sub set {
my ($me, $key, $val) = @_;
croak "Too few args!" if @_ < 3;
@@ -86,12 +37,7 @@
$me->{_attribs}{$key} = $val;
}
-=head2 get($key)
-Returns the value of the attribute C<$key>.
-
-=cut
-
sub get {
my ($me, $key) = @_;
@@ -105,13 +51,7 @@
}
}
-=head2 get_many(@keys)
-In scalar context, returns an arrayref of values of each attribute
-in C<@keys>. In list context, returns a list of the same.
-
-=cut
-
sub get_many {
my $me = shift;
my @ret = ();
@@ -124,12 +64,6 @@
return wantarray ? @ret : [EMAIL PROTECTED] ;
}
-=head2 del($key)
-
-Remove the attribute C<$key> and return it.
-
-=cut
-
sub del {
my ($me, $key) = @_;
croak "Too few args" if @_ < 2;
@@ -138,12 +72,6 @@
delete $me->{_attribs}{$key};
}
-=head2 has($key)
-
-Returns true if the attribute C<$key> is set, false otherwise.
-
-=cut
-
sub has {
my ($me, $key) = @_;
croak "Too few args!" if @_ < 2;
@@ -154,15 +82,72 @@
1;
+__END__
+=head1 NAME
-=head1 SEE ALSO
+Haver::Server::Object - Base class for Users and Channels.
-L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
+=head1 SYNOPSIS
+ use Haver::Server::Object;
+ # FIXME
+
+=head1 DESCRIPTION
+
+FIXME
+
+=head1 INHERITENCE
+
+Haver::Server::Object extends L<Haver::Base>.
+
+=head1 METHODS
+
+Haver::Server::Object supports the following methods:
+
+=head2 new(%params | \%params)
+
+This is the constructor, inherited from L<Haver::Base>.
+The parameter "id" is required.
+
+=head2 id(Z<>)
+
+Returns the id (name) of the object.
+
+=head2 namespace(Z<>)
+
+Returns the namespace of the object.
+
+This method B<must> be implemented by subclasses.
+
+=head2 set($key, $val)
+
+Set the attribute C<$key> to C<$val> on the current object.
+
+=head2 get($key)
+
+Returns the value of the attribute C<$key>.
+
+=head2 get_many(@keys)
+
+In scalar context, returns an arrayref of values of each attribute
+in C<@keys>. In list context, returns a list of the same.
+
+=head2 del($key)
+
+Remove the attribute C<$key> and return it.
+
+=head2 has($key)
+
+Returns true if the attribute C<$key> is set, false otherwise.
+
=head1 AUTHOR
Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+=head1 SEE ALSO
+
+L<Haver::Server::Object::User>, L<Haver::Server::Object::Channel>.
+
=head1 COPYRIGHT and LICENSE
Copyright (C) 2004, 2005 by Dylan Hardison