summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/JAWS/clients/Caching/Local_Locator.cpp76
-rw-r--r--apps/JAWS/clients/Caching/Local_Locator.h14
-rw-r--r--apps/JAWS/clients/Caching/Locator_Request_Reply.cpp302
-rw-r--r--apps/JAWS/clients/Caching/Locator_Request_Reply.h142
-rw-r--r--apps/JAWS/clients/Caching/Locator_Request_Reply.i64
-rw-r--r--apps/JAWS/clients/Caching/Makefile18
-rw-r--r--apps/JAWS/clients/Caching/URL_Locator.h36
-rw-r--r--apps/JAWS/clients/Caching/URL_Properties.h4
8 files changed, 458 insertions, 198 deletions
diff --git a/apps/JAWS/clients/Caching/Local_Locator.cpp b/apps/JAWS/clients/Caching/Local_Locator.cpp
index 66a879ea145..9799a4f21b3 100644
--- a/apps/JAWS/clients/Caching/Local_Locator.cpp
+++ b/apps/JAWS/clients/Caching/Local_Locator.cpp
@@ -19,11 +19,9 @@ ACE_URL_Local_Locator::url_query (const ACE_URL_Locator::ACE_Selection_Criteria
{
ACE_URL_Record *item = 0;
- // Nanbor, do you really want to return NOMEM, or -1 (since errno
- // will already be set to ENOMEM by the ACE_NEW_RETURN macro).
- ACE_NEW_RETURN (offer, ACE_URL_Offer_Seq (how_many), ACE_URL_Locator::NOMEM);
+ ACE_NEW_RETURN (offer, ACE_URL_Offer_Seq (how_many), -1);
- for (ACE_Unbounded_Stack_Iterator<ACE_URL_Record> iter (this->repository_);
+ for (ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_);
iter.next (item) != 0;
iter.advance ())
{
@@ -31,30 +29,30 @@ ACE_URL_Local_Locator::url_query (const ACE_URL_Locator::ACE_Selection_Criteria
{
case ACE_URL_Locator::NONE:
// Offers must not have any properties in <pseq>
- return ACE_URL_Locator::UNIMPLEMENTED;
+ errno = ACE_URL_Locator::UNIMPLEMENTED;
+ return -1;
break;
case ACE_URL_Locator::SOME:
// Offers must have at least one property in <pseq>
- return ACE_URL_Locator::UNIMPLEMENTED;
+ errno = ACE_URL_Locator::UNIMPLEMENTED;
+ return -1;
break;
case ACE_URL_Locator::ALL:
// Offers must have all the properties in <pseq>
- return ACE_URL_Locator::UNIMPLEMENTED;
+ errno = ACE_URL_Locator::UNIMPLEMENTED;
+ return -1;
break;
default:
delete [] offer ;
offer = 0;
- return ACE_URL_Locator::INVALID_ARGUMENT;
+ errno = ACE_URL_Locator::INVALID_ARGUMENT;
+ return -1;
}
if (how_many == 0)
break;
}
- // Nanbor, I recommend just returning 0 for success and -1 for
- // failure. That is more consistent with the rest of ACE. In
- // general, it's a better idea to use errno to indicate *which*
- // error occurred, and -1 to indicate to the caller to check errno.
- return ACE_URL_Locator::OK;
+ return 0;
}
int
@@ -64,23 +62,25 @@ ACE_URL_Local_Locator::export_offer (ACE_URL_Offer *offer,
ACE_URL_Record *item = 0;
// First check if we have registered this URL already.
- for (ACE_Unbounded_Stack_Iterator<ACE_URL_Record> iter (this->repository_);
+ for (ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_);
iter.next (item) != 0;
iter.advance ())
if (*item->offer_->url () == *offer->url ())
- // Nanbor, here's a good example of where it might make more
- // sense to set errno to EEXIST and return -1.
- return ACE_URL_Locator::OFFER_EXIST;
-
+ {
+ errno = ACE_URL_Locator::OFFER_EXIST;
+ return -1;
+ }
+
ACE_URL_Record *new_offer;
+ // Offer is not in repository, we can add new one in safely.
ACE_NEW_RETURN (new_offer, ACE_URL_Record (offer),
ACE_URL_Locator::NOMEM);
this->repository_.push (*new_offer);
offer_id = *new_offer->id_;
- return ACE_URL_Locator::OK;
+ return 0;
}
int
@@ -88,19 +88,23 @@ ACE_URL_Local_Locator::withdraw_offer (const ACE_WString &offer_id)
{
ACE_URL_Record *item = 0;
- // Nanbor, please make sure that you comment code like this.
- for (ACE_Unbounded_Stack_Iterator<ACE_URL_Record> iter (this->repository_);
+ // Iterate thru repository and remove offer with <offer_id>.
+ for (ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_);
iter.next (item) != 0;
iter.advance ())
if (offer_id == *item->id_)
{
if (this->repository_.remove (*item) == 0)
- return ACE_URL_Locator::OK;
+ return 0
else
- return ACE_URL_Locator::UNKNOWN;
+ {
+ errno = ACE_URL_Locator::UNKNOWN;
+ return -1;
+ }
}
- return ACE_URL_Locator::NO_SUCH_OFFER;
+ errno = ACE_URL_Locator::NO_SUCH_OFFER;
+ return 0;
}
int
@@ -109,18 +113,19 @@ ACE_URL_Local_Locator::describe_offer (const ACE_WString &offer_id,
{
ACE_URL_Record *item = 0;
- // Nanbor, please make sure that you comment this code.
- for (ACE_Unbounded_Stack_Iterator<ACE_URL_Record> iter (this->repository_);
+ // Iterate thru the repository and produce a copy of offer's
+ // description.
+ for (ACE_Unbounded_Set_Iterator<ACE_URL_Record> iter (this->repository_);
iter.next (item) != 0;
iter.advance ())
if (offer_id == *item->id_)
{
- ACE_NEW_RETURN (offer, ACE_URL_Offer (*item->offer_),
- ACE_URL_Locator::NOMEM);
- return ACE_URL_Locator::OK;
+ ACE_NEW_RETURN (offer, ACE_URL_Offer (*item->offer_), -1);
+ return 0;
}
- return ACE_URL_Locator::NO_SUCH_OFFER;
+ errno = ACE_URL_Locator::NO_SUCH_OFFER;
+ return -1;
}
int
@@ -129,16 +134,17 @@ ACE_URL_Local_Locator::modify_offer (const ACE_WString &offer_id,
const ACE_URL_Property_Seq *del,
const ACE_URL_Property_Seq *modify)
{
- return ACE_URL_Locator::UNIMPLEMENTED;
+ errno = ACE_URL_Locator::UNIMPLEMENTED;
+ return -1;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Unbounded_Stack<ACE_URL_Record>;
-template class ACE_Unbounded_Stack_Iterator<ACE_URL_Record>;
+template class ACE_Unbounded_Set<ACE_URL_Record>;
+template class ACE_Unbounded_Set_Iterator<ACE_URL_Record>;
template class ACE_Node<ACE_URL_Record>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Unbounded_Stack<ACE_URL_Record>
-#pragma instantiate ACE_Unbounded_Stack_Iterator<ACE_URL_Record>
+#pragma instantiate ACE_Unbounded_Set<ACE_URL_Record>
+#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_URL_Record>
#pragma instantiate ACE_Node<ACE_URL_Record>
#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
#endif /* ACE_LOCAL_LOCATOR_C */
diff --git a/apps/JAWS/clients/Caching/Local_Locator.h b/apps/JAWS/clients/Caching/Local_Locator.h
index 0c85c6d5425..bcc82cef566 100644
--- a/apps/JAWS/clients/Caching/Local_Locator.h
+++ b/apps/JAWS/clients/Caching/Local_Locator.h
@@ -33,9 +33,11 @@ class ACE_URL_Record
// out of scope.
{
friend class ACE_URL_Local_Locator;
- // Nanbor, is it really necessary to have ACE_Node<> as a friend?
- // That seems like it breaks encapsulation.
friend class ACE_Node<ACE_URL_Record>;
+ // We are making ACE_Node as friend class because we don't want
+ // others to access default constructor and pushing in an invalid
+ // record. However, container classes need to use default constructor
+ // for its head record.
public:
ACE_URL_Record (ACE_URL_Offer *offer);
// ctor.
@@ -51,8 +53,8 @@ public:
private:
ACE_URL_Record (void);
- // Nanbor, please explain why this is private.
- // default ctor.
+ // Default ctor. This is put here to prevent users from
+ // pushing in an invalid record.
ACE_WString *id_;
// Offer ID in the repository.
@@ -101,9 +103,7 @@ class ACE_Export ACE_URL_Local_Locator
// Modify a previously registered offer.
protected:
- ACE_Unbounded_Stack<ACE_URL_Record> repository_;
- // Nanbor, please add a comment here. In particular, why do you use
- // a stack rather than, e.g., a set?
+ ACE_Unbounded_Set<ACE_URL_Record> repository_;
};
#if defined (__ACE_INLINE__)
diff --git a/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp b/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp
index dc762835ac2..0582c3e702c 100644
--- a/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp
+++ b/apps/JAWS/clients/Caching/Locator_Request_Reply.cpp
@@ -28,7 +28,7 @@ ACE_URL_Locator_Request::url_query (const int how,
ACE_NEW_RETURN (this->seq1_, ACE_URL_Property_Seq (pseq), -1);
this->how_ = how;
this->how_many_ = how_many;
- this->code_ = ACE_URL_Locator_Request::QUERY;
+ this->code_ = ACE_URL_Locator::QUERY;
return 0;
}
@@ -38,7 +38,7 @@ ACE_URL_Locator_Request::export_offer (const ACE_URL_Offer &offer)
ACE_TRACE ("ACE_URL_Locator_Request::export_offer");
ACE_NEW_RETURN (this->offer_, ACE_URL_Offer (offer), -1);
- this->code_ = ACE_URL_Locator_Request::EXPORT;
+ this->code_ = ACE_URL_Locator::EXPORT;
return 0;
}
@@ -48,7 +48,7 @@ ACE_URL_Locator_Request::withdraw_offer (const ACE_WString &offer_id)
ACE_TRACE ("ACE_URL_Locator_Request::withdraw_offer");
this->id_ = offer_id;
- this->code_ = ACE_URL_Locator_Request::WITHDRAW;
+ this->code_ = ACE_URL_Locator::WITHDRAW;
return 0;
}
@@ -58,7 +58,7 @@ ACE_URL_Locator_Request::describe_offer (const ACE_WString &offer_id)
ACE_TRACE ("ACE_URL_Locator_Request::describe_offer");
this->id_ = offer_id;
- this->code_ = ACE_URL_Locator_Request::DESCRIBE;
+ this->code_ = ACE_URL_Locator::DESCRIBE;
return 0;
}
@@ -77,17 +77,17 @@ ACE_URL_Locator_Request::modify_offer (const ACE_WString &offer_id,
this->url_ = *url;
this->id_ = offer_id;
- this->code_ = ACE_URL_Locator_Request::MODIFY;
+ this->code_ = ACE_URL_Locator::MODIFY;
return 0;
}
#define ENCODE_UINT32(ADDR,LEN,V) \
* (ACE_UINT32 *) (ADDR+LEN) = htonl (V); \
- total_length += sizeof (ACE_UINT32);
+ LEN += sizeof (ACE_UINT32);
#define DECODE_UINT32(ADDR,LEN,V) \
V = ntohl (* (ACE_UINT32 *) (ADDR+LEN)); \
- total_length += sizeof (ACE_UINT32);
+ LEN += sizeof (ACE_UINT32);
size_t
ACE_URL_Locator_Request::encode (void)
@@ -95,40 +95,37 @@ ACE_URL_Locator_Request::encode (void)
ACE_TRACE ("ACE_URL_Locator_Request::encode");
size_t buf_size = this->bsize ();
+ size_t total_length = 0;
ACE_NEW_RETURN (this->buffer_, char [buf_size], 0);
- ((ACE_UINT32 *) this->buffer_)[0] = htonl (buf_size);
- ((ACE_UINT32 *) this->buffer_)[1] = htonl (this->code_);
- size_t total_length = 2 * sizeof (ACE_UINT32);
+
+ ENCODE_UINT32 (this->buffer_, total_length, buf_size);
+ // Encode buffer size.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->code_);
+ // Encode Op code.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->how_);
+ // Encode selection criteria.
- switch (this->code_)
- {
- case ACE_URL_Locator_Request::QUERY:
- ENCODE_UINT32 (this->buffer_, total_length, this->how_);
- ENCODE_UINT32 (this->buffer_, total_length, this->how_many_);
- total_length += ace_array_encode (this->buffer_ + total_length, *this->seq1_);
- break;
- case ACE_URL_Locator_Request::EXPORT:
- total_length += this->offer_->encode (this->buffer_ + total_length);
- break;
- case ACE_URL_Locator_Request::WITHDRAW:
- case ACE_URL_Locator_Request::DESCRIBE:
- total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
- &this->id_);
- break;
- case ACE_URL_Locator_Request::MODIFY:
- total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
- &this->id_);
- total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
- &this->url_);
- total_length += ace_array_encode (this->buffer_ + total_length, *this->seq1_);
- total_length += ace_array_encode (this->buffer_ + total_length, *this->seq2_);
- break;
- default:
- // Invalid data encountered. Stop encoding now.
- return 0;
- break;
- }
+ ENCODE_UINT32 (this->buffer_, total_length, this->how_many_);
+ // Encode number of offers interested.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->valid_ptr_);
+ // Encode valide pointer flag.
+
+ if (this->seq1_ != 0)
+ total_length += ace_array_encode (this->buffer_ + total_length, *this->seq1_);
+ if (this->seq2_ != 0)
+ total_length += ace_array_encode (this->buffer_ + total_length, *this->seq2_);
+ if (this->offer_ != 0)
+ total_length += this->offer_->encode (this->buffer_ + total_length);
+
+ total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
+ &this->id_);
+ total_length += ACE_WString_Helper::encode (this->buffer_ + total_length,
+ &this->url_);
+
ACE_ASSERT (total_length == buf_size);
return total_length;
}
@@ -144,92 +141,97 @@ ACE_URL_Locator_Request::decode (void *buffer)
delete [] this->buffer_;
this->buffer_ = (char*) buffer;
- size_t buf_size = ntohl (((ACE_UINT32 *) this->buffer_)[0]);
- this->code_ = ntohl (((ACE_UINT32 *) this->buffer_)[1]);
+ size_t buf_size = 0;
+ size_t total_length = 0;
+
+ DECODE_UINT32 (this->buffer_, total_length, buf_size);
+ // Decode length of buffer size first.
+
+ DECODE_UINT32 (this->buffer_, total_length, this->code_);
// Get the operation code.
- size_t total_length = 2 * sizeof (ACE_UINT32);
+ DECODE_UINT32 (this->buffer_, total_length, this->how_);
+ // Decode selection criteria.
+
+ DECODE_UINT32 (this->buffer_, total_length, this->how_many_);
+ // Decode number of offers interested.
- switch (this->code_)
+ DECODE_UINT32 (this->buffer_, total_length, this->valid_ptr_);
+ // Decode valide pointer flag.
+
+ if (this->valid_ptr_ | VALID_SEQ1 != 0)
{
- case ACE_URL_Locator_Request::QUERY:
- DECODE_UINT32 (this->buffer_, total_length, this->how_);
- DECODE_UINT32 (this->buffer_, total_length, this->how_many_);
- delete this->seq1_;
ACE_NEW_RETURN (this->seq1_, ACE_URL_Property_Seq (1), 0);
total_length += ace_array_decode (this->buffer_ + total_length, *this->seq1_);
- break;
- case ACE_URL_Locator_Request::EXPORT:
- delete this->offer_;
- ACE_NEW_RETURN (this->offer_, ACE_URL_Offer, 0);
- total_length += this->offer_->decode (this->buffer_);
- break;
- case ACE_URL_Locator_Request::WITHDRAW:
- case ACE_URL_Locator_Request::DESCRIBE:
- total_length = ACE_WString_Helper::decode (this->buffer_ + total_length);
- this->id_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
- break;
- case ACE_URL_Locator_Request::MODIFY:
- total_length += ACE_WString_Helper::decode (this->buffer_ + total_length);
- this->id_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
- total_length += ACE_WString_Helper::decode (this->buffer_ + total_length);
- this->url_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
- ACE_NEW_RETURN (this->seq1_, ACE_URL_Property_Seq (1), 0);
+ }
+ if (this->valid_ptr_ | VALID_SEQ2 != 0)
+ {
ACE_NEW_RETURN (this->seq2_, ACE_URL_Property_Seq (1), 0);
- total_length += ace_array_decode (this->buffer_ + total_length, *this->seq1_);
total_length += ace_array_decode (this->buffer_ + total_length, *this->seq2_);
- break;
- default:
- // Invalid data encountered. Stop encoding now.
- return 0;
- break;
}
+ if (this->valid_ptr_ | VALID_OFFER != 0)
+ {
+ ACE_NEW_RETURN (this->offer_, ACE_URL_Offer, 0);
+ total_length += this->offer_->decode (this->buffer_ + total_length);
+ }
+
+ total_length += ACE_WString_Helper::decode (this->buffer_ + total_length);
+ this->id_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
+ total_length += ACE_WString_Helper::decode (this->buffer_ + total_length);
+ this->url_ = ACE_WString ((ACE_USHORT16 *) (this->buffer_ + total_length));
+
+ ACE_ASSERT (total_length == buf_size);
+ return total_length;
}
size_t
-ACE_URL_Locator_Request::bsize (void) const
+ACE_URL_Locator_Request::bsize (void)
{
ACE_TRACE ("ACE_URL_Locator_Request::bsize");
- size_t total_length = 2 * sizeof (ACE_UINT32);
-
- switch (this->code_)
+ size_t total_length = 5 * sizeof (ACE_UINT32);
+ // There are 5 UINT32 variables at the beginning
+ // of the buffer. <buffer size>, <code>, <how>,
+ // <how_many>, <valid_ptr>.
+
+ this->valid_ptr_ = 0;
+ // Check valid pointers and mark corresponding flag in <valid_prt>.
+
+ if (this->seq1_ != 0)
{
- case ACE_URL_Locator_Request::QUERY:
- total_length += 2 * sizeof (ACE_UINT32);
- total_length += ace_array_bsize (*this->seq1_);
- break;
- case ACE_URL_Locator_Request::EXPORT:
- total_length += this->offer_->bsize ();
- break;
- case ACE_URL_Locator_Request::WITHDRAW:
- case ACE_URL_Locator_Request::DESCRIBE:
- total_length += ACE_WString_Helper::bsize (&this->id_);
- break;
- case ACE_URL_Locator_Request::MODIFY:
- total_length += ACE_WString_Helper::bsize (&this->id_);
- total_length += ACE_WString_Helper::bsize (&this->url_);
+ this->valid_ptr_ |= VALID_SEQ1;
total_length += ace_array_bsize (*this->seq1_);
+ }
+ if (this->seq2_ != 0)
+ {
+ this->valid_ptr_ |= VALID_SEQ2;
total_length += ace_array_bsize (*this->seq2_);
- break;
- default:
- // Invalid data encountered. Stop encoding now.
- return 0;
- break;
}
+ if (this->offer_ != 0)
+ {
+ this->valid_ptr_ |= VALID_OFFER;
+ total_length += this->offer_->bsize ();
+ }
+
+ total_length += ACE_WString_Helper::bsize (&this->id_);
+ total_length += ACE_WString_Helper::bsize (&this->url_);
+
return total_length;
}
void
ACE_URL_Locator_Request::dump (void) const
{
+ //ACE_TRACE ("ACE_URL_Locator_Request::dump");
+
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ size_t i;
switch (this->code_)
{
- case ACE_URL_Locator_Request::QUERY:
+ case ACE_URL_Locator::QUERY:
ACE_DEBUG ((LM_DEBUG, "Query Request:\nSelection: "));
switch (this->how_)
{
@@ -247,18 +249,19 @@ ACE_URL_Locator_Request::dump (void) const
break;
}
ACE_DEBUG ((LM_DEBUG, "At most %d reply.\n", this->how_many_));
- this->seq1_->dump ();
+ for (i = 0; i < this->seq1_->size (); i++)
+ (*this->seq1_)[i].dump ();
break;
- case ACE_URL_Locator_Request::EXPORT:
+ case ACE_URL_Locator::EXPORT:
ACE_DEBUG ((LM_DEBUG, "Export Request:\n"));
break;
- case ACE_URL_Locator_Request::WITHDRAW:
+ case ACE_URL_Locator::WITHDRAW:
ACE_DEBUG ((LM_DEBUG, "Withdraw Request:\n"));
break;
- case ACE_URL_Locator_Request::DESCRIBE:
+ case ACE_URL_Locator::DESCRIBE:
ACE_DEBUG ((LM_DEBUG, "Describe Request:\n"));
break;
- case ACE_URL_Locator_Request::MODIFY:
+ case ACE_URL_Locator::MODIFY:
ACE_DEBUG ((LM_DEBUG, "Modify Request:\n"));
break;
default:
@@ -270,4 +273,107 @@ ACE_URL_Locator_Request::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
+int
+ACE_URL_Locator_Reply::status_reply (u_int op, int result)
+{
+ ACE_TRACE ("ACE_URL_Locator_Reply::status_reply");
+
+ this->code_ = op;
+ this->status_ = result;
+ return 0;
+}
+
+int
+ACE_URL_Locator_Reply::query_reply (int result, size_t num,
+ const ACE_URL_Offer_Seq &offers)
+{
+ ACE_TRACE ("ACE_URL_Locator_Reply::query_reply");
+
+ this->code_ = ACE_URL_Locator::QUERY;
+ this->status_ = result;
+ ACE_NEW_RETURN (this->offers_, ACE_URL_Offer_Seq (offers), -1);
+ return 0;
+}
+
+int
+ACE_URL_Locator_Reply::describe_reply (int result,
+ const ACE_URL_Offer &offer)
+{
+ ACE_TRACE ("ACE_URL_Locator_Reply::describe_reply");
+
+ this->code_ = ACE_URL_Locator::DESCRIBE;
+ this->status_ = result;
+ ACE_NEW_RETURN (this->offer_, ACE_URL_Offer (offer), -1);
+ return 0;
+}
+
+size_t
+ACE_URL_Locator_Reply::encode (void)
+{
+ ACE_TRACE ("ACE_URL_Locator_Reply::encode");
+
+ size_t buf_size = this->bsize ();
+ size_t total_length = 0;
+
+ ACE_NEW_RETURN (this->buffer_, char [buf_size], 0);
+
+ ENCODE_UINT32 (this->buffer_, total_length, buf_size);
+ // Encode buffer size.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->code_);
+ // Encode Op code.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->status_);
+ // Encode Op result status.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->num_offers_);
+ // Encode number of offers in this->offers_.
+
+ ENCODE_UINT32 (this->buffer_, total_length, this->valid_ptr_);
+ // Encode valid pointers mask.
+
+ // Encode request for network communication. If succeed,
+ // returns the size of the buffer, otherwise, return 0.
+ return 0;
+}
+
+size_t
+ACE_URL_Locator_Reply::decode (void *buffer)
+{
+ ACE_TRACE ("ACE_URL_Locator_Reply::decode");
+
+ // Restore from network data. Returns size of the buffer
+ // if succeed, 0 otherwise.
+ return 0;
+}
+
+size_t
+ACE_URL_Locator_Reply::bsize (void)
+{
+ ACE_TRACE ("ACE_URL_Locator_Reply:bsize");
+
+ size_t total_length = 5 * sizeof (ACE_UINT32);
+ // size for 5 ACE_UINT32 objects: <buffer size>, <code_>,
+ // <status_>, <num_offers_>, and <valid_ptr_>.
+
+ this->valid_ptr_ = 0;
+ if (this->offer_ != 0)
+ {
+ this->valid_ptr_ |= VALID_OFFER;
+ total_length += this->offer_->bsize ();
+ }
+ if (this->offers_ != 0)
+ {
+ this->valid_ptr_ |= VALID_OFFERS;
+ total_length += ace_array_bsize (this->offers_);
+ }
+ return total_length;
+}
+
+void
+ACE_URL_Locator_Reply::dump (void) const
+{
+ //ACE_TRACE ("ACE_URL_Locator_Reply::dump");
+
+}
#endif /* ACE_LOCATOR_REQUEST_REPLY_C */
diff --git a/apps/JAWS/clients/Caching/Locator_Request_Reply.h b/apps/JAWS/clients/Caching/Locator_Request_Reply.h
index 64f7485aa6d..31f32c78a85 100644
--- a/apps/JAWS/clients/Caching/Locator_Request_Reply.h
+++ b/apps/JAWS/clients/Caching/Locator_Request_Reply.h
@@ -21,25 +21,15 @@
#include "URL_Properties.h"
class ACE_Export ACE_URL_Locator_Request
-// Nanbor, please make sure you explain what this class is *used* for!
// = TITLE
// A URL request message formater/wrapper.
//
// = DESCRIPTION
- // This class defines a URL request data.
+ // This class defines a URL request data. It is used
+ // to transform requests to an object so that we can
+ // ship them across network.
{
public:
- enum ACE_URL_Locator_Request_Type
- {
- QUERY,
- EXPORT,
- WITHDRAW,
- DESCRIBE,
- MODIFY,
- INVALID_REQUEST // LAST
- };
- // Request type
-
ACE_URL_Locator_Request (void);
// Default ctor.
@@ -75,22 +65,6 @@ public:
const ACE_URL_Property_Seq &modify = 0);
// Modify a previously registered offer.
- int encode (void);
- // Encode request for network communication.
-
- int decode (void);
- // Restore from network data.
-
- // = A bunch of methods to access internal data.
- int how (void);
- int how_many (void);
- ACE_URL_Property_Seq &seq (void);
- ACE_URL_Property_Seq &del (void);
- ACE_URL_Property_Seq &modify (void);
- ACE_WString &id (void);
- ACE_WString &url (void);
- void *buffer (void);
-
size_t encode (void);
// Encode request for network communication. If succeed,
// returns the size of the buffer, otherwise, return 0.
@@ -101,6 +75,7 @@ public:
const int how (void) const;
const int how_many (void) const;
+ const u_int opcode (void) const;
const ACE_URL_Property_Seq *seq (void) const;
const ACE_URL_Property_Seq *del (void) const;
const ACE_URL_Property_Seq *modify (void) const;
@@ -110,21 +85,33 @@ public:
const char *buffer (void) const;
// A bunch of methods to access internal data.
- void dump (void);
+ void dump (void) const;
// Print out this object.
protected:
+ size_t bsize (void);
+ // Return the size of the buffer required to encode
+ // this request.
+
+ enum {
+ VALID_SEQ1 = 0x1,
+ VALID_SEQ2 = 0X2,
+ VALID_OFFER = 0X4
+ };
+ // These constants used to indicate which pointers are valid.
+
u_int code_;
// Request type code.
- // Nanbor, please make sure that you comment all of these data
- // members.
- size_t bsize (void) const;
- // Return the size of buffer required to encode
- // this request.
-
int how_;
+ // Query method (if code_ == QUERY.)
+
int how_many_;
+ // How many offers are we interested in in this query.
+
+ int valid_ptr_;
+ // Bit flag to mark valid pointers within this object.
+
ACE_URL_Property_Seq *seq1_;
// For query or del in modify_offer.
@@ -132,14 +119,95 @@ protected:
// For modify seq. in modify_offer.
ACE_URL_Offer *offer_;
+ // Offer to export.
ACE_WString id_;
+ // Offer ID.
ACE_WString url_;
-
+ // URL of this offer.
+
char *buffer_;
+ // Buffer to store encoded data.
};
+class ACE_Export ACE_URL_Locator_Reply
+ // = TITLE
+ // A URL reply message formater/wrapper.
+ //
+ // = DESCRIPTION
+ // This class defines a URL reply data. It is used
+ // to transform reply messages to an object so that we can
+ // ship them across network.
+{
+ ACE_URL_Locator_Reply (void);
+ // Default ctor.
+
+ ~ACE_URL_Locator_Reply (void);
+ // Default dtor.
+
+ int status_reply (u_int op, int result);
+ // Setup a reply message for EXPORT, WITHDRAW, or MODIFY operations.
+
+ int query_reply (int result, size_t num,
+ const ACE_URL_Offer_Seq &offers);
+ // Setup a reply for QUERY operation.
+
+ int describe_reply (int result,
+ const ACE_URL_Offer &offer);
+ // Construct a reply for DESCRIBE operation.
+
+ size_t encode (void);
+ // Encode request for network communication. If succeed,
+ // returns the size of the buffer, otherwise, return 0.
+
+ size_t decode (void *buffer);
+ // Restore from network data. Returns size of the buffer
+ // if succeed, 0 otherwise.
+
+ // Accessor function.
+ const size_t num_offers (void) const;
+ const ACE_URL_Offer *offer (void) const;
+ const ACE_URL_Offer_Seq *offers (void) const;
+ const u_int opcode (void) const;
+ const u_int status (void) const;
+ const char *buffer (void) const ;
+
+ void dump (void) const ;
+ // Print out this object.
+
+protected:
+ size_t bsize (void);
+ // Return the size of the buffer required to encode
+ // this request.
+
+ enum {
+ VALID_OFFER = 0x1,
+ VALID_OFFERS = 0x2
+ };
+ // Valid pointer masks.
+
+ u_int code_;
+ // Holds the original op code.
+
+ int status_;
+ // Holds the result of an operation from the Location Server.
+
+ size_t num_offers_;
+ // Holds the number of valid offers in the offers_ sequence.
+
+ int valid_ptr_;
+ // Flag that marks valid internal pointers.
+
+ ACE_URL_Offer *offer_;
+ // Holds a single offer. Used in query offer property.
+
+ ACE_URL_Offer_Seq *offers_;
+ // Holds the replying offer sequence from a Locator.
+
+ char *buffer_;
+ // Buffer to store encoded data.
+};
#if defined (__ACE_INLINE__)
#include "Locator_Request_Reply.i"
#endif /* __ACE_INLINE__ */
diff --git a/apps/JAWS/clients/Caching/Locator_Request_Reply.i b/apps/JAWS/clients/Caching/Locator_Request_Reply.i
index 5181649ca2c..9dd2f851ceb 100644
--- a/apps/JAWS/clients/Caching/Locator_Request_Reply.i
+++ b/apps/JAWS/clients/Caching/Locator_Request_Reply.i
@@ -2,9 +2,11 @@
// $Id$
+#include "URL_Locator.h"
+
ACE_INLINE
ACE_URL_Locator_Request::ACE_URL_Locator_Request (void)
- : how_(INVALID_REQUEST),
+ : code_(ACE_URL_Locator::INVALID_OPERATION),
seq1_ (0),
seq2_ (0),
offer_ (0),
@@ -33,6 +35,12 @@ ACE_URL_Locator_Request::how_many (void) const
return this->how_many_;
}
+ACE_INLINE const u_int
+ACE_URL_Locator_Request::opcode (void) const
+{
+ return this->code_;
+}
+
ACE_INLINE const ACE_URL_Property_Seq *
ACE_URL_Locator_Request::seq (void) const
{
@@ -74,3 +82,57 @@ ACE_URL_Locator_Request::buffer (void) const
{
return this->buffer_;
}
+
+ACE_INLINE
+ACE_URL_Locator_Reply::ACE_URL_Locator_Reply (void)
+ : code_ (ACE_URL_Locator::INVALID_OPERATION),
+ offer_ (0),
+ offers_ (0),
+ buffer_ (0)
+{
+}
+
+ACE_INLINE
+ACE_URL_Locator_Reply::~ACE_URL_Locator_Reply (void)
+{
+ delete this->offer_;
+ delete this->offers_;
+ delete [] this->buffer_;
+}
+
+ACE_INLINE const size_t
+ACE_URL_Locator_Reply::num_offers (void) const
+{
+ return this->num_offers_;
+}
+
+
+ACE_INLINE const ACE_URL_Offer *
+ACE_URL_Locator_Reply::offer (void) const
+{
+ return this->offer_;
+}
+
+ACE_INLINE const ACE_URL_Offer_Seq *
+ACE_URL_Locator_Reply::offers (void) const
+{
+ return this->offers_;
+}
+
+ACE_INLINE const u_int
+ACE_URL_Locator_Reply::opcode (void) const
+{
+ return this->code_;
+}
+
+ACE_INLINE const u_int
+ACE_URL_Locator_Reply::status (void) const
+{
+ return this->status_;
+}
+
+ACE_INLINE const char *
+ACE_URL_Locator_Reply::buffer (void) const
+{
+ return this->buffer_;
+}
diff --git a/apps/JAWS/clients/Caching/Makefile b/apps/JAWS/clients/Caching/Makefile
index 2490dbb4f2a..1cbe5731815 100644
--- a/apps/JAWS/clients/Caching/Makefile
+++ b/apps/JAWS/clients/Caching/Makefile
@@ -44,6 +44,22 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
# DO NOT DELETE THIS LINE -- g++dep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-
+test_URL.o: test_URL.cpp URL_Properties.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/SString.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/ACE.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/OS.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/config.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/stdcpp.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/OS.i \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Trace.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Log_Msg.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Log_Record.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Log_Priority.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Log_Record.i \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/ACE.i \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/SString.i \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Array.h \
+ /project/cumbia/nanbor/build-sunos5.5-sunc++4.2/ace/Array.i \
+ URL_Properties.i
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/apps/JAWS/clients/Caching/URL_Locator.h b/apps/JAWS/clients/Caching/URL_Locator.h
index d7b0a616f7d..684829ebb4e 100644
--- a/apps/JAWS/clients/Caching/URL_Locator.h
+++ b/apps/JAWS/clients/Caching/URL_Locator.h
@@ -27,30 +27,37 @@ class ACE_Export ACE_URL_Locator
//
// = DESCRIPTION
// This class defines the basic URL_Locator APIs.
-// Nanbor, please make sure that you explain more about what a URL
-// Locator is in the description here.
+ // An URL locator provides services for URL clients to
+ // query specific URL location that has certain properties
+ // and URL providers to export their services and a set of
+ // APIs to maintain their offers.
{
public:
+ // Request type
+ enum ACE_URL_Locator_Op_Type
+ {
+ QUERY,
+ EXPORT,
+ WITHDRAW,
+ DESCRIBE,
+ MODIFY,
+ INVALID_OPERATION // LAST
+ };
// = Specify how to select offers.
- // Nanbor, please add comments to each of these enumerals.
enum ACE_Selection_Criteria
{
- NONE,
- SOME,
- ALL,
- INVALID_SELECTION
+ NONE, // URL that contains none of the properties.
+ SOME, // URL that contains some of the properties.
+ ALL, // URL that contains all of the properties.
+ INVALID_SELECTION // Invalid.
};
enum ACE_URL_Locator_Error
- // Nanbor, I don't think that you need to use this enum. I
- // recommend that you return -1 from methods that fail and set
- // errno accordingly.
+ // errno will set to one of these value.
{
- OK = 0, // everything's OK so far.
OFFER_EXIST, // trying to register an offer.
// that is already exist in repository.
- NOMEM, // no memory available.
NO_SUCH_OFFER, // No such offer in the repository.
INVALID_ARGUMENT, // Invalid argument encountered.
UNIMPLEMENTED, // function not implemented.
@@ -89,11 +96,8 @@ public:
const ACE_URL_Property_Seq *modify = 0) = 0;
// Modify a previously registered offer.
- virtual char *error_status (void);
+ virtual const char *error_status (void);
// Provide a human readable error status.
- // Nanbor, please make sure that you explain who is responsible for
- // the memory returned from this method. Also, I recommend that you
- // make this return a *const* char *.
};
#if defined (__ACE_INLINE__)
diff --git a/apps/JAWS/clients/Caching/URL_Properties.h b/apps/JAWS/clients/Caching/URL_Properties.h
index ec2f7f3a7de..6677222b3b3 100644
--- a/apps/JAWS/clients/Caching/URL_Properties.h
+++ b/apps/JAWS/clients/Caching/URL_Properties.h
@@ -32,8 +32,6 @@ class ACE_Export ACE_WString_Helper
public:
static size_t bsize (const ACE_WString *wstr);
// Returns the actual size required to contain the ACE_WString.
- // Nanbor, is there a reason you called this <bsize> rather than
- // just <size>? I think I like <size> better!
static size_t encode (void *buf, ACE_WString *wstr);
// Encode <wstr> into <buf> for network communication.
@@ -122,8 +120,8 @@ protected:
// Property value.
} ;
-// Nanbor, please add a comment here.
typedef ACE_Array<ACE_URL_Property> ACE_URL_Property_Seq;
+// type of URL_Property collection.
class ACE_Export ACE_URL_Offer
// = TITLE