file_transfer_tentacle.h

Go to the documentation of this file.
00001 #ifndef FILE_TRANSFER_TENTACLE_CLASS
00002 #define FILE_TRANSFER_TENTACLE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : file_transfer_tentacle                                            *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2005-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "file_transfer_infoton.h"
00019 
00020 #include <octopus/tentacle_helper.h>
00021 
00022 // forward.
00023 class directory_tree;
00024 class file_transfer_cleaner;
00025 class file_transfer_status;
00026 class filename_list;
00027 class mutex;
00028 class time_stamp;
00029 
00031 
00038 class TENTACLES_CLASS_STYLE file_transfer_tentacle
00039 : public tentacle_helper<file_transfer_infoton>
00040 {
00041 public:
00042   file_transfer_tentacle(int maximum_transfer, bool only_provide_comparisons);
00044 
00050   virtual ~file_transfer_tentacle();
00051 
00052   IMPLEMENT_CLASS_NAME("file_transfer_tentacle");
00053 
00054   istring text_form() const;
00056 
00057   directory_tree *lock_directory(const istring &source_mapping);
00059   void unlock_directory();
00061 
00062   // these methods are for the "server" side--the side that has files to offer.
00063 
00064   outcome add_correspondence(const istring &source_mapping,
00065           const istring &source_root, int refresh_interval);
00067 
00076   outcome remove_correspondence(const istring &source_mapping);
00078 
00081   outcome refresh_now(const istring &source_mapping);
00083 
00086   bool add_path(const istring &source_mapping, const istring &new_path);
00088 
00090   bool remove_path(const istring &source_mapping, const istring &old_path);
00092 
00093   // these methods are for the client side--the side that wants to get files.
00094 
00095   outcome register_file_transfer(const octopus_entity &ent,
00096           const istring &src_root, const istring &dest_root,
00097           const string_array &include);
00099 
00105   outcome cancel_file_transfer(const octopus_entity &ent,
00106           const istring &src_root, const istring &dest_root);
00108 
00111   bool status(const octopus_entity &ent, const istring &src,
00112         const istring &dest, double &total_size, int &total_files,
00113         double &current_size, int &current_files, bool &done,
00114         time_stamp &last_active);
00116 
00122   bool get_differences(const octopus_entity &ent, const istring &src,
00123         const istring &dest, filename_list &diffs);
00125 
00127   // required tentacle methods...
00128 
00129   virtual outcome reconstitute(const string_array &classifier,
00130           byte_array &packed_form, infoton * &reformed);
00132 
00136   virtual outcome consume(infoton &to_chow, const octopus_request_id &item_id,
00137           byte_array &transformed);
00139 
00140   virtual void expunge(const octopus_entity &to_remove);
00142 
00143   // internal use only.
00144 
00145   void periodic_actions();  
00146 
00147 private:
00148   int _maximum_transfer;  
00149   file_transfer_status *_transfers;  
00150   file_transfer_status *_correspondences;  
00151   mutex *_lock;  
00152   file_transfer_cleaner *_cleaner;  
00153   bool _only_comparisons;  
00154 
00155   // these process the request and response infotons that are passed to us.
00156   outcome handle_tree_compare_request(file_transfer_infoton &req,
00157           const octopus_request_id &item_id);
00158   outcome handle_tree_compare_response(file_transfer_infoton &req,
00159           const octopus_request_id &item_id);
00160   outcome handle_storage_request(file_transfer_infoton &req,
00161           const octopus_request_id &item_id);
00162   outcome handle_storage_response(file_transfer_infoton &req,
00163           const octopus_request_id &item_id);
00164 };
00165 
00166 #endif
00167 

Generated on Thu Nov 20 04:29:06 2008 for HOOPLE Libraries by  doxygen 1.5.1