4 //=============================================================================
6 * @file Locator_Request_Reply.h
10 //=============================================================================
13 #ifndef ACE_LOCATOR_REQUEST_REPLY_H
14 #define ACE_LOCATOR_REQUEST_REPLY_H
16 #include "URL_Properties.h"
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
31 ACE_URL_Locator_Request ();
34 ~ACE_URL_Locator_Request ();
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
,
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
,
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.
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.
95 /// Return the size of the buffer required to encode
104 // These constants used to indicate which pointers are valid.
106 /// Request type code.
109 /// Query method (if code_ == QUERY.)
112 /// How many offers are we interested in in this query.
115 /// Bit flag to mark valid pointers within this object.
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_
;
125 ACE_URL_Offer
*offer_
;
130 /// URL of this offer.
133 /// Buffer to store encoded data.
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
150 ACE_URL_Locator_Reply ();
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.
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.
190 /// Return the size of the buffer required to encode
198 // Valid pointer masks.
200 /// Holds the original op code.
203 /// Holds the result of an operation from the Location Server.
206 /// Holds the number of valid offers in the offers_ sequence.
209 /// Flag that marks valid internal pointers.
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.
221 #if defined (__ACE_INLINE__)
222 #include "Locator_Request_Reply.inl"
223 #endif /* __ACE_INLINE__ */
225 #endif /* ACE_LOCATOR_REQUEST_REPLY_H */