Difference between revisions of "Assembly line objects"

From Apibot
Jump to: navigation, search
(some more info (will continue it later))
Line 1: Line 1:
Every Assembly line object belongs to one of the following types:
+
The Assembly line objects are the entities that form an assembly line.
 +
 
 +
== Types ==
 +
 
 +
Every object belongs to one of the following types:
  
 
* [[Apibot 0.40 Assembly line feeders|Feeders]] - supply data to the assembly line
 
* [[Apibot 0.40 Assembly line feeders|Feeders]] - supply data to the assembly line
Line 8: Line 12:
 
* [[Apibot 0.40 Assembly line writers|Writers]] - write the processed data (back to the wiki, or to a file, etc.)
 
* [[Apibot 0.40 Assembly line writers|Writers]] - write the processed data (back to the wiki, or to a file, etc.)
  
Each of those types is in a subtree named after it, inside the <code>/line</code> subdirectory in the bot.
+
For each of those types there is a subtree named after it, inside the <code>/line</code> subdirectory in the bot.
 +
 
 +
== 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:
 +
* <code>$worker->link_to ( $feeder );</code> will link $worker ''after'' $feeder in the line.
 +
* <code>$worker->link_with ( $writer );</code> will link $worker ''before'' $writer in the line.
 +
 
 +
Several objects can be linked after and / or before one object:
 +
<pre>
 +
$filter1->link_to ( $feeder );
 +
$filter2->link_to ( $feeder );
 +
$filter3->link_to ( $feeder );
 +
 
 +
$worker->link_to ( $filter1 );
 +
$worker->link_to ( $filter2 );
 +
$worker->link_to ( $filter3 );
 +
</pre>
 +
In this line, <code>$worker</code> must get from <code>$feeder</code> 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 <code>$mains</code> object - on creation. Most require and / or can take more parameters.
 +
 
 +
== Creating 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 <code>Line_Slot</code> class, found in the <code>line/_line_slot.php</code> file. In addition, classes of a certain type should best derive from its generic class, typically found in the file <code>_generic.php</code> in the object type subpath in <code>line</code>.

Revision as of 19:31, 13 April 2013

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

Types

Every 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.

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.

Creating 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.