Difference between revisions of "Assembly line objects"

From Apibot
Jump to: navigation, search
(some more info (will continue it later))
(+ set_slot_params_from_signal)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
The Assembly line objects are the entities that form an assembly line.
+
All Assembly line objects share some common features. They inherit those from the Line_Slot class, from which all their classes ultimately descend.
  
== Types ==
+
== Public properties ==
  
Every object belongs to one of the following types:
+
* <code>$explicit name</code> - in addition to the slot name, which is specific for the objects class, you can assign an explicit name, specific to each object from the same class. Added to the slot name, it forms the full name of the object. It is used to determine the line object full name parameter group, and is written in the Apibot logs and some error messages. Default: none.
 +
* <code>$default_data_key</code> - the key to the signals data block that will be considered default by this object, and processed by it. Default: "*".
 +
* <code>$set_slot_params_from_signal</code> (v0.40.21+) - typically the object will take parameters from signal parameters group that is named for the object full name, slot name or type name (in that precedence). If this property is set to <code>false</code>, the object will not take parameters from the signal. Default: <code>true</code>.
 +
* <code>$preserve_slot_signal_params</code> - after setting object parameters from signal parameters group, the object will delete this parameters group from the signal. If this property is set to <code>false</code>, the parameters group will not be deleted. If the property is set to a string, the parameters group will be renamed to "type." plus this string, if it was named for the object type, to "name." plus this string, if it was named for the object slot name, and to "object." plus this string, if it was named for the object full name. Default: <code>true</code>.
  
* [[Apibot 0.40 Assembly line feeders|Feeders]] - supply data to the assembly line
+
== Public methods ==
* [[Apibot 0.40 Assembly line fetchers|Fetchers]] - fetch full wiki objects by some identificator (eg. pages by titles)
 
* [[Apibot 0.40 Assembly line filters|Filters]] - let through only data that matches given criteria, or reorder the data
 
* [[Apibot 0.40 Assembly line signals|Signal modifiers]] - modify signals and their properties in some way
 
* [[Apibot 0.40 Assembly line workers|Workers]] - process the data in one way or another
 
* [[Apibot 0.40 Assembly line writers|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 <code>/line</code> subdirectory in the bot.
+
* <code>is_linked()</code> - returns <code>true</code> if there is at least one other line object linked to (after) this one, <code>false</code> if there is none.
 +
* <code>linked_with()</code> - returns an array with all line objects linked to (after) this one.
  
== Line structure and creation ==
+
* <code>link_with ( $object, $backcall = true )</code> - links <code>$object</code> (must be a line object) after this one. If <code>$backcall</code> is true, makes <code>$object</code> also linked to this one (this is the typical case). If <code>$backcall</code> is false, <code>$object</code> will not be linked back to this one (do this only if you know VERY well what you are doing).
 +
* <code>link_to ( $object, $backcall = true )</code> - links this line object after <code>$object</code> (must be a line object). If <code>$backcall</code> is true, makes <code>$object</code> also linked with this one (this is the typical case). If <code>$backcall</code> is false, <code>$object</code> will not be linked with this one (do this only if you know VERY well what you are doing).
  
An assembly line typically starts with a feeder object and ends with a writer object, typically with some other objects (writers etc) in between.
+
* <code>unlink ( $object, $backcall = true )</code> - unlinks <code>$object</code> (must be a line object, linked after this one) from this one. If <code>$backcall</code> is true, makes <code>$object</code> also unlink from this one (this is the typical case). If <code>$backcall</code> is false, <code>$object</code> will not be unlinked from this one (do this only if you know VERY well what you are doing).
 +
* <code>unlink_from ( $object, $backcall = true )</code> - unlinks <code>$object</code> (must be a line object this one is linked after) from this one. If <code>$backcall</code> is true, makes <code>$object</code> also unlink from this one (this is the typical case). If <code>$backcall</code> is false, <code>$object</code> will not be unlinked from this one (do this only if you know VERY well what you are doing).
  
Objects are strung one to another via two procedures:
+
* <code>process ( &$signal )</code> - processes a signal (incl. propagates it to the line objects after this one).
* <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:
+
== See also ==
<pre>
 
$filter1->link_to ( $feeder );
 
$filter2->link_to ( $feeder );
 
$filter3->link_to ( $feeder );
 
  
$worker->link_to ( $filter1 );
+
* [[Assembly line feeders]]
$worker->link_to ( $filter2 );
+
* [[Assembly line fetchers]]
$worker->link_to ( $filter3 );
+
* [[Assembly line filters]]
</pre>
+
* [[Assembly line workers]]
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.
+
* [[Assembly line writers]]
  
All line objects require at least one parameter - the bot <code>$mains</code> object - on creation. Most require and / or can take more parameters.
+
* [[Assembly line interface]]
  
== Creating Assembly line objects classes ==
+
* [[Main Page]]
 
 
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>.
 

Latest revision as of 15:47, 5 November 2014

All Assembly line objects share some common features. They inherit those from the Line_Slot class, from which all their classes ultimately descend.

Public properties

  • $explicit name - in addition to the slot name, which is specific for the objects class, you can assign an explicit name, specific to each object from the same class. Added to the slot name, it forms the full name of the object. It is used to determine the line object full name parameter group, and is written in the Apibot logs and some error messages. Default: none.
  • $default_data_key - the key to the signals data block that will be considered default by this object, and processed by it. Default: "*".
  • $set_slot_params_from_signal (v0.40.21+) - typically the object will take parameters from signal parameters group that is named for the object full name, slot name or type name (in that precedence). If this property is set to false, the object will not take parameters from the signal. Default: true.
  • $preserve_slot_signal_params - after setting object parameters from signal parameters group, the object will delete this parameters group from the signal. If this property is set to false, the parameters group will not be deleted. If the property is set to a string, the parameters group will be renamed to "type." plus this string, if it was named for the object type, to "name." plus this string, if it was named for the object slot name, and to "object." plus this string, if it was named for the object full name. Default: true.

Public methods

  • is_linked() - returns true if there is at least one other line object linked to (after) this one, false if there is none.
  • linked_with() - returns an array with all line objects linked to (after) this one.
  • link_with ( $object, $backcall = true ) - links $object (must be a line object) after this one. If $backcall is true, makes $object also linked to this one (this is the typical case). If $backcall is false, $object will not be linked back to this one (do this only if you know VERY well what you are doing).
  • link_to ( $object, $backcall = true ) - links this line object after $object (must be a line object). If $backcall is true, makes $object also linked with this one (this is the typical case). If $backcall is false, $object will not be linked with this one (do this only if you know VERY well what you are doing).
  • unlink ( $object, $backcall = true ) - unlinks $object (must be a line object, linked after this one) from this one. If $backcall is true, makes $object also unlink from this one (this is the typical case). If $backcall is false, $object will not be unlinked from this one (do this only if you know VERY well what you are doing).
  • unlink_from ( $object, $backcall = true ) - unlinks $object (must be a line object this one is linked after) from this one. If $backcall is true, makes $object also unlink from this one (this is the typical case). If $backcall is false, $object will not be unlinked from this one (do this only if you know VERY well what you are doing).
  • process ( &$signal ) - processes a signal (incl. propagates it to the line objects after this one).

See also