Author: dylan
Date: 2005-01-08 02:06:14 -0500 (Sat, 08 Jan 2005)
New Revision: 547
Added:
trunk/main/server/lib/Haver/Server/Entity.pm
trunk/main/server/lib/Haver/Server/Entity/
trunk/main/server/lib/Haver/Server/Entity/Channel.pm
trunk/main/server/lib/Haver/Server/Entity/User.pm
Removed:
trunk/main/server/lib/Haver/Server/Entity/Channel.pm
trunk/main/server/lib/Haver/Server/Entity/User.pm
trunk/main/server/lib/Haver/Server/Object.pm
trunk/main/server/lib/Haver/Server/Object/
Log:
Object -> Entity.
Copied: trunk/main/server/lib/Haver/Server/Entity (from rev 520,
trunk/main/server/lib/Haver/Server/Object)
Deleted: trunk/main/server/lib/Haver/Server/Entity/Channel.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object/Channel.pm 2005-01-05
02:15:44 UTC (rev 520)
+++ trunk/main/server/lib/Haver/Server/Entity/Channel.pm 2005-01-08
07:06:14 UTC (rev 547)
@@ -1,186 +0,0 @@
-# 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;
-use Haver::Server::Object;
-use base qw( Haver::Server::Object );
-
-our $VERSION = 0.10;
-
-=head1 METHODS
-
-Haver::Server::Object::Channel implements the following methods:
-
-=cut
-
-sub initialize {
- my ($me) = @_;
-
- $me->SUPER::initialize;
- $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) = @_;
-
- my $ns = $object->namespace;
- my $id = $object->id;
-
- croak ref($me) . " can't contain $object!" unless
$me->can_contain($object);
-
- $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) = @_;
-
- return undef unless exists $me->{_contents}{$ns};
- return undef unless exists $me->{_contents}{$ns}{$id};
- 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) = @_;
-
- return undef unless exists $me->{_contents}{$ns};
- return undef unless exists $me->{_contents}{$ns}{$id};
- 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 = ();
-
- if (exists $me->{_contents}{$ns}) {
- @values = values %{ $me->{_contents}{$ns} };
- }
-
- 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) = @_;
-
- return undef unless exists $me->{_contents}{$ns};
- return exists $me->{_contents}{$ns}{$id};
-}
-
-
-
-
-1;
-
-=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
-
Copied: trunk/main/server/lib/Haver/Server/Entity/Channel.pm (from rev 546,
trunk/main/server/lib/Haver/Server/Object/Channel.pm)
Deleted: trunk/main/server/lib/Haver/Server/Entity/User.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object/User.pm 2005-01-05 02:15:44 UTC
(rev 520)
+++ trunk/main/server/lib/Haver/Server/Entity/User.pm 2005-01-08 07:06:14 UTC
(rev 547)
@@ -1,42 +0,0 @@
-# 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
-package Haver::Server::Object::User;
-use strict;
-use warnings;
-use Carp;
-
-use Haver::Preprocessor;
-use Haver::Server::Object;
-use Haver::Server::Object::Index;
-use base qw( Haver::Server::Object );
-
-our $VERSION = 0.05;
-
-
-sub initialize {
- my ($me) = @_;
-
- $me->{_access} = {};
-}
-
-
-
-sub grant {
-
-}
-
Copied: trunk/main/server/lib/Haver/Server/Entity/User.pm (from rev 546,
trunk/main/server/lib/Haver/Server/Object/User.pm)
Copied: trunk/main/server/lib/Haver/Server/Entity.pm (from rev 522,
trunk/main/server/lib/Haver/Server/Object.pm)
Deleted: trunk/main/server/lib/Haver/Server/Object.pm
===================================================================
--- trunk/main/server/lib/Haver/Server/Object.pm 2005-01-08 07:05:40 UTC
(rev 546)
+++ trunk/main/server/lib/Haver/Server/Object.pm 2005-01-08 07:06:14 UTC
(rev 547)
@@ -1,167 +0,0 @@
-# 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;
-use strict;
-use warnings;
-use Haver::Preprocessor;
-use Carp;
-
-use Fatal qw(:void open close opendir closedir);
-use Haver::Base;
-use Storable (); # nstore, retrieve.
-use File::Basename (); # fileparse
-use File::Spec;
-use File::Path ();
-
-use base 'Haver::Base';
-
-
-sub initialize {
- my ($me) = @_;
-
- croak "required paramter: id" unless $me->{id};
- $me->{_attribs} = { };
-}
-
-sub id {
- my ($me) = @_;
-
- return $me->{id};
-}
-
-sub set {
- my ($me, $key, $val) = @_;
- croak "Too few args!" if @_ < 3;
- croak "Too many args, use set_many!" if @_ > 3;
-
- $me->{_attribs}{$key} = $val;
-}
-
-
-sub get {
- my ($me, $key) = @_;
-
- croak "Too few args!" if @_ < 1;
- croak "Too many args, try get_many!" if @_ > 1;
-
- if (exists $me->{_attribs}{$key}) {
- return $me->{_attribs}{$key};
- } else {
- return undef;
- }
-}
-
-
-sub get_many {
- my $me = shift;
- my @ret = ();
- my $f = $me->{_attribs};
-
- foreach my $key (@_) {
- push @ret, exists $f->{$key} ? $f->{$key} : undef;
- }
-
- return wantarray ? @ret : [EMAIL PROTECTED] ;
-}
-
-sub del {
- my ($me, $key) = @_;
- croak "Too few args" if @_ < 2;
- croak "Too many args" if @_ > 2;
-
- delete $me->{_attribs}{$key};
-}
-
-sub has {
- my ($me, $key) = @_;
- croak "Too few args!" if @_ < 2;
- croak "Too many args!" if @_ > 2;
-
- return exists $me->{_attribs}{$key};
-}
-
-
-1;
-__END__
-=head1 NAME
-
-Haver::Server::Object - Base class for Users and Channels.
-
-=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
-
-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