feisty meow concerns codebase  2.140
octopi::file_transfer_infoton Class Reference

Base objects used by the file transfer tentacle to schedule transfers. More...

#include <file_transfer_infoton.h>

Inheritance diagram for octopi::file_transfer_infoton:
Collaboration diagram for octopi::file_transfer_infoton:

Public Types

enum  commands { BUILD_TARGET_TREE = 4 , TREE_COMPARISON = 1 , PLACE_FILE_CHUNKS = 2 , CONCLUDE_TRANSFER_MARKER = 3 }
 the commands specify what this package is intended to do. More...
 

Public Member Functions

 file_transfer_infoton ()
 
 file_transfer_infoton (const basis::outcome &success, bool request, commands command, const basis::astring &source, const basis::astring &destination, const basis::byte_array &packed_data)
 
virtual ~file_transfer_infoton ()
 
virtual void pack (basis::byte_array &packed_form) const
 stuffs the data in the infoton into the "packed_form". More...
 
virtual bool unpack (basis::byte_array &packed_form)
 restores an infoton from a packed form. More...
 
void package_tree_info (const filesystem::directory_tree &tree, const structures::string_array &includes)
 prepares the packed data from the "tree" and "includes" list. More...
 
virtual basis::clonableclone () const
 must be provided to allow creation of a copy of this object. More...
 
virtual void text_form (basis::base_string &fill) const
 requires derived infotons to be able to show their state as a string. More...
 
virtual int packed_size () const
 reports how large the infoton will be when packed. More...
 
- Public Member Functions inherited from octopi::infoton
 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 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 const structures::string_arrayfile_transfer_classifier ()
 returns the classifier for this type of infoton. More...
 
- Static Public Member Functions inherited from octopi::infoton
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...
 

Public Attributes

basis::outcome _success
 reports what kind of result occurred. More...
 
bool _request
 if it's not a request, then it's a response. More...
 
basis::abyte _command
 one of the commands above. More...
 
basis::astring _src_root
 the top-level directory of the source. More...
 
basis::astring _dest_root
 the top-level directory of the destination. More...
 
basis::byte_array _packed_data
 the packed headers and file chunks. More...
 

Detailed Description

Base objects used by the file transfer tentacle to schedule transfers.

Note: this is a fairly heavy-weight header.

Definition at line 29 of file file_transfer_infoton.h.

Member Enumeration Documentation

◆ commands

the commands specify what this package is intended to do.

Enumerator
BUILD_TARGET_TREE 

asks the target side to build the directory tree from the source.

this is a new first step for the transfer. we want to make sure the target will look right for what we're going to transfer over.

TREE_COMPARISON 

the destination root will be compared with the source root.

the packed data in the request holds a packed symbol tree describing the destination hierarchy. the packed data in the response is the packed filename list that represents the differences between the two hierarchies. this is considered to start a file transfer based on those differences.

PLACE_FILE_CHUNKS 

the destination side requests a new set of chunks.

this is based on the source's memory of where the transfer is at. this will only perform properly when the file transfer was requested to be started by the client using a TREE_COMPARISON request. the request has an empty data chunk, but the response consists of an arbitrary number of pairs of

[ file_transfer_header + file chunk described in header ]
CONCLUDE_TRANSFER_MARKER 

this infoton marks the end of the transfer process.

we've added this type of transfer infoton to handle the finish of the transfer. previously this was marked by a null data packet, which turns out to be a really bad idea.

Definition at line 33 of file file_transfer_infoton.h.

Constructor & Destructor Documentation

◆ file_transfer_infoton() [1/2]

octopi::file_transfer_infoton::file_transfer_infoton ( )

Definition at line 27 of file file_transfer_infoton.cpp.

◆ file_transfer_infoton() [2/2]

octopi::file_transfer_infoton::file_transfer_infoton ( const basis::outcome success,
bool  request,
commands  command,
const basis::astring source,
const basis::astring destination,
const basis::byte_array packed_data 
)

