3 //=============================================================================
7 * Header file for the Web_Server::Callback implementation.
9 * @author Ossama Othman <ossama@uci.edu>
11 //=============================================================================
17 #include "ace/FILE_Addr.h"
18 #include "ace/FILE_IO.h"
19 #include "Push_Web_ServerS.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 // Implement the Web_Server::Callback interface.
27 public virtual POA_Web_Server::Callback
30 // Implement the Web_Server::Callback interface.
33 // A <Callback> object implements the Observer pattern. It
34 // simply "watches" while the Content Server pushes chunks of
35 // data to itself. Once the Content Server pushes the last chunk
36 // of data, the <Callback> object spawns an external viewer to
37 // display the pushed data based on the data content type
38 // returned by the Iterator_Factory::register_callback() method.
40 // Since the server pushes data to the <Callback> object
41 // asynchronously, and since instances of this <Callback> class
42 // are registered with the Content Server asynchronously, there
43 // is no guarantee that the metadata containing the content type
44 // will arrive before the content of the file. As such, this
45 // class atomically sets and checks the flags that provide the
46 // current condition of the metadata and content, in case two
47 // concurrently running threads attempt to update the state
48 // contained within a given <Callback> object.
50 /// Dummy friend class declaration to quiet down a warning.
51 friend class Callback_i_Friend
;
55 Callback_i (int *request_count
);
57 /// This operation returns the next <chunk> of the file starting at
58 /// <offset>. If there are no more bindings, false is returned.
59 virtual void next_chunk (const Web_Server::Chunk_Type
&chunk
,
60 CORBA::Boolean last_chunk
);
62 /// Set metadata associated with received data.
63 void metadata (const Web_Server::Metadata_Type
&metadata
);
66 /// Destructor must be private to ensure that this object is
67 /// allocated on the heap.
70 /// Returns one if the metadata was received, and zero otherwise.
71 int metadata_received ();
73 /// Returns one if the entire content was received, and zero
75 int content_received ();
77 /// Get the name of the viewer associated with the file being
79 int get_viewer (char *viewer
, size_t length
);
81 /// Spawn an external view to display the retrieved file.
85 /// Deactivate this Callback servant.
89 /// The Addr corresponding to the retrieved file.
92 /// The object that provides all file related IO operations
93 /// (e.g. read, write, etc).
96 /// Reference to this Reply Handler's self.
97 Web_Server::AMI_CallbackHandler_var ami_handler_
;
99 /// The metadata associated with the file being retrieved from the
101 Web_Server::Metadata_Type metadata_
;
103 /// Flag that indicates entire data content has been received.
106 /// Lock used to prevent race conditions when checking to see if
107 /// metadata or entire content has been received.
108 TAO_SYNCH_MUTEX lock_
;
111 * Pointer to external status monitoring variable. The contents (not
112 * the pointer itself) of the <pending_data> parameter will be
113 * decremented when file retrieval has completed.
118 #endif /* CALLBACK_I_H */