feisty meow concerns codebase  2.140
octopi::infoton Class Referenceabstract

An infoton is an individual request parcel with accompanying information. More...

#include <infoton.h>

Inheritance diagram for octopi::infoton:
Collaboration diagram for octopi::infoton:

Public Member Functions

 infoton (const structures::string_array &classifier)
 creates an infoton with the "classifier". More...
 
 infoton (const basis::astring &class_1)
 
 infoton (const basis::astring &class_1, const basis::astring &class_2)
 
 infoton (const basis::astring &class_1, const basis::astring &class_2, const basis::astring &cl_3)
 
 infoton (const infoton &to_copy)
 copies only the base class portion of the infoton. More...
 
virtual ~infoton ()
 
 DEFINE_CLASS_NAME ("infoton")
 
infotonoperator= (const infoton &to_copy)
 assigns only the base class portion. More...
 
const structures::string_arrayclassifier () const
 this array of strings is the "name" for this infoton. More...
 
void set_classifier (const structures::string_array &new_classifier)
 sets the infoton's classifier to the "new_classifier". More...
 
void set_classifier (const basis::astring &class_1)
 
void set_classifier (const basis::astring &class_1, const basis::astring &class_2)
 
void set_classifier (const basis::astring &class_1, const basis::astring &class_2, const basis::astring &cl_3)
 
bool check_classifier (const basis::astring &class_name, const basis::astring &caller)
 checks that the classifier seems valid. More...
 
virtual void pack (basis::byte_array &packed_form) const =0
 stuffs the data in the infoton into the "packed_form". More...
 
virtual bool unpack (basis::byte_array &packed_form)=0
 restores an infoton from a packed form. More...
 
virtual void text_form (basis::base_string &state_fill) const =0
 requires derived infotons to be able to show their state as a string. More...
 
virtual clonable * clone () const =0
 must be provided to allow creation of a copy of this object. More...
 
virtual int packed_size () const =0
 reports how large the infoton will be when packed. More...
 
virtual basis::astring text_form () const
 local version just makes text_form() more functional. More...
 
- Public Member Functions inherited from basis::text_formable
virtual const char * class_name () const =0
 Returns the bare name of this class as a constant character pointer. More...
 

Static Public Member Functions

static void fast_pack (basis::byte_array &packed_form, const infoton &to_pack)
 flattens an infoton "to_pack" into the byte array "packed_form". More...
 
static bool fast_unpack (basis::byte_array &packed_form, structures::string_array &classifier, basis::byte_array &info)
 undoes a previous fast_pack to restore the previous information. More...
 
static bool test_fast_unpack (const basis::byte_array &packed_form, int &packed_length)
 checks that the "packed_form" could hold a valid packed infoton. More...
 
static int fast_pack_overhead (const structures::string_array &classifier)
 reports how much space is needed to pack the "classifier". More...
 

Detailed Description

An infoton is an individual request parcel with accompanying information.

This is the unit of data exchange in the octopus scheme.

Definition at line 28 of file infoton.h.

Constructor & Destructor Documentation

◆ infoton() [1/5]

infoton::infoton ( const structures::string_array classifier)

creates an infoton with the "classifier".

keep in mind that although anything can be passed in here, the consistency of one's collection of octopi depends on a regular classification scheme. it is recommended that the "classifier" be effectively constant. also, classifiers that begin with the octothorpe (aka the pound sign '#') are reserved for octopus internal usage.

Definition at line 41 of file infoton.cpp.

References FUNCDEF.

◆ infoton() [2/5]

infoton::infoton ( const basis::astring class_1)

Definition at line 47 of file infoton.cpp.

References FUNCDEF.

◆ infoton() [3/5]

infoton::infoton ( const basis::astring class_1,
const basis::astring class_2 
)

Definition at line 54 of file infoton.cpp.

References FUNCDEF.

◆ infoton() [4/5]

infoton::infoton ( const basis::astring class_1,
const basis::astring class_2,
const basis::astring cl_3 
)

Definition at line 62 of file infoton.cpp.

References FUNCDEF.

◆ infoton() [5/5]

infoton::infoton ( const infoton to_copy)

copies only the base class portion of the infoton.

clone() is the proper method for copying an instantiated infoton– this constructor only supports copying the base's information.

Definition at line 72 of file infoton.cpp.

◆ ~infoton()

infoton::~infoton ( )
virtual

Definition at line 79 of file infoton.cpp.

References basis::WHACK().

Member Function Documentation

◆ check_classifier()

bool infoton::check_classifier ( const basis::astring class_name,
const basis::astring caller 
)

checks that the classifier seems valid.

the "class_name" and "caller" should be set to the location where the check is being done.

Definition at line 88 of file infoton.cpp.

References basis::array< contents >::length().

Referenced by set_classifier().

◆ classifier()

const string_array & infoton::classifier ( ) const

this array of strings is the "name" for this infoton.

the naming scheme for an infoton hierarchically and uniquely identifies the exact type of this object. the last string (at the end() index) is the most specific name for this object, while the preceding names describe the object's membership in groups. the outermost group name is at the zeroth index in the array. a classifier can have one or more elements.

Definition at line 85 of file infoton.cpp.

Referenced by synchronic::list_manager::consume(), octopi::octopus::evaluate(), fast_pack(), fast_pack_overhead(), fast_unpack(), octopi::identity_infoton::operator=(), octopi::security_infoton::operator=(), and octopi::tentacle::propel_arm().

◆ clone()