Definition at line 37 of file file_transfer_infoton.cpp.

◆ ~file_transfer_infoton()

octopi::file_transfer_infoton::~file_transfer_infoton ( )
virtual

Definition at line 50 of file file_transfer_infoton.cpp.

Member Function Documentation

◆ clone()

virtual basis::clonable* octopi::file_transfer_infoton::clone ( ) const
inlinevirtual

must be provided to allow creation of a copy of this object.

Implements octopi::infoton.

Definition at line 83 of file file_transfer_infoton.h.

◆ file_transfer_classifier()

static const structures::string_array& octopi::file_transfer_infoton::file_transfer_classifier ( )
static

returns the classifier for this type of infoton.

Referenced by octopi::file_transfer_tentacle::reconstitute().

◆ pack()

void octopi::file_transfer_infoton::pack ( basis::byte_array packed_form) const
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 octopi::infoton.

Definition at line 82 of file file_transfer_infoton.cpp.

References _command, _dest_root, _packed_data, _request, _src_root, _success, basis::attach(), basis::astring::pack(), and basis::outcome::value().

◆ package_tree_info()

void octopi::file_transfer_infoton::package_tree_info ( const filesystem::directory_tree tree,
const structures::string_array includes 
)

prepares the packed data from the "tree" and "includes" list.

Referenced by octopi::recursive_file_copy::copy_hierarchy().

◆ packed_size()

virtual int octopi::file_transfer_infoton::packed_size ( ) const
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 octopi::infoton.

◆ text_form()

void octopi::file_transfer_infoton::text_form ( basis::base_string state_fill) const
virtual

requires derived infotons to be able to show their state as a string.

Implements octopi::infoton.

Definition at line 54 of file file_transfer_infoton.cpp.

References basis::base_string::assign(), and basis::text_formable::class_name().

◆ unpack()

bool octopi::file_transfer_infoton::unpack ( basis::byte_array packed_form)
virtual

restores an infoton from a packed form.

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

Implements octopi::infoton.

Definition at line 92 of file file_transfer_infoton.cpp.

References _command, _dest_root, _packed_data, _request, _src_root, _success, basis::detach(), and basis::astring::unpack().

Member Data Documentation

◆ _command

basis::abyte octopi::file_transfer_infoton::_command

one of the commands above.

Definition at line 63 of file file_transfer_infoton.h.

Referenced by octopi::file_transfer_tentacle::consume(), octopi::recursive_file_copy::copy_hierarchy(), pack(), and unpack().

◆ _dest_root

basis::astring octopi::file_transfer_infoton::_dest_root

the top-level directory of the destination.

Definition at line 65 of file file_transfer_infoton.h.

Referenced by octopi::recursive_file_copy::copy_hierarchy(), pack(), octopi::SAFE_STATIC_CONST(), and unpack().

◆ _packed_data

basis::byte_array octopi::file_transfer_infoton::_packed_data

the packed headers and file chunks.

Definition at line 66 of file file_transfer_infoton.h.

Referenced by octopi::recursive_file_copy::copy_hierarchy(), pack(), octopi::SAFE_STATIC_CONST(), and unpack().

◆ _request

bool octopi::file_transfer_infoton::_request

if it's not a request, then it's a response.

Definition at line 62 of file file_transfer_infoton.h.

Referenced by octopi::file_transfer_tentacle::consume(), octopi::recursive_file_copy::copy_hierarchy(), pack(), and unpack().

◆ _src_root

basis::astring octopi::file_transfer_infoton::_src_root

the top-level directory of the source.

Definition at line 64 of file file_transfer_infoton.h.

Referenced by octopi::recursive_file_copy::copy_hierarchy(), pack(), octopi::SAFE_STATIC_CONST(), and unpack().

◆ _success

basis::outcome octopi::file_transfer_infoton::_success

reports what kind of result occurred.

Definition at line 61 of file file_transfer_infoton.h.

Referenced by octopi::recursive_file_copy::copy_hierarchy(), pack(), and unpack().


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