Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / clients / Caching / Locator_Request_Reply.h
blob4653f3cc74e707e6d9c111db6cfcbb9d5dfd6139
1 /* -*- C++ -*- */
4 //=============================================================================
5 /**
6 * @file Locator_Request_Reply.h
8 * @author Nanbor Wang
9 */
10 //=============================================================================
13 #ifndef ACE_LOCATOR_REQUEST_REPLY_H
14 #define ACE_LOCATOR_REQUEST_REPLY_H
16 #include "URL_Properties.h"
18 /**
19 * @class ACE_URL_Locator_Request
21 * @brief A URL request message formater/wrapper.
23 * This class defines a URL request data. It is used
24 * to transform requests to an object so that we can
25 * ship them across network.
27 class ACE_Svc_Export ACE_URL_Locator_Request
29 public:
30 /// Default ctor.
31 ACE_URL_Locator_Request ();
33 /// Default dtor.
34 ~ACE_URL_Locator_Request ();
36 /**
37 * Query the locator for HTTP with designate properties (none, some,
38 * or all). The locator being queried will return a sequence of
39 * offers with <how_many> offers in it. This interface allocates
40 * <offer> so users must deallocate it after use.
42 int url_query (const int how,
43 const ACE_URL_Property_Seq &pseq,
44 const int how_many);
46 /// Export an offer to the locator.
47 int export_offer (const ACE_URL_Offer &offer);
49 /// Withdraw an offer. return 0 if succeed, -1 otherwise.
50 int withdraw_offer (const ACE_WString &offer_id);
52 /// Query a specific offer.
53 int describe_offer (const ACE_WString &offer_id);
55 /// Modify a previously registered offer.
56 int modify_offer (const ACE_WString &offer_id,
57 const char *url = 0,
58 const ACE_URL_Property_Seq &del = 0,
59 const ACE_URL_Property_Seq &modify = 0);
61 /// Modify a previously registered offer.
62 int modify_offer (const ACE_WString &offer_id,
63 const ACE_WString *url = 0,
64 const ACE_URL_Property_Seq &del = 0,
65 const ACE_URL_Property_Seq &modify = 0);
67 /// Encode request for network communication. If succeed,
68 /// returns the size of the buffer, otherwise, return 0.
69 size_t encode ();
71 /**
72 * Restore from network data. Returns size of the buffer
73 * if succeed, 0 otherwise. When passing in a buffer,
74 * caller must take the responsibility to delete the buffer
75 * afterward, if so needed.
77 size_t decode (void *buffer);
79 /// A bunch of methods to access internal data.
80 const int how () const;
81 const int how_many () const;
82 const u_int opcode () const;
83 const ACE_URL_Property_Seq *seq () const;
84 const ACE_URL_Property_Seq *del () const;
85 const ACE_URL_Property_Seq *modify () const;
86 const ACE_URL_Offer *offer () const;
87 const ACE_WString &id () const;
88 const ACE_WString &url () const;
89 const char *buffer () const;
91 /// Print out this object.
92 void dump () const;
94 protected:
95 /// Return the size of the buffer required to encode
96 /// this request.
97 size_t size ();
99 enum {
100 VALID_SEQ1 = 0x1,
101 VALID_SEQ2 = 0X2,
102 VALID_OFFER = 0X4
104 // These constants used to indicate which pointers are valid.
106 /// Request type code.
107 u_int code_;
109 /// Query method (if code_ == QUERY.)
110 int how_;
112 /// How many offers are we interested in in this query.
113 int how_many_;
115 /// Bit flag to mark valid pointers within this object.
116 int valid_ptr_;
118 /// For query or del in modify_offer.
119 ACE_URL_Property_Seq *seq1_;
121 /// For modify seq. in modify_offer.
122 ACE_URL_Property_Seq *seq2_;
124 /// Offer to export.
125 ACE_URL_Offer *offer_;
127 /// Offer ID.
128 ACE_WString id_;
130 /// URL of this offer.
131 ACE_WString url_;
133 /// Buffer to store encoded data.
134 char *buffer_;
138 * @class ACE_URL_Locator_Reply
140 * @brief A URL reply message formater/wrapper.
142 * This class defines a URL reply data. It is used
143 * to transform reply messages to an object so that we can
144 * ship them across network.
146 class ACE_Svc_Export ACE_URL_Locator_Reply
148 public:
149 /// Default ctor.
150 ACE_URL_Locator_Reply ();
152 /// Default dtor.
153 ~ACE_URL_Locator_Reply ();
155 /// Setup a reply message for EXPORT, WITHDRAW, or MODIFY operations.
156 int status_reply (u_int op, int result);
158 /// Setup a reply for QUERY operation.
159 int query_reply (int result, size_t num,
160 const ACE_URL_Offer_Seq &offers);
162 /// Construct a reply for DESCRIBE operation.
163 int describe_reply (int result,
164 const ACE_URL_Offer &offer);
166 /// Encode request for network communication. If succeed,
167 /// returns the size of the buffer, otherwise, return 0.
168 size_t encode ();
171 * Restore from network data. Returns size of the buffer
172 * if succeed, 0 otherwise. When passing in a buffer,
173 * caller must take the responsibility to delete the buffer
174 * afterward, if so needed.
176 size_t decode (void *buffer);
178 // Accessor function.
179 const size_t num_offers () const;
180 const ACE_URL_Offer *offer () const;
181 const ACE_URL_Offer_Seq *offers () const;
182 const u_int opcode () const;
183 const u_int status () const;
184 const char *buffer () const ;
186 /// Print out this object.
187 void dump () const ;
189 protected:
190 /// Return the size of the buffer required to encode
191 /// this request.
192 size_t size ();
194 enum {
195 VALID_OFFER = 0x1,
196 VALID_OFFERS = 0x2
198 // Valid pointer masks.
200 /// Holds the original op code.
201 u_int code_;
203 /// Holds the result of an operation from the Location Server.
204 int status_;
206 /// Holds the number of valid offers in the offers_ sequence.
207 size_t num_offers_;
209 /// Flag that marks valid internal pointers.
210 int valid_ptr_;
212 /// Holds a single offer. Used in query offer property.
213 ACE_URL_Offer *offer_;
215 /// Holds the replying offer sequence from a Locator.
216 ACE_URL_Offer_Seq *offers_;
218 /// Buffer to store encoded data.
219 char *buffer_;
221 #if defined (__ACE_INLINE__)
222 #include "Locator_Request_Reply.inl"
223 #endif /* __ACE_INLINE__ */
225 #endif /* ACE_LOCATOR_REQUEST_REPLY_H */