virtual clonable* octopi::infoton::clone ( ) const
pure virtual

◆ DEFINE_CLASS_NAME()

octopi::infoton::DEFINE_CLASS_NAME ( "infoton"  )

◆ fast_pack()

void infoton::fast_pack ( basis::byte_array packed_form,
const infoton to_pack 
)
static

flattens an infoton "to_pack" into the byte array "packed_form".

Definition at line 162 of file infoton.cpp.

References structures::attach(), classifier(), octopi::FAST_PACK_VERSION, FUNCDEF, basis::array< contents >::length(), pack(), and structures::pack_array().

◆ fast_pack_overhead()

int infoton::fast_pack_overhead ( const structures::string_array classifier)
static

reports how much space is needed to pack the "classifier".

returns the overhead in bytes that will be added to an infoton's packed size when it is packed with fast_pack(). the "classifier" is the name of the infoton in question and must be accurate or the overhead will not be calculated properly.

Definition at line 155 of file infoton.cpp.

References classifier(), and structures::string_array::packed_size().

◆ fast_unpack()

bool infoton::fast_unpack ( basis::byte_array packed_form,
structures::string_array classifier,
basis::byte_array info 
)
static

undoes a previous fast_pack to restore the previous information.

extracts the data from a packed infoton in "packed_form" into the "classifier" and "info" that are contained therein.

Definition at line 227 of file infoton.cpp.

References classifier(), continuable_error, structures::detach(), octopi::FAST_PACK_VERSION, FUNCDEF, basis::array< contents >::length(), basis::array< contents >::reset(), static_class_name, basis::array< contents >::subarray(), structures::unpack_array(), and basis::array< contents >::zap().

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

◆ operator=()

infoton & infoton::operator= ( const infoton to_copy)

assigns only the base class portion.

clone() is the proper method for copying an instantiated infoton.

Definition at line 82 of file infoton.cpp.

◆ pack()

virtual void octopi::infoton::pack ( basis::byte_array packed_form) const
pure virtual

stuffs the data in the infoton into the "packed_form".

the derived method must know how to pack this particular type of infoton.

Implements basis::packable.

Implemented in synchronic::synchronizable, octopi::security_infoton, octopi::file_transfer_infoton, octopi::encryption_wrapper, octopi::encryption_infoton, octopi::unhandled_request, and octopi::identity_infoton.

Referenced by fast_pack().

◆ packed_size()

virtual int octopi::infoton::packed_size ( ) const
pure virtual

reports how large the infoton will be when packed.

must be overridden by derived classes to provide a guess at how large the packed size of this will be. this is important to estimate accurately.

Implements basis::packable.

Implemented in synchronic::synchronizable, octopi::security_infoton, octopi::file_transfer_infoton, octopi::encryption_wrapper, octopi::encryption_infoton, octopi::unhandled_request, and octopi::identity_infoton.

Referenced by octopi::entity_data_bin::acquire_for_entity(), octopi::entity_data_bin::add_item(), and octopi::tentacle::enqueue().

◆ set_classifier() [1/4]

void infoton::set_classifier ( const basis::astring class_1)

◆ set_classifier() [2/4]

void infoton::set_classifier ( const basis::astring class_1,
const basis::astring class_2 
)

◆ set_classifier() [3/4]

void infoton::set_classifier ( const basis::astring class_1,
const basis::astring class_2,
const basis::astring cl_3 
)

◆ set_classifier() [4/4]

void infoton::set_classifier ( const structures::string_array new_classifier)

sets the infoton's classifier to the "new_classifier".

do not do this unless you know what you're doing; changing the classifier may keep an infoton from being recognized properly.

Definition at line 104 of file infoton.cpp.

References check_classifier(), basis::text_formable::class_name(), and FUNCDEF.

Referenced by octopi::identity_infoton::operator=(), octopi::security_infoton::operator=(), and octopi::reconstituter().

◆ test_fast_unpack()

bool infoton::test_fast_unpack ( const basis::byte_array packed_form,
int &  packed_length 
)
static

checks that the "packed_form" could hold a valid packed infoton.

tests that the smallest prefix of the "packed_form" looks like an appropriate packed classifier and packet length. the "packed_length" is set to the length found in the packet. note that the byte array does not need to contain the complete packed infoton yet; just the first portion where the header info is located must be present. this method does not disturb the data in the packed array.

Definition at line 185 of file infoton.cpp.

References structures::detach(), octopi::FAST_PACK_VERSION, FUNCDEF, basis::array< contents >::length(), structures::obscure_detach(), basis::array< contents >::observe(), and basis::array< contents >::subarray().

◆ text_form() [1/2]

virtual basis::astring octopi::infoton::text_form ( ) const
inlinevirtual

local version just makes text_form() more functional.

Reimplemented in synchronic::synchronizable.

Definition at line 108 of file infoton.h.

References text_form().

Referenced by text_form(), and octopi::unhandled_request::text_form().

◆ text_form() [2/2]

virtual void octopi::infoton::text_form ( basis::base_string state_fill) const
pure virtual

◆ unpack()

virtual bool octopi::infoton::unpack ( basis::byte_array packed_form)
pure virtual

restores an infoton from a packed form.

the unpack() method will be utilized by tentacles that support this type of object.

Implements basis::packable.

Implemented in synchronic::synchronizable, octopi::security_infoton, octopi::file_transfer_infoton, octopi::encryption_wrapper, octopi::encryption_infoton, octopi::unhandled_request, and octopi::identity_infoton.


The documentation for this class was generated from the following files: