feisty meow concerns codebase 2.140
file_transfer_tentacle.h
Go to the documentation of this file.
1#ifndef FILE_TRANSFER_TENTACLE_CLASS
2#define FILE_TRANSFER_TENTACLE_CLASS
3
4/*****************************************************************************\
5* *
6* Name : file_transfer_tentacle *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 2005-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
19
20#include <basis/mutex.h>
24#include <timely/time_stamp.h>
25
26namespace octopi {
27
28class file_transfer_cleaner;
29class file_transfer_status;
30
32
40: public tentacle_helper<file_transfer_infoton>
41{
42public:
49
50
51 file_transfer_tentacle(int maximum_transfer, transfer_modes mode_of_transfer);
53
65
66 DEFINE_CLASS_NAME("file_transfer_tentacle");
67
70
73 void unlock_directory();
75
76 // these methods are for the "server" side--the side that has files to offer.
77
79 const basis::astring &source_root, int refresh_interval);
81
92
95 basis::outcome refresh_now(const basis::astring &source_mapping);
97
100 bool add_path(const basis::astring &source_mapping, const basis::astring &new_path);
102
104 bool remove_path(const basis::astring &source_mapping, const basis::astring &old_path);
106
107 // these methods are for the client side--the side that wants to get files.
108
110 const basis::astring &src_root, const basis::astring &dest_root,
111 const structures::string_array &include);
113
120 const basis::astring &src_root, const basis::astring &dest_root);
122
125 bool status(const octopus_entity &ent, const basis::astring &src,
126 const basis::astring &dest, double &total_size, int &total_files,
127 double &current_size, int &current_files, bool &done,
128 timely::time_stamp &last_active);
130
136 bool get_differences(const octopus_entity &ent, const basis::astring &src,
137 const basis::astring &dest, filesystem::filename_list &diffs);
139
141 // required tentacle methods...
142
143 virtual basis::outcome reconstitute(const structures::string_array &classifier,
144 basis::byte_array &packed_form, infoton * &reformed);
146
150 virtual basis::outcome consume(infoton &to_chow, const octopus_request_id &item_id,
151 basis::byte_array &transformed);
153
154 virtual void expunge(const octopus_entity &to_remove);
156
157 // internal use only.
158
159 void periodic_actions();
160
161private:
162 int _maximum_transfer;
163 file_transfer_status *_transfers;
164 file_transfer_status *_correspondences;
165 basis::mutex *_lock;
166 file_transfer_cleaner *_cleaner;
167 int _mode;
168
169 // these process the request and response infotons that are passed to us.
170 basis::outcome handle_build_target_tree_request(file_transfer_infoton &req,
171 const octopus_request_id &item_id);
172 basis::outcome handle_build_target_tree_response(file_transfer_infoton &resp,
173 const octopus_request_id &item_id);
174 basis::outcome handle_tree_compare_request(file_transfer_infoton &req,
175 const octopus_request_id &item_id);
176 basis::outcome handle_tree_compare_response(file_transfer_infoton &resp,
177 const octopus_request_id &item_id);
178 basis::outcome handle_storage_request(file_transfer_infoton &req,
179 const octopus_request_id &item_id);
180 basis::outcome handle_storage_response(file_transfer_infoton &resp,
181 const octopus_request_id &item_id);
182 basis::outcome conclude_storage_request(file_transfer_infoton &req,
183 const octopus_request_id &item_id);
184 basis::outcome conclude_storage_response(file_transfer_infoton &resp,
185 const octopus_request_id &item_id);
186};
187
188} //namespace.
189
190#endif
191
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
Outcomes describe the state of completion for an operation.
Definition outcome.h:31
An object that traverses directory trees and provides a view of all files.
Base objects used by the file transfer tentacle to schedule transfers.
Manages the transferrence of directory trees from one place to another.
bool add_path(const basis::astring &source_mapping, const basis::astring &new_path)
inserts the "new_path" into a registered correspondence.
basis::outcome cancel_file_transfer(const octopus_entity &ent, const basis::astring &src_root, const basis::astring &dest_root)
tosses a previously registered file transfer.
void unlock_directory()
unlock MUST be called when one is done looking at the tree.
DEFINE_CLASS_NAME("file_transfer_tentacle")
virtual void expunge(const octopus_entity &to_remove)
throws out any transfers occurring for the entity "to_remove".
bool status(const octopus_entity &ent, const basis::astring &src, const basis::astring &dest, double &total_size, int &total_files, double &current_size, int &current_files, bool &done, timely::time_stamp &last_active)
locates the transfer specified and returns information about it.
basis::outcome refresh_now(const basis::astring &source_mapping)
refreshes the "source_mapping" right now, regardless of the interval.
virtual basis::outcome reconstitute(const structures::string_array &classifier, basis::byte_array &packed_form, infoton *&reformed)
recreates a "reformed" infoton from its packed form.
bool remove_path(const basis::astring &source_mapping, const basis::astring &old_path)
deletes the "old_path" out of an existing correspondence.
bool get_differences(const octopus_entity &ent, const basis::astring &src, const basis::astring &dest, filesystem::filename_list &diffs)
accesses the list of difference for an ongoing transfer.
virtual basis::outcome consume(infoton &to_chow, const octopus_request_id &item_id, basis::byte_array &transformed)
processes the "to_chow" infoton as a file transfer request.
basis::outcome remove_correspondence(const basis::astring &source_mapping)
takes out the "source_mapping" which was previously added.
void periodic_actions()
drops timed out transfers.
basis::outcome add_correspondence(const basis::astring &source_mapping, const basis::astring &source_root, int refresh_interval)
adds a file transfer correspondence.
basis::astring text_form() const
returns a string representing the current state of transfers.
@ COMPARE_SIZE_AND_TIME
uses size and time to see differences.
@ COMPARE_ALL
compares all of the file size, file time, and contents.
@ ONLY_REPORT_DIFFS
no actual file transfer, just reports.
@ COMPARE_CONTENT_SAMPLE
samples parts of file for comparison.
basis::outcome register_file_transfer(const octopus_entity &ent, const basis::astring &src_root, const basis::astring &dest_root, const structures::string_array &include)
records a transfer that is going to commence.
filesystem::directory_tree * lock_directory(const basis::astring &source_mapping)
provides a view of the tentacle's current state.
An infoton is an individual request parcel with accompanying information.
Definition infoton.h:32
Provides a way of identifying users of an octopus object.
Definition entity_defs.h:35
Identifies requests made on an octopus by users.
provides prefab implementations for parts of the tentacle object.
An array of strings with some additional helpful methods.
Represents a point in time relative to the operating system startup time.
Definition time_stamp.h:38
Automates some common tasks for tentacle implementations. This template provides some default impleme...