// -*- indent-tabs-mode: nil -*- #ifndef __ARC_DATAEXTERNALCOMM_H__ #define __ARC_DATAEXTERNALCOMM_H__ #include #include #include #include namespace Arc { class DataExternalComm { public: static char const ErrorTag; static char const DataStatusTag; static char const FileInfoTag; static char const DataChunkTag; static char const TransferStatusTag; template static bool InEntry(std::istream& instream, T& entry) { try { instream>>entry; return true; } catch(std::exception const&) { } return false; } template static void OutEntry(Arc::Run& run, int timeout, T& entry) { std::ostringstream ostream; ostream<::iterator chunk_iterator; DataChunkClientList() {}; ~DataChunkClientList() { for(chunk_iterator it = chunk_list.begin(); it != chunk_list.end(); ++it) delete *it; }; class iterator: public chunk_iterator { public: iterator(chunk_iterator const& other):chunk_iterator(other) {}; DataChunkClient& operator*() { return *(chunk_iterator::operator*()); }; DataChunkClient* operator->() { return chunk_iterator::operator*(); }; DataChunkClient* get() { return chunk_iterator::operator*(); }; }; //typedef std::list::iterator iterator; void erase(iterator it) { delete it.get(); chunk_list.erase(it); }; void clear() { for(chunk_iterator it = chunk_list.begin(); it != chunk_list.end(); ++it) delete *it; chunk_list.clear(); }; iterator begin() { return chunk_list.begin(); }; iterator end() { return chunk_list.end(); }; bool empty() const { return chunk_list.empty(); }; std::size_t size() const { return chunk_list.size(); }; void push_back(DataChunkClient& source) { chunk_list.push_back(new DataChunkClient(source)); }; private: std::list chunk_list; }; static bool OutEntry(Arc::Run& run, int timeout, DataChunkExtBuffer const& data); static bool InEntry(Arc::Run& run, int timeout, DataChunkExtBuffer& data); static bool OutEntry(std::ostream& outstream, DataChunkClient const& data); static bool InEntry(std::istream& instream, DataChunkClient& data); }; // class DataExternalComm } // namespace Arc #endif // __ARC_DATAEXTERNALCOMM_H__