octopi::tentacle Class Reference

Manages a service within an octopus by processing certain infotons. More...

#include <tentacle.h>

Inheritance diagram for octopi::tentacle:
Inheritance graph
[legend]
Collaboration diagram for octopi::tentacle:
Collaboration graph
[legend]

List of all members.

Public Types

enum  constants { DEFAULT_RATE = 40 }
enum  outcomes {
  OKAY = basis::common::OKAY, NOT_FOUND = basis::common::NOT_FOUND, ALREADY_EXISTS = basis::common::EXISTING, BAD_INPUT = basis::common::BAD_INPUT,
  NO_SPACE = basis::common::NO_SPACE, GARBAGE = basis::common::GARBAGE, DISALLOWED = basis::common::DISALLOWED, NO_HANDLER = basis::common::NO_HANDLER,
  PARTIAL = basis::common::PARTIAL, ENCRYPTION_MISMATCH = basis::common::ENCRYPTION_MISMATCH
}

Public Member Functions

 tentacle (const structures::string_array &group_name, bool backgrounded, int motivational_rate=tentacle::DEFAULT_RATE)
 constructs a tentacle that handles infotons with the "group_name".
virtual ~tentacle ()
 DEFINE_CLASS_NAME ("tentacle")
const structures::string_arraygroup () 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 basis::outcome reconstitute (const structures::string_array &classifier, basis::byte_array &packed_form, infoton *&reformed)=0
 regenerates an infoton from its packed form.
virtual basis::outcome consume (infoton &to_chow, const octopus_request_id &item_id, basis::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".
basis::outcome enqueue (infoton *to_chow, const octopus_request_id &item_id)
 holds onto infotons coming from the octopus for backgrounding.
infotonnext_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 basis::outcome &to_name)
 returns the textual form of the outcome "to_name".

Detailed Description

Manages a service within an octopus by processing certain infotons.

Definition at line 35 of file tentacle.h.


Member Enumeration Documentation

Enumerator:
DEFAULT_RATE 

Definition at line 49 of file tentacle.h.

Enumerator:
OKAY 
NOT_FOUND 
ALREADY_EXISTS 
BAD_INPUT 
NO_SPACE 
GARBAGE 
DISALLOWED 
NO_HANDLER 

no handler for that type of infoton.

PARTIAL 

processing of request is partially done.

ENCRYPTION_MISMATCH 

there is a disconnect regarding encryption.

Definition at line 64 of file tentacle.h.


Constructor & Destructor Documentation

octopi::tentacle::tentacle ( const structures::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 71 of file tentacle.cpp.

octopi::tentacle::~tentacle (  )  [virtual]

Definition at line 85 of file tentacle.cpp.

References basis::WHACK().


Member Function Documentation

void octopi::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 102 of file tentacle.cpp.

References NIL.

Referenced by octopi::octopus::add_tentacle().

bool octopi::tentacle::backgrounding (  )  const [inline]

reports on whether this tentacle supports background operation or not.

Definition at line 58 of file tentacle.h.

Referenced by octopi::octopus::evaluate().

virtual basis::outcome octopi::tentacle::consume ( infoton to_chow,
const octopus_request_id item_id,
basis::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 octopi::identity_tentacle, synchronic::list_manager, octopi::encryption_tentacle, octopi::unwrapping_tentacle, octopi::file_transfer_tentacle, and octopi::login_tentacle.

Referenced by octopi::octopus::evaluate(), and propel_arm().

octopi::tentacle::DEFINE_CLASS_NAME ( "tentacle"   ) 
void octopi::tentacle::detach_storage (  ) 

unhooks the storage bin from this tentacle.

Definition at line 108 of file tentacle.cpp.

References NIL.

outcome octopi::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 129 of file tentacle.cpp.

References GRAB_CONSUMER_LOCK, octopi::entity_data_bin::max_bytes_per_entity(), NO_SPACE, OKAY, octopi::infoton::packed_size(), and basis::WHACK().

Referenced by octopi::octopus::evaluate().

virtual void octopi::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 synchronic::list_manager, octopi::encryption_tentacle, octopi::file_transfer_tentacle, and octopi::login_tentacle.

const string_array & octopi::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 94 of file tentacle.cpp.

Referenced by octopi::octopus::add_tentacle(), octopi::octopus::evaluate(), and synchronic::list_manager::list_name().

int octopi::tentacle::motivational_rate (  )  const

returns the background processing rate this was constructed with.

Definition at line 99 of file tentacle.cpp.

infoton * octopi::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 156 of file tentacle.cpp.

References GRAB_CONSUMER_LOCK, and NIL.

Referenced by propel_arm().

const char * octopi::tentacle::outcome_name ( const basis::outcome to_name  )  [static]

returns the textual form of the outcome "to_name".

Definition at line 96 of file tentacle.cpp.

Referenced by octopi::octopus::evaluate().

void octopi::tentacle::propel_arm (  ) 

invoked by our thread to cause requests to be processed.

Definition at line 168 of file tentacle.cpp.

References octopi::infoton::classifier(), consume(), FUNCDEF, LOG, next_request(), NIL, OKAY, structures::string_array::text_form(), and basis::WHACK().

virtual basis::outcome octopi::tentacle::reconstitute ( const structures::string_array classifier,
basis::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 octopi::identity_tentacle, octopi::tentacle_helper< contents >, synchronic::list_manager, octopi::encryption_tentacle, octopi::unwrapping_tentacle, octopi::file_transfer_tentacle, octopi::login_tentacle, octopi::tentacle_helper< identity_infoton >, octopi::tentacle_helper< encryption_wrapper >, octopi::tentacle_helper< file_transfer_infoton >, octopi::tentacle_helper< security_infoton >, octopi::tentacle_helper< encryption_infoton >, and octopi::tentacle_helper< unhandled_request >.

Referenced by octopi::octopus::restore().

bool octopi::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 114 of file tentacle.cpp.

References octopi::entity_data_bin::add_item(), FUNCDEF, and LOG.

Referenced by octopi::login_tentacle::consume(), octopi::encryption_tentacle::consume(), and octopi::identity_tentacle::consume().


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 04:25:45 2012 for hoople2 project by  doxygen 1.6.3