Sprog::Machine.3pm

Langue: en

Autres versions - même langue

Version: 2005-07-27 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Sprog::Machine - Data model for a Sprog application

DESCRIPTION

This class implements the data model for a Sprog application. It is a container for Sprog::Gear classes.

When a machine is run, it creates a Sprog::Machine::Scheduler instance to handle the passing of messages between gears.

CLASS METHODS

new ( arguments )

Constructor. This method is called by the Sprog application class during app startup.

INSTANCE METHODS

add_gear ( gear_class, arguments )

Adds a gear to the workspace. Usually called from the application's "add_gear_at_x_y" method. Returns a reference to the gear on success. Fires an alert message and returns undef on error.

app

Returns a reference to the Sprog application object.

delete_gear_by_id ( id )

Removes the specified gear from the machine.

detach_gear ( gear )

Breaks connection between the supplied gear and the gear feeding into it. This is used for example when dragging gears to pull a machine apart.

expunge ( )

Removes all gears from the machine in such a way that the gui components disappear too.

head_gear ( )

Returns a reference to the first gear that has no input connector.

load_from_file ( filename )

Reads the specified file, verifies file format and version information in the header and then instantiates each of the gears described in the file as well as the interconnections between them.

run ( )

Called by the app object to instantiate a scheduler and set it runnning.

running ( boolean )

Get/set the flag to indicate the machine is running.

save_to_file ( filename )

Serialises each of the gears and their interconnections to the named file.

stop ( )

Called by the app to stop a running machine.

SEE ALSO

Sprog

Sprog::help::internals has more information about the inner workings of Sprog.

Copyright 2004-2005 Grant McLean <grantm@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.