#include <tentacle.h>
Inheritance diagram for tentacle:


Public Types | |
| enum | constants { DEFAULT_RATE = 40 } |
| enum | outcomes { OKAY = common::OKAY, NOT_FOUND = common::NOT_FOUND, ALREADY_EXISTS = common::EXISTING, BAD_INPUT = common::BAD_INPUT, NO_SPACE = common::NO_SPACE, GARBAGE = common::GARBAGE, DISALLOWED = common::DISALLOWED, NO_HANDLER = common::NO_HANDLER, PARTIAL = common::PARTIAL, ENCRYPTION_MISMATCH = common::ENCRYPTION_MISMATCH } |
Public Member Functions | |
| tentacle (const string_array &group_name, bool backgrounded, int motivational_rate=tentacle::DEFAULT_RATE) | |
| constructs a tentacle that handles infotons with the "group_name". | |
| virtual | ~tentacle () |
| IMPLEMENT_CLASS_NAME ("tentacle") | |
| const string_array & | group () const |
| returns the name of the group that this tentacle services. | |
| bool | backgrounding () const |
| reports on whether this tentacle supports background operation or not. | |
| int | motivational_rate () const |
| returns the background processing rate this was constructed with. | |
| virtual outcome | reconstitute (const string_array &classifier, byte_array &packed_form, infoton *&reformed)=0 |
| regenerates an infoton from its packed form. | |
| virtual outcome | consume (infoton &to_chow, const octopus_request_id &item_id, byte_array &transformed)=0 |
| this is the main function that processes infotons for this tentacle. | |
| virtual void | expunge (const octopus_entity &to_remove)=0 |
| called to remove traces of the entity "to_remove". | |
| outcome | enqueue (infoton *to_chow, const octopus_request_id &item_id) |
| holds onto infotons coming from the octopus for backgrounding. | |
| infoton * | next_request (octopus_request_id &item_id) |
| pops out the next queued request for processing. | |
| bool | store_product (infoton *product, const octopus_request_id &original_id) |
| used by tentacles to store the objects they produce from infotons. | |
| void | attach_storage (entity_data_bin &storage) |
| used when a tentacle is being integrated with an octopus. | |
| void | detach_storage () |
| unhooks the storage bin from this tentacle. | |
| void | propel_arm () |
| invoked by our thread to cause requests to be processed. | |
Static Public Member Functions | |
| static const char * | outcome_name (const outcome &to_name) |
| returns the textual form of the outcome "to_name". | |
Definition at line 33 of file tentacle.h.
| enum tentacle::constants |
| enum tentacle::outcomes |
Definition at line 62 of file tentacle.h.
| tentacle::tentacle | ( | const string_array & | group_name, | |
| bool | backgrounded, | |||
| int | motivational_rate = tentacle::DEFAULT_RATE | |||
| ) |
constructs a tentacle that handles infotons with the "group_name".
if "backgrounded" is true, then the tentacle will periodically look for queued requests at the specified "motivational_rate". if "backgrounded" is false, then the tentacle will not perform any background processing, meaning that it can only provide immediate evaluation for an octopus.
Definition at line 69 of file tentacle.cpp.
| tentacle::~tentacle | ( | ) | [virtual] |
| tentacle::IMPLEMENT_CLASS_NAME | ( | "tentacle" | ) |
| const string_array & tentacle::group | ( | ) | const |
returns the name of the group that this tentacle services.
this can be a single string or it can be a list of names. a tentacle can only service one name group currently.
Definition at line 92 of file tentacle.cpp.
Referenced by octopus::add_tentacle(), and list_manager::list_name().
| bool tentacle::backgrounding | ( | ) | const [inline] |
reports on whether this tentacle supports background operation or not.
Definition at line 56 of file tentacle.h.
Referenced by octopus::evaluate().
| int tentacle::motivational_rate | ( | ) | const |
returns the background processing rate this was constructed with.
Definition at line 97 of file tentacle.cpp.
| const char * tentacle::outcome_name | ( | const outcome & | to_name | ) | [static] |
returns the textual form of the outcome "to_name".
Definition at line 94 of file tentacle.cpp.
References common::outcome_name().
Referenced by octopus::evaluate().
| virtual outcome tentacle::reconstitute | ( | const string_array & | classifier, | |
| byte_array & | packed_form, | |||
| infoton *& | reformed | |||
| ) | [pure virtual] |
regenerates an infoton from its packed form.
given the "classifier" under which the object is categorized, this reconstructs a "reformed" infoton equivalent to the flattened infoton in "packed_form". the "packed_form" is destructively consumed. NOTE: it is crucial that the derived method calls set_classifier() on the "reformed" infoton from the passed "classifier".
Implemented in list_manager, identity_tentacle, tentacle_helper< contents >, encryption_tentacle, unwrapping_tentacle, file_transfer_tentacle, login_tentacle, tentacle_helper< identity_infoton >, tentacle_helper< encryption_wrapper >, tentacle_helper< file_transfer_infoton >, tentacle_helper< bubble >, tentacle_helper< security_infoton >, tentacle_helper< address_ton >, tentacle_helper< encryption_infoton >, and tentacle_helper< unhandled_request >.
Referenced by octopus::restore().
| virtual outcome tentacle::consume | ( | infoton & | to_chow, | |
| const octopus_request_id & | item_id, | |||
| byte_array & | transformed | |||
| ) | [pure virtual] |
this is the main function that processes infotons for this tentacle.
the octopus will feed this function with appropriate data "to_chow" for infotons that are to be processed by this tentacle's group(). the "item_id" provides for the requesting entity an origination marker that can be used in produce() below. the outcome indicates whether the processing was successful. processing could fail due to a missing handler for the item, due to erronous data in the infoton, because of resource limits placed on the tentacle, from explicit rejection by the tentacle, or due to other causes. the "transformed" is a packed infoton that may be generated during the consumption of "to_chow" (it must actually be a packed classifier and then the packed infoton). if it can be unpacked successfully, then it will be treated as the actual infoton that was to be consumed. this is only expected from a filter. note: the infoton "to_chow" can be destructively manipulated by the tentacle, including patching the classifier for internal octopi or rearranging any data contained in "to_chow". none of these changes will be seen by the entity that requested processing. regarding filters: if this tentacle is serving as a filter, then it may be presented with infotons that are not covered by its group. given such an infoton, the tentacle should perform whatever filtering is to be done, including modifying the infoton appropriately, and return PARTIAL when it liked the infoton or DISALLOWED when it rejects the infoton. it is understood that the infoton will be passed along to the rest of the tentacles when the successful result of PARTIAL is returned.
Implemented in list_manager, identity_tentacle, encryption_tentacle, unwrapping_tentacle, file_transfer_tentacle, and login_tentacle.
Referenced by octopus::evaluate(), and propel_arm().
| virtual void tentacle::expunge | ( | const octopus_entity & | to_remove | ) | [pure virtual] |
called to remove traces of the entity "to_remove".
this is an order from the octopus that all traces of the entity "to_remove" should now be cleaned out. that entity has been utterly destroyed and any data structures held for it should be thrown out also. the required actions are specific to the tentacle's design.
Implemented in list_manager, encryption_tentacle, file_transfer_tentacle, and login_tentacle.
| outcome tentacle::enqueue | ( | infoton * | to_chow, | |
| const octopus_request_id & | item_id | |||
| ) |
holds onto infotons coming from the octopus for backgrounding.
this will add an infoton "to_chow" into the list of objects to be consumed. at some point after a successful outcome from this, the tentacle will be handed the infoton for processing. NOTE: all responsibility for the infoton "to_chow" is passed to this method; the infoton should not be touched in any way after invocation.
Definition at line 125 of file tentacle.cpp.
References GRAB_CONSUMER_LOCK, entity_data_bin::max_bytes_per_entity(), NO_SPACE, OKAY, infoton::packed_size(), and WHACK().
Referenced by octopus::evaluate().
| infoton * tentacle::next_request | ( | octopus_request_id & | item_id | ) |
pops out the next queued request for processing.
this function locates the next request for the tentacle when it is in its consume() method. the returned infoton was previously passed to the enqueue() method and needs to be processed. if there are no requests ready, NIL is returned.
Definition at line 152 of file tentacle.cpp.
References GRAB_CONSUMER_LOCK, and NIL.
Referenced by propel_arm().
| bool tentacle::store_product | ( | infoton * | product, | |
| const octopus_request_id & | original_id | |||
| ) |
used by tentacles to store the objects they produce from infotons.
this will cache the "product" object and its "original_id" for later retrieval from the entity_data_bin we were given when hooked to an octopus. note that the "product" must be allocated dynamically and that it becomes owned by the response bin after this call (do not delete the original pointer). if the item would not fit in the entity's bin, then false is returned and the "product" is deleted.
Definition at line 112 of file tentacle.cpp.
References entity_data_bin::add_item(), FUNCDEF, and LOG.
Referenced by login_tentacle::consume(), encryption_tentacle::consume(), and identity_tentacle::consume().
| void tentacle::attach_storage | ( | entity_data_bin & | storage | ) |
used when a tentacle is being integrated with an octopus.
not for casual external users. note that the tentacle's background processing will not be started until attach is called and that it stops when detach is called.
Definition at line 100 of file tentacle.cpp.
References NIL.
Referenced by octopus::add_tentacle().
| void tentacle::detach_storage | ( | ) |
unhooks the storage bin from this tentacle.
Definition at line 106 of file tentacle.cpp.
References NIL.
| void tentacle::propel_arm | ( | ) |
invoked by our thread to cause requests to be processed.
Definition at line 164 of file tentacle.cpp.
References infoton::classifier(), consume(), FUNCDEF, LOG, next_request(), NIL, OKAY, string_array::text_form(), and WHACK().
1.5.1