Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / clients / Blobby / Blob.h
blob2d27add07b2e0d88c5c5bf39ef762ae64192f788
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Blob.h
7 * This is the ACE_Blob class, which is the API for doing file
8 * uploads/downloads.
10 * @author Prashant Jain and Sumedh Mungee
12 //=============================================================================
15 #ifndef ACE_BLOB_H
16 #define ACE_BLOB_H
18 #include "ace/config-all.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/INET_Addr.h"
25 #include "ace/Svc_Handler.h"
26 #include "ace/SOCK_Connector.h"
27 #include "ace/Connector.h"
28 #include "ace/Message_Block.h"
29 #include "Blob_Handler.h"
31 /**
32 * @class ACE_Blob
34 * @brief Blob is intended to provide application API to
35 * classes that wish to do network i/o at a very
36 * high level of abstraction.
37 * = This class provides the ability to retrieve data from
38 * the network, of specified length and offset, and potentially
39 * use any protocol "under the hood" to do so. It currently
40 * uses HTTP. See Blob_Handler also.
42 class ACE_Blob
44 public:
45 ACE_Blob ();
46 ~ACE_Blob ();
48 /// initializes the class with the given filename, hostname and port.
49 /// it should be called with the filename, before any read/write calls
50 int open (const ACE_TCHAR *filename,
51 const ACE_TCHAR *hostname = ACE_DEFAULT_SERVER_HOST,
52 u_short port = 80);
55 /**
56 * starts a connection, and reads a file from the server,
57 * of length and offset as specified, into Message_Block mb
58 * The message block should have capacity to hold length number
59 * of bytes
61 int read (ACE_Message_Block *mb, size_t length, size_t offset);
63 /**
64 * starts a connection, and writes a file to the server,
65 * of length and offset as specified, from Message_Block mb
66 * thus the message block should contain atleast length + offset
67 * bytes of data
69 int write (ACE_Message_Block *mb, size_t length, size_t offset);
72 /// Frees memory allocated for filename.
73 int close ();
75 private:
76 /// store the internet address of the server
77 ACE_INET_Addr inet_addr_;
79 /// The filename
80 ACE_TCHAR *filename_;
82 /// The connector endpoint to initiate the client connection
83 ACE_Connector<ACE_Blob_Handler, ACE_SOCK_CONNECTOR> connector_;
86 #endif /* ACE_BLOB_H */