diff options
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Hash_Map_Manager.cpp | 16 | ||||
-rw-r--r-- | ace/Hash_Map_Manager.h | 6 | ||||
-rw-r--r-- | ace/Local_Tokens.cpp | 20 | ||||
-rw-r--r-- | ace/Local_Tokens.h | 6 | ||||
-rw-r--r-- | ace/Malloc_T.cpp | 31 | ||||
-rw-r--r-- | ace/Malloc_T.h | 6 | ||||
-rw-r--r-- | ace/Map_Manager.cpp | 24 | ||||
-rw-r--r-- | ace/Map_Manager.h | 12 | ||||
-rw-r--r-- | ace/Message_Queue.cpp | 88 | ||||
-rw-r--r-- | ace/Message_Queue.h | 12 | ||||
-rw-r--r-- | ace/Message_Queue.i | 77 | ||||
-rw-r--r-- | ace/Reactor.cpp | 8 | ||||
-rw-r--r-- | ace/Reactor.h | 13 | ||||
-rw-r--r-- | ace/SString.cpp | 23 | ||||
-rw-r--r-- | ace/SString.h | 37 | ||||
-rw-r--r-- | ace/SString.i | 30 | ||||
-rw-r--r-- | ace/Service_Repository.cpp | 10 | ||||
-rw-r--r-- | ace/Service_Repository.h | 27 | ||||
-rw-r--r-- | ace/Set.cpp | 113 | ||||
-rw-r--r-- | ace/Set.h | 53 | ||||
-rw-r--r-- | ace/Stream.cpp | 8 | ||||
-rw-r--r-- | ace/Stream.h | 17 | ||||
-rw-r--r-- | ace/Stream.i | 16 | ||||
-rw-r--r-- | ace/Timer_Queue_T.cpp | 4 |
24 files changed, 452 insertions, 205 deletions
diff --git a/ace/Hash_Map_Manager.cpp b/ace/Hash_Map_Manager.cpp index 77dd67cdb34..1072c3a8407 100644 --- a/ace/Hash_Map_Manager.cpp +++ b/ace/Hash_Map_Manager.cpp @@ -475,6 +475,19 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::next (ACE_Hash_Map_Entry<EXT_ID, IN return 0; } +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::done (void) const +{ + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->map_man_.lock_, -1); + + if (this->map_man_.table_ != 0 + && this->index_ < this->map_man_.total_size_ + && this->next_ != this->map_man_.sentinel_) + return 0; + else + return 1; +} + template <class EXT_ID, class INT_ID, class LOCK> int ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) { @@ -490,7 +503,8 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) break; } - return 0; + return this->index_ < this->map_man_.total_size_ + && this->next_ != this->map_man_.sentinel_; } #endif /* ACE_HASH_MAP_MANAGER_C */ diff --git a/ace/Hash_Map_Manager.h b/ace/Hash_Map_Manager.h index afe20363b46..0284a8c3ddb 100644 --- a/ace/Hash_Map_Manager.h +++ b/ace/Hash_Map_Manager.h @@ -242,8 +242,12 @@ public: // Pass back the next <entry> that hasn't been seen in the Set. // Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. diff --git a/ace/Local_Tokens.cpp b/ace/Local_Tokens.cpp index 61e012af735..0fbe4524db6 100644 --- a/ace/Local_Tokens.cpp +++ b/ace/Local_Tokens.cpp @@ -201,20 +201,26 @@ ACE_TPQ_Iterator::next (ACE_TPQ_Entry *&next_item) { ACE_TRACE ("ACE_TPQ_Iterator::next"); - next_item = current_; + next_item = this->current_; - if (current_ == 0) - return 0; + return current_ != 0; +} + +int +ACE_TPQ_Iterator::done (void) const +{ + ACE_TRACE ("ACE_TPQ_Iterator::done"); - return 1; + return this->current_ == 0; } void ACE_TPQ_Iterator::advance (void) { ACE_TRACE ("ACE_TPQ_Iterator::advance"); + if (current_ != 0) - current_ = current_->next_; + this->current_ = this->current_->next_; } void @@ -223,8 +229,8 @@ ACE_TPQ_Iterator::dump (void) const ACE_TRACE ("ACE_TPQ_Iterator::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, "ACE_TPQ_Iterator::dump:\n" - " current_ = %d\n", - (long) current_)); + " current_ = %d\n", + (long) this->current_)); ACE_DEBUG ((LM_DEBUG, "head_ and tail_\n")); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } diff --git a/ace/Local_Tokens.h b/ace/Local_Tokens.h index d50ba02619b..49a66af5b68 100644 --- a/ace/Local_Tokens.h +++ b/ace/Local_Tokens.h @@ -225,8 +225,10 @@ public: // Construction. int next (ACE_TPQ_Entry *&next_item); - // Pass back the <next_item>. Returns 0 when all items have been - // seen, else 1. + // Pass back the <next_item>. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. void advance (void); // Move forward by one element in the queue. diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp index 362743f6842..9d126061fea 100644 --- a/ace/Malloc_T.cpp +++ b/ace/Malloc_T.cpp @@ -587,10 +587,10 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::next (void *&next_entry, { ACE_TRACE ("ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::next"); - if (curr_ != 0) + if (this->curr_ != 0) { - next_entry = curr_->pointer_; - name = curr_->name_; + next_entry = this->curr_->pointer_; + name = this->curr_->name_; return 1; } else @@ -602,15 +602,23 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::next (void *&next_entry) { ACE_TRACE ("ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::next"); - if (curr_ != 0) + if (this->curr_ != 0) { - next_entry = curr_->pointer_; + next_entry = this->curr_->pointer_; return 1; } else return 0; } +template <ACE_MEM_POOL_1, class LOCK> int +ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::done (void) const +{ + ACE_TRACE ("ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::done"); + + return this->curr_ == 0; +} + template <ACE_MEM_POOL_1, class LOCK> int ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::advance (void) { @@ -619,14 +627,13 @@ ACE_Malloc_Iterator<ACE_MEM_POOL_2, LOCK>::advance (void) this->curr_ = this->curr_->next_; if (this->name_ == 0) - return 1; + return this->curr_ != 0; + + while (this->curr_ != 0 + && ACE_OS::strcmp (this->name_, this->curr_->name_) != 0) + this->curr_ = this->curr_->next_; - for (; - this->curr_ != 0 && - ACE_OS::strcmp (this->name_, this->curr_->name_) != 0; - this->curr_ = this->curr_->next_) - continue; - return 1; + return this->curr_ != 0; } #endif /* ACE_MALLOC_T_C */ diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index ddc5423a3f0..432aa405145 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -338,13 +338,17 @@ public: // Pass back the next <entry> in the set that hasn't yet been // visited. Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int next (void *&next_entry, char *&name); // Pass back the next <entry> (and the <name> associated with it) in // the set that hasn't yet been visited. Returns 0 when all items // have been seen, else 1. int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. diff --git a/ace/Map_Manager.cpp b/ace/Map_Manager.cpp index ffb6565bb81..4e200705549 100644 --- a/ace/Map_Manager.cpp +++ b/ace/Map_Manager.cpp @@ -587,6 +587,17 @@ ACE_Map_Iterator<EXT_ID, INT_ID, LOCK>::next (ACE_Map_Entry<EXT_ID, INT_ID> *&mm return 0; } +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Map_Iterator<EXT_ID, INT_ID, LOCK>::done (void) const +{ + ACE_TRACE ("ACE_Map_Iterator<EXT_ID, INT_ID, LOCK>::done"); + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->map_man_.lock_, -1); + + return this->map_man_.search_structure_ == 0 + // Note that this->next_ is never negative at this point... + || size_t (this->next_) >= this->map_man_.cur_size_; +} + template <class EXT_ID, class INT_ID, class LOCK> int ACE_Map_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) { @@ -598,7 +609,7 @@ ACE_Map_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) && this->map_man_.search_structure_[this->next_].is_free_; this->next_++) continue; - return this->next_; + return size_t (this->next_) < this->map_man_.cur_size_; } ACE_ALLOC_HOOK_DEFINE(ACE_Map_Reverse_Iterator) @@ -639,6 +650,15 @@ ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK>::next (ACE_Map_Entry<EXT_ID, INT_ return 0; } +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK>::done (void) const +{ + ACE_TRACE ("ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK>::done"); + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->map_man_.lock_, -1); + + return this->map_man_.search_structure_ == 0 || this->next_ < 0; +} + template <class EXT_ID, class INT_ID, class LOCK> int ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) { @@ -650,7 +670,7 @@ ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) && this->map_man_.search_structure_[this->next_].is_free_; this->next_--) continue; - return this->next_; + return size_t (this->next_) >= 0; } #endif /* ACE_MAP_MANAGER_C */ diff --git a/ace/Map_Manager.h b/ace/Map_Manager.h index c93c0768fc9..0eb4d0130b8 100644 --- a/ace/Map_Manager.h +++ b/ace/Map_Manager.h @@ -259,8 +259,12 @@ public: // Pass back the next <entry> that hasn't been seen in the Set. // Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. @@ -293,8 +297,12 @@ public: // Pass back the <entry> that hasn't been seen in the Set. // Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. diff --git a/ace/Message_Queue.cpp b/ace/Message_Queue.cpp index 3ac29a47e3f..3e9bde4dc81 100644 --- a/ace/Message_Queue.cpp +++ b/ace/Message_Queue.cpp @@ -13,6 +13,94 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue) +template <ACE_SYNCH_1> +ACE_Message_Queue_Iterator<ACE_SYNCH_2>::ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_2> &queue) + : queue_ (queue), + curr_ (queue_.head_) +{ +} + +template <ACE_SYNCH_1> int +ACE_Message_Queue_Iterator<ACE_SYNCH_2>::next (ACE_Message_Block *&entry) +{ + ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); + + if (this->curr_ != 0) + { + entry = this->curr_; + return 1; + } + else + return 0; +} + +template <ACE_SYNCH_1> int +ACE_Message_Queue_Iterator<ACE_SYNCH_2>::done (void) const +{ + ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); + + return this->curr_ == 0; +} + +template <ACE_SYNCH_1> int +ACE_Message_Queue_Iterator<ACE_SYNCH_2>::advance (void) +{ + ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); + + this->curr_ = this->curr_->next (); + return this->curr_ != 0; +} + +template <ACE_SYNCH_1> void +ACE_Message_Queue_Iterator<ACE_SYNCH_2>::dump (void) const +{ +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator) + +template <ACE_SYNCH_1> +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_2> &queue) + : queue_ (queue), + curr_ (queue_.tail_) +{ +} + +template <ACE_SYNCH_1> int +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::next (ACE_Message_Block *&entry) +{ + ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); + + if (this->curr_ != 0) + { + entry = this->curr_; + return 1; + } + else + return 0; +} + +template <ACE_SYNCH_1> int +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::done (void) const +{ + ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); + + return this->curr_ == 0; +} + +template <ACE_SYNCH_1> int +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::advance (void) +{ + ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); + + this->curr_ = this->curr_->prev (); + return this->curr_ != 0; +} + +template <ACE_SYNCH_1> void +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::dump (void) const +{ +} + template <ACE_SYNCH_1> void ACE_Message_Queue<ACE_SYNCH_2>::dump (void) const { diff --git a/ace/Message_Queue.h b/ace/Message_Queue.h index 09e799b5cb1..ffd727e1877 100644 --- a/ace/Message_Queue.h +++ b/ace/Message_Queue.h @@ -257,8 +257,12 @@ public: // Pass back the <entry> that hasn't been seen in the queue. // Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); - // Move forward by one element in the queue + // Move forward by one element in the queue. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. @@ -288,8 +292,12 @@ public: // Pass back the <entry> that hasn't been seen in the queue. // Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); - // Move forward by one element in the queue + // Move forward by one element in the queue. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. diff --git a/ace/Message_Queue.i b/ace/Message_Queue.i index 15e07b64da0..02ded2c141a 100644 --- a/ace/Message_Queue.i +++ b/ace/Message_Queue.i @@ -117,7 +117,7 @@ ACE_Message_Queue<ACE_SYNCH_2>::message_count (void) return this->cur_count_; } -template <ACE_SYNCH_1> int +template <ACE_SYNCH_1> ACE_INLINE int ACE_Message_Queue<ACE_SYNCH_2>::activate (void) { ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_2>::activate"); @@ -126,7 +126,7 @@ ACE_Message_Queue<ACE_SYNCH_2>::activate (void) return this->activate_i (); } -template <ACE_SYNCH_1> int +template <ACE_SYNCH_1> ACE_INLINE int ACE_Message_Queue<ACE_SYNCH_2>::deactivate (void) { ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_2>::deactivate"); @@ -135,79 +135,6 @@ ACE_Message_Queue<ACE_SYNCH_2>::deactivate (void) return this->deactivate_i (); } -template <ACE_SYNCH_1> -ACE_Message_Queue_Iterator<ACE_SYNCH_2>::ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_2> &queue) -: queue_ (queue), - curr_ (queue_.head_) -{ -} - -template <ACE_SYNCH_1> int -ACE_Message_Queue_Iterator<ACE_SYNCH_2>::next (ACE_Message_Block *&entry) -{ - ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); - - if (this->curr_ != 0) - { - entry = this->curr_; - return 1; - } - else - return 0; -} - -template <ACE_SYNCH_1> int -ACE_Message_Queue_Iterator<ACE_SYNCH_2>::advance (void) -{ - ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); - - this->curr_ = this->curr_->next (); - return this->curr_ != 0; -} - -template <ACE_SYNCH_1> void -ACE_Message_Queue_Iterator<ACE_SYNCH_2>::dump (void) const -{ -} - -ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator) - - -template <ACE_SYNCH_1> -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_2> &queue) -: queue_ (queue), - curr_ (queue_.tail_) -{ -} - -template <ACE_SYNCH_1> int -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::next (ACE_Message_Block *&entry) -{ - ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); - - if (this->curr_ != 0) - { - entry = this->curr_; - return 1; - } - else - return 0; -} - -template <ACE_SYNCH_1> int -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::advance (void) -{ - ACE_Read_Guard<ACE_SYNCH_MUTEX_T> m (this->queue_.lock_); - - this->curr_ = this->curr_->prev (); - return this->curr_ != 0; -} - -template <ACE_SYNCH_1> void -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_2>::dump (void) const -{ -} - ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator) diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index 16117c84594..70b04a8a371 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -365,6 +365,12 @@ ACE_Reactor_Handler_Repository_Iterator::next (ACE_Event_Handler *&next_item) return result; } +int +ACE_Reactor_Handler_Repository_Iterator::done (void) const +{ + return this->current_ >= this->rep_->max_handlep1_; +} + // Move forward by one element in the set. int @@ -379,7 +385,7 @@ ACE_Reactor_Handler_Repository_Iterator::advance (void) else this->current_++; - return 0; + return this->current_ < this->rep_->max_handlep1_; } // Dump the state of an object. diff --git a/ace/Reactor.h b/ace/Reactor.h index 6738d878e87..d881bdc6a64 100644 --- a/ace/Reactor.h +++ b/ace/Reactor.h @@ -253,8 +253,12 @@ public: // Pass back the <next_item> that hasn't been seen in the Set. // Returns 0 when all items have been seen, else 1. + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. @@ -270,13 +274,6 @@ private: // Pointer to the current iteration level. }; -class ACE_Export ACE_Dispatch_Strategy -{ -public: - -private: -}; - class ACE_Export ACE_Reactor // = TITLE // An object oriented event demultiplexor and event handler diff --git a/ace/SString.cpp b/ace/SString.cpp index 8917b6d4fb5..2f3c10ba5d7 100644 --- a/ace/SString.cpp +++ b/ace/SString.cpp @@ -14,6 +14,29 @@ ACE_ALLOC_HOOK_DEFINE(ACE_CString) char ACE_CString::NULL_CString_ = '\0'; +ostream & +operator << (ostream &os, const ACE_CString &cs) +{ + os << cs.fast_rep (); + return os; +} + +ACE_WString +operator+ (const ACE_WString &s, const ACE_WString &t) +{ + ACE_WString temp (s); + temp += t; + return temp; +} + +ACE_CString +operator+ (const ACE_CString &s, const ACE_CString &t) +{ + ACE_CString temp (s); + temp += t; + return temp; +} + // Copy constructor. ACE_CString::ACE_CString (const ACE_CString &s) diff --git a/ace/SString.h b/ace/SString.h index 04f7af84f63..4d5612c83c0 100644 --- a/ace/SString.h +++ b/ace/SString.h @@ -39,6 +39,8 @@ class ACE_Export ACE_CString // allocated new space. Instead, its internal representation is set // equal to a global empty string. { + friend ACE_CString operator+ (const ACE_CString &, const ACE_CString &); + friend ostream &operator << (ostream &, const ACE_CString &); public: ACE_CString (ACE_Allocator *allocator = 0); // Default constructor. @@ -89,10 +91,13 @@ public: // bounds checking). int operator== (const ACE_CString &s) const; - // Comparison operator (must match entire string). + // Equality comparison operator (must match entire string). int operator!= (const ACE_CString &s) const; - // Comparison operator. + // Inequality comparison operator. + + int compare (const ACE_CString &s) const; + // Performs a <strcmp>-style comparison. void dump (void) const; // Dump the state of an object. @@ -114,6 +119,9 @@ private: // Represents the "NULL" string to simplify the internal logic. }; +ACE_CString operator+ (const ACE_CString &, const ACE_CString &); +ostream &operator << (ostream &, const ACE_CString &); + class ACE_Export ACE_SString // = TITLE // A very "Simple String" (ACE_SString) class. @@ -170,10 +178,13 @@ public: // bounds checking). int operator== (const ACE_SString &s) const; - // Comparison operator (must match entire string). + // Equality comparison operator (must match entire string). int operator!= (const ACE_SString &s) const; - // Comparison operator. + // Inequality comparison operator. + + int compare (const ACE_SString &s) const; + // Performs a <strcmp>-style comparison. void dump (void) const; // Dump the state of an object. @@ -182,7 +193,6 @@ public: // Declare the dynamic allocation hooks. private: - ACE_Allocator *allocator_; // Pointer to a memory allocator. @@ -202,11 +212,11 @@ class ACE_Export ACE_WString // intended for use with applications that understand how it // works. Note that we need to use this class since the ACE // ACE_Map_Manager requires an object that supports the operator== - // and operator!=. - // This class uses an ACE_Allocator to allocate memory - // The user can make this a persistant class by providing an - // ACE_Allocator with a persistable memory pool + // and operator!=. This class uses an ACE_Allocator to allocate + // memory The user can make this a persistant class by providing + // an ACE_Allocator with a persistable memory pool { + friend ACE_WString operator+ (const ACE_WString &, const ACE_WString &); public: ACE_WString (ACE_Allocator *allocator = 0); // Default constructor. @@ -261,10 +271,13 @@ public: // index of the first location that matches, else -1. int operator== (const ACE_WString &s) const; - // Comparison operator (must match entire string). + // Equality comparison operator (must match entire string). int operator!= (const ACE_WString &s) const; - // Comparison operator. + // Inequality comparison operator. + + int compare (const ACE_WString &s) const; + // Performs a <strcmp>-style comparison. void dump (void) const; // Dump the state of an object. @@ -292,6 +305,8 @@ private: // Pointer to data. }; +ACE_WString operator+ (const ACE_WString &, const ACE_WString &); + #if defined (__ACE_INLINE__) #include "ace/SString.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/SString.i b/ace/SString.i index 682ff9bf1fa..743c30d3a56 100644 --- a/ace/SString.i +++ b/ace/SString.i @@ -56,6 +56,7 @@ ACE_INLINE int ACE_CString::operator== (const ACE_CString &s) const { ACE_TRACE ("ACE_CString::operator=="); + return this->len_ == s.len_ && ACE_OS::strcmp (this->rep_, s.rep_) == 0; } @@ -69,6 +70,13 @@ ACE_CString::operator!= (const ACE_CString &s) const return !(*this == s); } +ACE_INLINE int +ACE_CString::compare (const ACE_CString &s) const +{ + ACE_TRACE ("ACE_CString::compare"); + return ACE_OS::strcmp (this->rep_, s.rep_); +} + // Return the <index'th> character in the string. ACE_INLINE char @@ -106,6 +114,13 @@ ACE_SString::operator!= (const ACE_SString &s) const return !(*this == s); } +ACE_INLINE int +ACE_SString::compare (const ACE_SString &s) const +{ + ACE_TRACE ("ACE_CString::compare"); + return ACE_OS::strcmp (this->rep_, s.rep_); +} + // Get a copy of the underlying representation. ACE_INLINE ACE_USHORT16 * @@ -142,8 +157,9 @@ ACE_WString::operator== (const ACE_WString &s) const { ACE_TRACE ("ACE_WString::operator=="); return this->len_ == s.len_ - && ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_, - this->len_ * sizeof (ACE_USHORT16)) == 0; + && ACE_OS::memcmp ((const void *) this->rep_, + (const void *) s.rep_, + this->len_ * sizeof (ACE_USHORT16)) == 0; } // Comparison operator. @@ -155,6 +171,16 @@ ACE_WString::operator!= (const ACE_WString &s) const return !(*this == s); } +ACE_INLINE int +ACE_WString::compare (const ACE_WString &s) const +{ + ACE_TRACE ("ACE_WString::compare"); + + return ACE_OS::memcmp ((const void *) this->rep_, + (const void *) s.rep_, + this->len_ * sizeof (ACE_USHORT16)); +} + // Return the <index'th> character in the string. ACE_INLINE ACE_USHORT16 diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index 6500e28938b..c614b638dc0 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -260,6 +260,14 @@ ACE_Service_Repository_Iterator::next (const ACE_Service_Record *&sr) return 0; } +int +ACE_Service_Repository_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Service_Repository_Iterator::done"); + + return this->next_ >= this->svc_rep_.current_size_; +} + // Advance the iterator by the proper amount. If we are ignoring // suspended entries and the current entry is suspended, then we must // skip over this entry. Otherwise, we must advance the NEXT index to @@ -275,5 +283,5 @@ ACE_Service_Repository_Iterator::advance (void) && this->svc_rep_.service_vector_[this->next_]->active () == 0; this->next_++) continue; - return this->next_; + return this->next_ < this->svc_rep_.current_size_; } diff --git a/ace/Service_Repository.h b/ace/Service_Repository.h index 2d758e1ffe3..26ceeb868e5 100644 --- a/ace/Service_Repository.h +++ b/ace/Service_Repository.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -25,6 +24,7 @@ class ACE_Export ACE_Service_Repository // Provide the abstract base class that supplies common server // repository operations. { + friend class ACE_Service_Repository_Iterator; public: enum {DEFAULT_SIZE = 50}; // = Initialization and termination methods. @@ -95,21 +95,29 @@ private: ACE_Thread_Mutex lock_; // Synchronization variable for the MT_SAFE Repository #endif /* ACE_MT_SAFE */ - - friend class ACE_Service_Repository_Iterator; }; class ACE_Export ACE_Service_Repository_Iterator // = TITLE - // - // = DESCRIPTION - // + // Iterate through the <ACE_Service_Repository>. { public: + // = Initialization method. ACE_Service_Repository_Iterator (ACE_Service_Repository &sr, int ignored_suspended = 1); - int next (const ACE_Service_Record *&so); + + // = Iteration methods. + + int next (const ACE_Service_Record *&next_item); + // Pass back the <next_item> that hasn't been seen in the set. + // Returns 0 when all items have been seen, else 1. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. void dump (void) const; // Dump the state of an object. @@ -119,8 +127,13 @@ public: private: ACE_Service_Repository &svc_rep_; + // Reference to the Service Repository we are iterating over. + int next_; + // Next index location that we haven't yet seen. + int ignore_suspended_; + // Are we ignoring suspended services? }; #if defined (__ACE_INLINE__) diff --git a/ace/Set.cpp b/ace/Set.cpp index d13b1ee2055..d09ca2115b3 100644 --- a/ace/Set.cpp +++ b/ace/Set.cpp @@ -95,23 +95,6 @@ ACE_Fixed_Set<T, SIZE>::find (const T &item) const } template <class T, size_t SIZE> int -ACE_Fixed_Set<T, SIZE>::find (T &item, size_t index) const -{ - ACE_TRACE ("ACE_Fixed_Set<T, SIZE>::find"); - - if (index > this->cur_size_ - || this->search_structure_[index].is_free_ != 0) - return 0; - else - { - item = this->search_structure_[index].item_; - return 1; - } - - return 0; -} - -template <class T, size_t SIZE> int ACE_Fixed_Set<T, SIZE>::insert (const T &item) { @@ -211,7 +194,15 @@ ACE_Fixed_Set_Iterator<T, SIZE>::advance (void) ++this->next_) continue; - return this->next_; + return size_t (this->next_) < this->s_.cur_size_; +} + +template <class T, size_t SIZE> int +ACE_Fixed_Set_Iterator<T, SIZE>::done (void) const +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator<T, SIZE>::done"); + + return size_t (this->next_) >= this->s_.cur_size_; } template <class T, size_t SIZE> int @@ -316,23 +307,6 @@ ACE_Bounded_Set<T>::find (const T &item) const } template <class T> int -ACE_Bounded_Set<T>::find (T &item, size_t index) const -{ - ACE_TRACE ("ACE_Bounded_Set<T>::find"); - - if (index > this->cur_size_ - || this->search_structure_[index].is_free_ != 0) - return 0; - else - { - item = this->search_structure_[i].item_; - return 1; - } - - return 0; -} - -template <class T> int ACE_Bounded_Set<T>::insert (const T &item) { ACE_TRACE ("ACE_Bounded_Set<T>::insert"); @@ -426,7 +400,15 @@ ACE_Bounded_Set_Iterator<T>::advance (void) ++this->next_) continue; - return this->next_; + return size_t (this->next_) < this->s_.cur_size_; +} + +template <class T> int +ACE_Bounded_Set_Iterator<T>::done (void) const +{ + ACE_TRACE ("ACE_Bounded_Set_Iterator<T>::done"); + + return size_t (this->next_) >= this->s_.cur_size_; } template <class T> int @@ -568,9 +550,9 @@ ACE_Unbounded_Set<T>::find (const T &item) const } template <class T> int -ACE_Unbounded_Set<T>::find (T &item, size_t index) const +ACE_Unbounded_Set<T>::get (T &item, size_t index) const { - ACE_TRACE ("ACE_Unbounded_Set<T>::find"); + ACE_TRACE ("ACE_Unbounded_Set<T>::get"); ACE_Set_Node<T> *curr = this->head_->next_; @@ -586,7 +568,6 @@ ACE_Unbounded_Set<T>::find (T &item, size_t index) const if (i < this->cur_size_) { - ACE_ASSERT (curr != this->head_); item = curr->item_; return 1; } @@ -594,6 +575,42 @@ ACE_Unbounded_Set<T>::find (T &item, size_t index) const return 0; } +template <class T> int +ACE_Unbounded_Set<T>::set (const T &item, size_t index) +{ + ACE_TRACE ("ACE_Unbounded_Set<T>::get"); + + ACE_Set_Node<T> *curr = this->head_->next_; + + int result = 1; + size_t i; + + for (i = 0; i <= index; i++) + { + if (i == this->cur_size_) + { + // We need to expand the list. + + result = 0; + + T dummy; + + // This head points to the existing dummy node, which is + // about to be overwritten when we add the new dummy node. + curr = this->head_; + + // Try to expand the size of the set by 1. + if (this->insert_tail (dummy) == -1) + return -1; + } + else + curr = curr->next_; + } + + curr->item_ = item; + return result; +} + template <class T> ACE_Unbounded_Set<T>::ACE_Unbounded_Set (void) : head_ (0), @@ -631,6 +648,14 @@ ACE_Unbounded_Set<T>::operator = (const ACE_Unbounded_Set<T> &us) this->copy_nodes (us); } +template <class T> void +ACE_Unbounded_Set<T>::reset (void) +{ + ACE_TRACE ("reset"); + + this->delete_nodes (); +} + // Insert the new node at the tail of the list. template <class T> int @@ -712,7 +737,15 @@ ACE_Unbounded_Set_Iterator<T>::advance (void) { // ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::advance"); this->current_ = this->current_->next_; - return 1; + return this->current_ != this->set_.head_; +} + +template <class T> int +ACE_Unbounded_Set_Iterator<T>::done (void) const +{ + ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::done"); + + return this->current_ == this->set_.head_; } template <class T> int diff --git a/ace/Set.h b/ace/Set.h index 2c1f5a563da..fccaeb8a2e3 100644 --- a/ace/Set.h +++ b/ace/Set.h @@ -41,7 +41,11 @@ public: // Returns 0 when all items have been seen, else 1. int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. void dump (void) const; // Dump the state of an object. @@ -92,10 +96,6 @@ public: // Returns -1 if failures occur, 1 if item is already present, else // 0. - int insert_tail (const T &new_item); - // Insert <new_item> into the set at the tail. Returns -1 if - // failures occur else 0. - int remove (const T &item); // Remove first occurrence of <item> from the set. Returns 1 if // it removes the item, 0 if it can't find the item, and -1 if a @@ -105,13 +105,28 @@ public: // Return first occurrence of <item> from the set. // Returns 0 if can't find, else 1. - int find (T &item, size_t index) const; - // Find the <index>th element in the set. Returns 0 if the element - // isn't in the range <0..size()>, else 1. - size_t size (void) const; // Size of the set. + // = Additional utility methods. + + int get (T &item, size_t index) const; + // Get the <index>th element in the set. Returns 0 if the element + // isn't in the range <0..size() - 1>, else 1. + + int set (const T &item, size_t index); + // Set the <index>th element in the set. Will pad out the set with + // empty nodes if <index> is beyond the range <0..size() - 1>. + // Returns -1 on failure, 0 if <index> isn't initially in range, and + // 1 otherwise. + + int insert_tail (const T &new_item); + // Insert <new_item> into the set at the tail. Returns -1 if + // failures occur else 0. + + void reset (void); + // Reset the <ACE_Unbounded_Set> to be empty. + void dump (void) const; // Dump the state of an object. @@ -156,7 +171,11 @@ public: // Returns 0 when all items have been seen, else 1. int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. void dump (void) const; // Dump the state of an object. @@ -214,10 +233,6 @@ public: // Return first occurrence of <item> from the set. // Returns 0 if can't find, else 1. - int find (T &item, size_t index) const; - // Find the <index>th element in the set. Returns 0 if the element - // isn't in the range <0..size()>, else 1. - size_t size (void) const; // Size of the set. @@ -268,7 +283,11 @@ public: // Returns 0 when all items have been seen, else 1. int advance (void); - // Move forward by one element in the set. + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. void dump (void) const; // Dump the state of an object. @@ -332,10 +351,6 @@ public: // Return first occurrence of <item> from the set. // Returns 0 if can't find, else 1. - int find (T &item, size_t index) const; - // Find the <index>th element in the set. Returns 0 if the element - // isn't in the range <0..size()>, else 1. - size_t size (void) const; // Size of the set. diff --git a/ace/Stream.cpp b/ace/Stream.cpp index a7e77ea3698..87ae733e4c3 100644 --- a/ace/Stream.cpp +++ b/ace/Stream.cpp @@ -75,14 +75,6 @@ ACE_Stream<ACE_SYNCH_2>::push (ACE_Module<ACE_SYNCH_2> *new_top) } template <ACE_SYNCH_1> int -ACE_Stream_Iterator<ACE_SYNCH_2>::advance (void) -{ - ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_2>::advance"); - this->next_ = this->next_->next (); - return 0; -} - -template <ACE_SYNCH_1> int ACE_Stream<ACE_SYNCH_2>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { ACE_TRACE ("ACE_Stream<ACE_SYNCH_2>::put"); diff --git a/ace/Stream.h b/ace/Stream.h index b4b7d648f13..2d81e618a0b 100644 --- a/ace/Stream.h +++ b/ace/Stream.h @@ -159,14 +159,29 @@ private: template <ACE_SYNCH_1> class ACE_Stream_Iterator + // = TITLE + // Iterate through an <ACE_Stream>. { public: + // = Initialization method. ACE_Stream_Iterator (const ACE_Stream<ACE_SYNCH_2> &sr); - int next (const ACE_Module<ACE_SYNCH_2> *&mo); + + // = Iteration methods. + + int next (const ACE_Module<ACE_SYNCH_2> *&next_item); + // Pass back the <next_item> that hasn't been seen in the set. + // Returns 0 when all items have been seen, else 1. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); + // Move forward by one element in the set. Returns 0 when all the + // items in the set have been seen, else 1. private: ACE_Module<ACE_SYNCH_2> *next_; + // Next <Module> that we haven't yet seen. }; #if defined (__ACE_INLINE__) diff --git a/ace/Stream.i b/ace/Stream.i index 368eec8d858..9406b02fb26 100644 --- a/ace/Stream.i +++ b/ace/Stream.i @@ -31,3 +31,19 @@ ACE_Stream_Iterator<ACE_SYNCH_2>::next (const ACE_Module<ACE_SYNCH_2> *&mod) mod = this->next_; return this->next_ != 0; } + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Stream_Iterator<ACE_SYNCH_2>::done (void) const +{ + ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_2>::done"); + return this->next_ == 0; +} + +template <ACE_SYNCH_1> int +ACE_Stream_Iterator<ACE_SYNCH_2>::advance (void) +{ + ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_2>::advance"); + this->next_ = this->next_->next (); + return this->next_ != 0; +} + diff --git a/ace/Timer_Queue_T.cpp b/ace/Timer_Queue_T.cpp index 41f8f444227..986c08a9777 100644 --- a/ace/Timer_Queue_T.cpp +++ b/ace/Timer_Queue_T.cpp @@ -168,12 +168,12 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR>::expire (const ACE_Time_Value &cur_time) int number_of_timers_expired = 0; - ITERATOR &iter = this->iter (); + ACE_Timer_Node_T<TYPE, FUNCTOR> *expired; // Keep looping while there are timers remaining and the earliest // timer is <= the <cur_time> passed in to the method. - for (ACE_Timer_Node_T<TYPE, FUNCTOR> *expired; + for (ITERATOR &iter = this->iter (); iter.next (expired, cur_time) != 0; ) { |