The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Games::Irrlicht::Group - a container class for Games::Irrlicht thingies

SYNOPSIS

        use Games::Irrlicht;
        use Games::Irrlicht::Group;
        use Games::Irrlicht::Timer;

        $app = Games::Irrlicht->new( ... );

        my $group = Games::Irrlicht::Group->new( $app );

        my $timer = Games::Irrlicht::Timer->new( ... );

        $group->add($timer);

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

DESCRIPTION

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

It is used by Games::Irrlicht 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 = Games::Irrlicht::Group->new( $app );

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, 2004 Tels <http://bloodgate.com/>

SEE ALSO

Games::Irrlicht