Difference between revisions of "Assembly line objects"

From Apibot
Jump to: navigation, search
m (added wikilink to the examples)
m (moved Apibot 0.40 Assembly line objects to Assembly line objects: 0.40 is the stable version now - why numbering it?)
(No difference)

Revision as of 15:31, 13 April 2014

The Assembly line objects are the entities (PHP objects) that form an assembly line.


Every assembly line object belongs to one of the following types:

  • Feeders - supply data to the assembly line
  • Fetchers - fetch full wiki objects by some identificator (eg. pages by titles)
  • Filters - let through only data that matches given criteria, or reorder the data
  • Signal modifiers - modify signals and their properties in some way
  • Workers - process the data in one way or another
  • Writers - write the processed data (back to the wiki, or to a file, etc.)

For each of those types there is a subtree named after it, inside the /line subdirectory in the bot.

In addition, there data the assembly line objects fetch, process and write is passed between them attached to special objects - signals. These cannot be attached to the line, and are not considered as proper assembly line objects.

Line structure and creation

An assembly line typically starts with a feeder object and ends with a writer object, typically with some other objects (writers etc) in between.

Objects are strung one to another via two procedures:

  • $worker->link_to ( $feeder ); will link $worker after $feeder in the line.
  • $worker->link_with ( $writer ); will link $worker before $writer in the line.

Several objects can be linked after and / or before one object:

$filter1->link_to ( $feeder );
$filter2->link_to ( $feeder );
$filter3->link_to ( $feeder );

$worker->link_to ( $filter1 );
$worker->link_to ( $filter2 );
$worker->link_to ( $filter3 );

In this line, $worker must get from $feeder data that match any of three completely different conditions, so three different filters must be connected in parallel.

All line objects require at least one parameter - the bot $mains object - on creation. Most require and / or can take more parameters.

You can see some examples on how to use them here.

Writing new Assembly line objects classes

The line objects are designed so as to be easily written and modified. Anyone with some PHP knowledge will be able to create new object classes, either based on existing ones, or from the ground up.

All new object classes must derive from the Line_Slot class, found in the line/_line_slot.php file. In addition, classes of a certain type should best derive from its generic class, typically found in the file _generic.php in the object type subpath in line.