NAME

SDL::App::FPS::Group - a container class for SDL::App::FPS thingies

SYNOPSIS

	use SDL::FPS::App;
	use SDL::FPS::App::Group;
	use SDL::FPS::App::Timer;

	$app = SDL::FPS::App->new( ... );

	my $group = SDL::App::FPS::Group->new( $app );

	my $handler = SDL::App::FPS::EventHandler->new(
          SDL_KEYDOWN, SDLK_SPACE, { ... });

        $group->add($handler);

	$group->for_each( $CODE_ref, @arguments );

DESCRIPTION

This package provides a container class, which is used to store timers, event handlers, buttons and other things.

It is used by SDL::App::FPS and you need not to use it directly for timer and event handlers. However, it may be usefull for other things.

CALLBACK

Once for_each() is called, the given callback code (CODE ref) is called with the following parameters:

&{$callback}($self,$object,$object_id,@arguments);

$self is the app the object resides in (e.g. the object of type SDL::App::FPS), $object is the object itself, $id it's id, and the additional arguments are whatever was passed when for_each() was called.

METHODS

new()
my $group = SDL::App::FPS::Group->new();

Creates a new group container.

add()
$group->add($object);
$group->add(@objects);

Add a list of obects (given as reference) to the group. The object(s) must have one internal field, called id. These IDs should be unique numbers or strings.

del()
$group->del($object_id);

Given an object ID, remove this object from the group.

contains()
$group->contains($object_id);

Given an object ID, returns true when the group contains an object with this ID.

id()
$group->id();

Returns the ID of the group itself.

member()
$object = $group->member($id);

Given an object ID, returns the object or undef.

members()
$count = $group->members();

Returns the number of members in this group.

for_each()
$count = $group->for_each($methodname, @arguments);

For each of the members in this group call their method $methodname with the @arguments.

activate()
$group->activate();

Activate each member of the group by calling it's activate() method.

deactivate()
$group->deactivate();

Deactivate each member of the group by calling it's deactivate() method.

clear
$group->clear();

This deregisters all members of the group with the application and then deletes all ptrs the group has to the members. In case the group was the only container holding these members, they will be destroyed and their memory freed.

named
my @objects = $group->named($name);

Return a list of names that match the given one, in scalar context returns the first match.

Give the name to match as string, and an exact, case-sensitive match will be searched. For substring matches, or case-insensitive ones give a quoted regular expression (using qr//). Returns undef if no match was found.

BUGS

None known yet.

AUTHORS

(c) 2002, 2003 Tels <http://bloodgate.com/>

SEE ALSO

SDL:App::FPS, SDL::App and SDL.