Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 247 invoked from network); 12 Feb 2009 23:20:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Feb 2009 23:20:26 -0000 Received: (qmail 12526 invoked by uid 500); 12 Feb 2009 23:20:26 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 12470 invoked by uid 500); 12 Feb 2009 23:20:26 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 12461 invoked by uid 99); 12 Feb 2009 23:20:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2009 15:20:26 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2009 23:20:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 987242388A16; Thu, 12 Feb 2009 23:19:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r743923 [2/3] - in /activemq/activemq-cpp/trunk/src: main/ main/activemq/cmsutil/ main/activemq/core/ main/activemq/state/ main/activemq/transport/ main/activemq/transport/correlator/ main/activemq/transport/failover/ main/activemq/transpor... Date: Thu, 12 Feb 2009 23:19:56 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090212231959.987242388A16@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: activemq/activemq-cpp/trunk/src/main/decaf/util/Set.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/Set.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/Set.h (original) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/Set.h Thu Feb 12 23:19:54 2009 @@ -18,235 +18,32 @@ #ifndef _DECAF_UTIL_SET_H_ #define _DECAF_UTIL_SET_H_ -#include -#include #include #include #include #include +#include namespace decaf{ namespace util{ /** - * Set template that wraps around a std::set to provide - * a more user-friendly interface and to provide common - * functions that do not exist in std::set. + * A collection that contains no duplicate elements. More formally, sets contain no + * pair of elements e1 and e2 such that e1 == e2, and at most one null element. + * As implied by its name, this interface models the mathematical set abstraction. + * + * The additional stipulation on constructors is, not surprisingly, that all constructors + * must create a set that contains no duplicate elements (as defined above). + * + * Note: Great care must be exercised if mutable objects are used as set elements. + * The behavior of a set is not specified if the value of an object is changed in a + * manner that affects equals comparisons while the object is an element in the set. */ - template class Set : public util::concurrent::Synchronizable { - private: - - std::set values; - util::concurrent::Mutex mutex; - - private: - - class SetIterator : public Iterator { - private: - - typename std::set::iterator current; - typename std::set::iterator previous; - typename std::set* set; - - public: - - SetIterator( typename std::set* set ) { - this->current = set->begin(); - this->previous = set->end(); - this->set = set; - } - virtual ~SetIterator() {} - - virtual E next() throw( lang::exceptions::NoSuchElementException ){ - if( this->current == set->end() ) { - throw lang::exceptions::NoSuchElementException( - __FILE__, __LINE__, - "Set::Iterator::next - No more elements to return" ); - } - - this->previous = this->current; - return *( this->current++ ); - } - - virtual bool hasNext() const { - return ( this->current != set->end() ); - } - - virtual void remove() throw ( lang::exceptions::IllegalStateException, - lang::exceptions::UnsupportedOperationException ){ - if( this->previous == set->end() ) { - throw lang::exceptions::IllegalStateException( - __FILE__, __LINE__, - "Set::Iterator::remove - Invalid State to call remove" ); - } - - this->set->erase( this->previous ); - this->previous = this->set->end(); - } - }; - + template + class Set : public decaf::util::Collection { public: - /** - * Default constructor - does nothing. - */ - Set(){} - - /** - * Copy constructor - copies the content of the given set into this - * one. - * @param source The source set. - */ - Set( const Set& source ){ - copy( source ); - } - - virtual ~Set(){} - - /** - * Returns an iterator for this collection. The order of Iteration - * is in no particular order other than the natural ording of the - * elements in the Set class. - * @returns Iterator for this collection - */ - Iterator* iterator() { - return new SetIterator( &values ); - } - - /** - * Copies the content of the source set into this set. Erases - * all existing data in this st. - * @param source The source object to copy from. - */ - virtual void copy( const Set& source ) { - // Add all of the entries to this map. - values = source.values; - } - - /** - * Removes all values from this set. - */ - virtual void clear() { - values.clear(); - } - - /** - * Indicates whether or this set contains the given value. - * @param value The value to look up. - * @return true if this set contains the value, otherwise false. - */ - virtual bool contains( const E& value ) const { - typename std::set::const_iterator iter; - iter = values.find( value ); - return iter != values.end(); - } - - /** - * @return if the set contains any element or not, TRUE or FALSE - */ - virtual bool isEmpty() const { - return values.empty(); - } - - /** - * @return The number of elements in this set. - */ - virtual std::size_t size() const { - return values.size(); - } - - /** - * Adds the given value to the set. - * @param value The value to add. - */ - virtual void add( const E& value ) { - values.insert( value ); - } - - /** - * Removes the value from the set. - * @param value The value to be removed. - */ - virtual void remove( const E& value ) { - values.erase( value ); - } - - /** - * @return the all values in this set as a std::vector. - */ - virtual std::vector toArray() const { - std::vector valueArray( values.size() ); - - typename std::set::const_iterator iter; - iter=values.begin(); - for( int ix=0; iter != values.end(); ++iter, ++ix ){ - valueArray[ix] = *iter; - } - - return valueArray; - } - - public: // Methods from Synchronizable - - /** - * Locks the object. - * @throws Exception - */ - virtual void lock() throw( lang::Exception ) { - mutex.lock(); - } - - /** - * Unlocks the object. - * @throws Exception - */ - virtual void unlock() throw( lang::Exception ) { - mutex.unlock(); - } - - /** - * Waits on a signal from this object, which is generated - * by a call to Notify. Must have this object locked before - * calling. - * @throws Exception - */ - virtual void wait() throw( lang::Exception ) { - mutex.wait(); - } - - /** - * Waits on a signal from this object, which is generated - * by a call to Notify. Must have this object locked before - * calling. This wait will timeout after the specified time - * interval. - * @param millisecs the time in millisecsonds to wait, or - * WAIT_INIFINITE - * @throws Exception - */ - virtual void wait( unsigned long millisecs ) - throw( lang::Exception ) { - mutex.wait( millisecs ); - } - - /** - * Signals a waiter on this object that it can now wake - * up and continue. Must have this object locked before - * calling. - * @throws Exception - */ - virtual void notify() throw( lang::Exception ) { - mutex.notify(); - } - - /** - * Signals the waiters on this object that it can now wake - * up and continue. Must have this object locked before - * calling. - * @throws Exception - */ - virtual void notifyAll() throw( lang::Exception ) { - mutex.notifyAll(); - } + virtual ~Set() {} }; Added: activemq/activemq-cpp/trunk/src/main/decaf/util/StlList.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/StlList.h?rev=743923&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/StlList.h (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/StlList.h Thu Feb 12 23:19:54 2009 @@ -0,0 +1,663 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DECAF_UTIL_STLLIST_H_ +#define _DECAF_UTIL_STLLIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace decaf{ +namespace util{ + + /** + * Set template that wraps around a std::set to provide a more + * user-friendly interface and to provide common functions that do + * not exist in std::list. + */ + template + class DECAF_API StlList : public decaf::util::List { + private: + + std::list values; + util::concurrent::Mutex mutex; + + private: + + class StlListIterator : public ListIterator { + private: + + typename std::list::iterator current; + typename std::list::iterator prev; + typename std::list* list; + + public: + + StlListIterator( typename std::list* list ) { + this->current = list->begin(); + this->prev = list->end(); + this->list = list; + } + StlListIterator( typename std::list* list, std::size_t index ) { + this->current = list->begin(); + std::advance( this->current, index ); + this->prev = list->end(); + this->list = list; + } + virtual ~StlListIterator() {} + + virtual E next() throw( lang::exceptions::NoSuchElementException ){ + if( this->current == list->end() ) { + throw lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "List::Iterator::next - No more elements to return" ); + } + + this->prev = this->current; + return *( this->current++ ); + } + + virtual bool hasNext() const { + return ( this->current != list->end() ); + } + + virtual void remove() throw ( lang::exceptions::IllegalStateException, + lang::exceptions::UnsupportedOperationException ){ + if( this->prev == list->end() ) { + throw lang::exceptions::IllegalStateException( + __FILE__, __LINE__, + "List::Iterator::remove - Invalid State to call remove" ); + } + + this->list->erase( this->prev ); + this->prev = this->list->end(); + } + + virtual void add( const E& e DECAF_UNUSED ) + throw ( decaf::lang::exceptions::UnsupportedOperationException, + decaf::lang::exceptions::IllegalArgumentException ) { + + throw lang::exceptions::UnsupportedOperationException( + __FILE__, __LINE__, + "List::ListIterator::add - Not Implemented Yet." ); + } + + virtual void set( const E& e ) + throw ( decaf::lang::exceptions::UnsupportedOperationException, + decaf::lang::exceptions::IllegalArgumentException, + decaf::lang::exceptions::IllegalStateException ) + { + if( this->current == list->end() ) { + throw lang::exceptions::IllegalStateException( + __FILE__, __LINE__, + "List::Iterator::set - Not a valid state for set" ); + } + + *( this->current ) = e; + } + + virtual bool hasPrevious() const { + return ( this->current != this->list->begin() ); + } + + virtual const E& previous() { + if( this->current == this->list->begin() ) { + throw lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "List::ListIterator::previous - No Previous element." ); + } + + typename std::list::const_iterator iter = this->current; + return *( iter-- ); + } + + virtual int nextIndex() const { + if( this->current == this->list->end() ) { + return this->list->size(); + } + + return std::distance( this->list->begin(), this->current ); + } + + virtual int previousIndex() const { + if( this->current == this->list->begin() ) { + return -1; + } + + return std::distance( this->list->begin(), this->current ) - 1; + } + + }; + + class ConstStlListIterator : public decaf::util::ListIterator { + private: + + typename std::list::const_iterator current; + typename std::list::const_iterator prev; + const typename std::list* list; + + public: + + ConstStlListIterator( const typename std::list* list ) { + this->current = list->begin(); + this->prev = list->end(); + this->list = list; + } + ConstStlListIterator( const typename std::list* list, std::size_t index ) { + this->current = list->begin(); + std::advance( this->current, index ); + this->prev = list->end(); + this->list = list; + } + virtual ~ConstStlListIterator() {} + + virtual E next() throw( lang::exceptions::NoSuchElementException ){ + if( this->current == list->end() ) { + throw lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "List::Iterator::next - No more elements to return" ); + } + + this->prev = this->current; + return *( this->current++ ); + } + + virtual bool hasNext() const { + return ( this->current != list->end() ); + } + + virtual void remove() throw ( lang::exceptions::IllegalStateException, + lang::exceptions::UnsupportedOperationException ){ + + throw lang::exceptions::UnsupportedOperationException( + __FILE__, __LINE__, + "List::ListIterator::remove - Const Iterator." ); + } + + virtual void add( const E& e DECAF_UNUSED ) + throw ( decaf::lang::exceptions::UnsupportedOperationException, + decaf::lang::exceptions::IllegalArgumentException ) { + + throw lang::exceptions::UnsupportedOperationException( + __FILE__, __LINE__, + "List::ListIterator::add - Const Iterator." ); + } + + virtual void set( const E& e DECAF_UNUSED ) + throw ( decaf::lang::exceptions::UnsupportedOperationException, + decaf::lang::exceptions::IllegalArgumentException, + decaf::lang::exceptions::IllegalStateException ) + { + throw lang::exceptions::UnsupportedOperationException( + __FILE__, __LINE__, + "List::ListIterator::set - Const Iterator." ); + } + + virtual bool hasPrevious() const { + return ( this->current != this->list->begin() ); + } + + virtual const E& previous() { + if( this->current == this->list->begin() ) { + throw lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "List::ListIterator::previous - No Previous element." ); + } + + typename std::list::const_iterator iter = this->current; + return *( iter-- ); + } + + virtual int nextIndex() const { + if( this->current == this->list->end() ) { + return this->list->size(); + } + + return std::distance( this->list->begin(), this->current ); + } + + virtual int previousIndex() const { + if( this->current == this->list->begin() ) { + return -1; + } + + return std::distance( this->list->begin(), this->current ) - 1; + } + }; + + public: + + /** + * Default constructor - does nothing. + */ + StlList() {} + + /** + * Copy constructor - copies the content of the given set into this + * one. + * @param source The source set. + */ + StlList( const StlList& source ) : List() { + copy( source ); + } + + /** + * Copy constructor - copies the content of the given set into this + * one. + * @param source The source set. + */ + StlList( const Collection& source ) : List() { + copy( source ); + } + + virtual ~StlList() {} + + /** + * {@inheritDoc} + */ + virtual bool equals( const StlList& source ) const { + return this->values == source.values; + } + virtual bool equals( const Collection& source ) const { + if( this->values.size() != source.size() ) { + return false; + } + + std::auto_ptr< Iterator > srcIter( source.iterator() ); + std::auto_ptr< Iterator > thisIter( this->iterator() ); + + while( srcIter->hasNext() ) { + if( !( thisIter->next() == srcIter->next() ) ) { + return false; + } + } + + return true; + } + + /** + * {@inheritDoc} + */ + virtual Iterator* iterator() { + return new StlListIterator( &values ); + } + virtual Iterator* iterator() const { + return new ConstStlListIterator( &values ); + } + + /** + * {@inheritDoc} + */ + virtual ListIterator* listIterator() { + return new StlListIterator( &values ); + } + virtual ListIterator* listIterator() const { + return new ConstStlListIterator( &values ); + } + + /** + * {@inheritDoc} + */ + virtual ListIterator* listIterator( std::size_t index ) + throw( decaf::lang::exceptions::IndexOutOfBoundsException ) { + + if( index >= this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::listIterator - Index greater than size()" ); + } + + return new StlListIterator( &values, index ); + } + virtual ListIterator* listIterator( std::size_t index ) const + throw( decaf::lang::exceptions::IndexOutOfBoundsException ) { + + if( index >= this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::listIterator - Index greater than size()" ); + } + + return new ConstStlListIterator( &values, index ); + } + + /** + * {@inheritDoc} + */ + virtual void copy( const StlList& source ) { + this->values.clear(); + this->values = source.values; + } + virtual void copy( const Collection& source ) { + this->values.clear(); + + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + this->add( srcIter->next() ); + } + } + + /** + * {@inheritDoc} + */ + virtual void clear() throw ( lang::exceptions::UnsupportedOperationException ) { + values.clear(); + } + + /** + * {@inheritDoc} + */ + virtual bool contains( const E& value ) const throw ( lang::Exception ) { + typename std::list::const_iterator iter; + iter = std::find( values.begin(), values.end(), value ); + return iter != values.end(); + } + + /** + * {@inheritDoc} + */ + virtual bool containsAll( const Collection& source ) const + throw ( lang::Exception ) { + + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + if( !this->contains( srcIter->next() ) ) { + return false; + } + } + + return true; + } + + /** + * {@inheritDoc} + */ + virtual std::size_t indexOf( const E& value ) + throw ( decaf::lang::exceptions::NoSuchElementException ) { + + typename std::list::iterator iter; + iter = std::find( values.begin(), values.end(), value ); + + if( iter == values.end() ) { + throw decaf::lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "List::indexOf - No matching element in list" ); + } + + return std::distance( values.begin(), iter ); + } + + /** + * {@inheritDoc} + */ + virtual std::size_t lastIndexOf( const E& value ) + throw ( decaf::lang::exceptions::NoSuchElementException ) { + + typename std::list::reverse_iterator iter; + iter = std::find( values.rbegin(), values.rend(), value ); + + if( iter == values.rend() ) { + throw decaf::lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "List::lastIndexOf - No matching element in list" ); + } + + // Now reverse the result to get the last index + return this->size() - std::distance( values.rbegin(), iter ) - 1; + } + + /** + * {@inheritDoc} + */ + virtual bool isEmpty() const { + return values.empty(); + } + + /** + * {@inheritDoc} + */ + virtual std::size_t size() const { + return values.size(); + } + + /** + * {@inheritDoc} + */ + virtual E get( std::size_t index ) const + throw ( decaf::lang::exceptions::IndexOutOfBoundsException ) { + + if( index >= this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::get - Index greater than size()" ); + } + + // Advance from begin and return the value at that location. + typename std::list::const_iterator iter = this->values.begin(); + std::advance( iter, index ); + return *( iter ); + } + + /** + * {@inheritDoc} + */ + virtual E set( std::size_t index, const E& element ) + throw ( decaf::lang::exceptions::IndexOutOfBoundsException ){ + + if( index >= this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::get - Index greater than size()" ); + } + + // Advance from begin and return the value at that location + // after setting the value to the new value. + typename std::list::iterator iter = this->values.begin(); + std::advance( iter, index ); + E oldValue = *iter; + *iter = element; + + return oldValue; + } + + /** + * {@inheritDoc} + */ + virtual bool add( const E& value ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + values.insert( values.end(), value ); + + return true; + } + + /** + * {@inheritDoc} + */ + virtual void add( std::size_t index, const E& element ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IndexOutOfBoundsException ) { + + if( index > this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::add - Index greater than size()" ); + } + + // Advance from begin and insert the value at that location + typename std::list::iterator iter = this->values.begin(); + std::advance( iter, index ); + this->values.insert( iter, element ); + } + + /** + * {@inheritDoc} + */ + virtual bool addAll( const Collection& source ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + return this->addAll( 0, source ); + } + + /** + * {@inheritDoc} + */ + virtual bool addAll( std::size_t index, const Collection& source ) + throw ( decaf::lang::exceptions::UnsupportedOperationException, + decaf::lang::exceptions::IndexOutOfBoundsException ) { + + if( index != 0 && index > this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::addAll - Index greater than size()" ); + } + + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + this->add( index++, srcIter->next() ); + } + + return !source.isEmpty(); + } + + /** + * {@inheritDoc} + */ + virtual bool remove( const E& value ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + std::size_t origSize = this->size(); + this->values.remove( value ); + return origSize != this->size(); + } + + /** + * {@inheritDoc} + */ + virtual E remove( std::size_t index ) + throw ( decaf::lang::exceptions::UnsupportedOperationException, + decaf::lang::exceptions::IndexOutOfBoundsException ) { + + if( index > this->size() ) { + throw decaf::lang::exceptions::IndexOutOfBoundsException( + __FILE__, __LINE__, + "List::add - Index greater than size()" ); + } + + // Advance from begin and insert the value at that location + typename std::list::iterator iter = this->values.begin(); + std::advance( iter, index ); + E oldValue = *iter; + this->values.erase( iter ); + + return oldValue; + } + + /** + * {@inheritDoc} + */ + virtual bool removeAll( const Collection& source ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + std::size_t origSize = this->size(); + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + this->remove( srcIter->next() ); + } + + return origSize == this->size(); + } + + /** + * {@inheritDoc} + */ + virtual bool retainAll( const Collection& collection ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + bool result = false; + std::auto_ptr< Iterator > iter( this->iterator() ); + while( iter->hasNext() ) { + if( !collection.contains( iter->next() ) ) { + iter->remove(); + result = true; + } + } + + return result; + } + + /** + * {@inheritDoc} + */ + virtual std::vector toArray() const { + std::vector valueArray( values.size() ); + + typename std::list::const_iterator iter; + iter=values.begin(); + for( int ix=0; iter != values.end(); ++iter, ++ix ){ + valueArray[ix] = *iter; + } + + return valueArray; + } + + public: + + virtual void lock() throw( lang::Exception ) { + mutex.lock(); + } + + virtual void unlock() throw( lang::Exception ) { + mutex.unlock(); + } + + virtual void wait() throw( lang::Exception ) { + mutex.wait(); + } + + virtual void wait( unsigned long millisecs ) throw( lang::Exception ) { + mutex.wait( millisecs ); + } + + virtual void notify() throw( lang::Exception ) { + mutex.notify(); + } + + virtual void notifyAll() throw( lang::Exception ) { + mutex.notifyAll(); + } + + }; + +}} + +#endif /*_DECAF_UTIL_STLLIST_H_*/ Propchange: activemq/activemq-cpp/trunk/src/main/decaf/util/StlList.h ------------------------------------------------------------------------------ svn:eol-style = native Copied: activemq/activemq-cpp/trunk/src/main/decaf/util/StlMap.h (from r743068, activemq/activemq-cpp/trunk/src/main/decaf/util/STLMap.h) URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/StlMap.h?p2=activemq/activemq-cpp/trunk/src/main/decaf/util/StlMap.h&p1=activemq/activemq-cpp/trunk/src/main/decaf/util/STLMap.h&r1=743068&r2=743923&rev=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/STLMap.h (original) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/StlMap.h Thu Feb 12 23:19:54 2009 @@ -33,8 +33,8 @@ * a more user-friendly interface and to provide common * functions that do not exist in std::map. */ - template > class STLMap : - public Map { + template > + class StlMap : public Map { private: std::map valueMap; @@ -45,14 +45,14 @@ /** * Default constructor - does nothing. */ - STLMap() : Map() {} + StlMap() : Map() {} /** * Copy constructor - copies the content of the given map into this * one. * @param source The source map. */ - STLMap( const STLMap& source ) : Map() { + StlMap( const StlMap& source ) : Map() { copy( source ); } @@ -61,11 +61,11 @@ * one. * @param source The source map. */ - STLMap( const Map& source ) : Map() { + StlMap( const Map& source ) : Map() { copy( source ); } - virtual ~STLMap() {} + virtual ~StlMap() {} /** * Comparison, equality is dependent on the method of determining @@ -73,7 +73,7 @@ * @param source - Map to compare to this one. * @returns true if the Map passed is equal in value to this one. */ - virtual bool equals( const STLMap& source ) const { + virtual bool equals( const StlMap& source ) const { return this->valueMap == source.valueMap; } @@ -99,7 +99,7 @@ * all existing data in this map. * @param source The source object to copy from. */ - virtual void copy( const STLMap& source ) { + virtual void copy( const StlMap& source ) { this->valueMap.clear(); this->valueMap.insert( source.valueMap.begin(), source.valueMap.end() ); } @@ -198,7 +198,7 @@ * @param key The target key. * @param value The value to be set. */ - virtual void putAll( const STLMap& other ) { + virtual void putAll( const StlMap& other ) { this->valueMap.insert( other.valueMap.begin(), other.valueMap.end() ); } virtual void putAll( const Map& other ) { Added: activemq/activemq-cpp/trunk/src/main/decaf/util/StlQueue.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/StlQueue.h?rev=743923&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/StlQueue.h (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/StlQueue.h Thu Feb 12 23:19:54 2009 @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef _DECAF_UTIL_STLQUEUE_H_ +#define _DECAF_UTIL_STLQUEUE_H_ + +#include +#include +#include +#include + +namespace decaf{ +namespace util{ + + /** + * The Queue class accepts messages with an psuh(m) command + * where m is the message to be queued. It destructively + * returns the message with pop(). pop() returns messages in + * the order they were enqueued. + * + * Queue is implemented with an instance of the STL queue object. + * The interface is essentially the same as that of the STL queue + * except that the pop method actually reaturns a reference to the + * element popped. This frees the app from having to call the + * front method before calling pop. + * + * Queue sq; // make a queue to hold string messages + * sq.push(s); // enqueues a message m + * string s = sq.pop(); // dequeues a message + * + * = DESIGN CONSIDERATIONS + * + * The Queue class inherits from the Synchronizable interface and + * provides methods for locking and unlocking this queue as well as + * waiting on this queue. In a multi-threaded app this can allow + * for multiple threads to be reading from and writing to the same + * Queue. + * + * Clients should consider that in a multiple threaded app it is + * possible that items could be placed on the queue faster than + * you are taking them off, so protection should be placed in your + * polling loop to ensure that you don't get stuck there. + */ + + template class StlQueue : public concurrent::Synchronizable { + public: + + StlQueue() {} + virtual ~StlQueue() {} + + /** + * Empties this queue. + */ + void clear() { + queue.clear(); + } + + /** + * Returns a Reference to the element at the head of the queue + * @return reference to a queue type object or (safe) + */ + T& front() { + if( queue.empty() ) { + return getSafeValue(); + } + + return queue.front(); + } + + /** + * Returns a Reference to the element at the head of the queue + * @return reference to a queue type object or (safe) + */ + const T& front() const { + if( queue.empty() ) { + return getSafeValue(); + } + + return queue.front(); + } + + /** + * Returns a Reference to the element at the tail of the queue + * @return reference to a queue type object or (safe) + */ + T& back() { + if( queue.empty() ) { + return getSafeValue(); + } + + return queue.back(); + } + + /** + * Returns a Reference to the element at the tail of the queue + * @return reference to a queue type object or (safe) + */ + const T& back() const { + if( queue.empty() ) { + return getSafeValue(); + } + + return queue.back(); + } + + /** + * Places a new Object at the Tail of the queue + * @param t - Queue Object Type reference. + */ + void push( const T &t ) { + queue.push_back( t ); + } + + /** + * Places a new Object at the front of the queue + * @param t - Queue Object Type reference. + */ + void enqueueFront( const T &t ) { + queue.push_front( t ); + } + + /** + * Removes and returns the element that is at the Head of the queue + * @return reference to a queue type object or (safe) + */ + T pop() { + if( queue.empty() ) { + return getSafeValue(); + } + + // Pop the element into a temp, since we need to remain locked. + // this means getting front and then popping. + T temp = queue.front(); + queue.pop_front(); + + return temp; + } + + /** + * Gets the Number of elements currently in the Queue + * @return Queue Size + */ + size_t size() const{ + return queue.size(); + } + + /** + * Checks if this Queue is currently empty + * @return boolean indicating queue emptiness + */ + bool empty() const { + return queue.empty(); + } + + /** + * @return the all values in this queue as a std::vector. + */ + virtual std::vector toArray() const { + std::vector valueArray( queue.begin(), queue.end() ); + return valueArray; + } + + /** + * Reverses the order of the contents of this queue and stores them + * in the target queue. + * @param target - The target queue that will receive the contents of + * this queue in reverse order. + */ + void reverse( StlQueue& target ) const { + target.queue.insert( target.queue.end(), queue.rbegin(), queue.rend() ); + } + + /** + * Locks the object. + */ + virtual void lock() throw( lang::Exception ){ + mutex.lock(); + } + + /** + * Unlocks the object. + */ + virtual void unlock() throw( lang::Exception ){ + mutex.unlock(); + } + + /** + * Waits on a signal from this object, which is generated + * by a call to Notify. Must have this object locked before + * calling. + */ + virtual void wait() throw( lang::Exception ){ + mutex.wait(); + } + + /** + * Waits on a signal from this object, which is generated + * by a call to Notify. Must have this object locked before + * calling. This wait will timeout after the specified time + * interval. + * @param millisecs time to wait, or WAIT_INIFINITE + * @throws ActiveMQException + */ + virtual void wait( unsigned long millisecs ) + throw( lang::Exception ) { + + mutex.wait(millisecs); + } + + /** + * Signals a waiter on this object that it can now wake + * up and continue. Must have this object locked before + * calling. + */ + virtual void notify() throw( lang::Exception ){ + mutex.notify(); + } + + /** + * Signals the waiters on this object that it can now wake + * up and continue. Must have this object locked before + * calling. + */ + virtual void notifyAll() throw( lang::Exception ){ + mutex.notifyAll(); + } + + public: // Statics + + /** + * Fetch a reference to the safe value this object will return + * when there is nothing to fetch from the queue. + * @return Reference to this Queues safe object + */ + T& getSafeValue() { + static T safe; + return safe; + } + + private: + + // The real queue + std::list queue; + + // Object used for sync + util::concurrent::Mutex mutex; + + }; + +}} + +#endif /*_DECAF_UTIL_STLQUEUE_H_*/ Propchange: activemq/activemq-cpp/trunk/src/main/decaf/util/StlQueue.h ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/src/main/decaf/util/StlSet.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/StlSet.h?rev=743923&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/StlSet.h (added) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/StlSet.h Thu Feb 12 23:19:54 2009 @@ -0,0 +1,368 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _DECAF_UTIL_STLSET_H_ +#define _DECAF_UTIL_STLSET_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace decaf{ +namespace util{ + + /** + * Set template that wraps around a std::set to provide + * a more user-friendly interface and to provide common + * functions that do not exist in std::set. + */ + template + class StlSet : public decaf::util::Set { + private: + + std::set values; + util::concurrent::Mutex mutex; + + private: + + class SetIterator : public Iterator { + private: + + typename std::set::iterator current; + typename std::set::iterator previous; + typename std::set* set; + + public: + + SetIterator( typename std::set* set ) { + this->current = set->begin(); + this->previous = set->end(); + this->set = set; + } + virtual ~SetIterator() {} + + virtual E next() throw( lang::exceptions::NoSuchElementException ){ + if( this->current == set->end() ) { + throw lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "Set::Iterator::next - No more elements to return" ); + } + + this->previous = this->current; + return *( this->current++ ); + } + + virtual bool hasNext() const { + return ( this->current != set->end() ); + } + + virtual void remove() throw ( lang::exceptions::IllegalStateException, + lang::exceptions::UnsupportedOperationException ){ + if( this->previous == set->end() ) { + throw lang::exceptions::IllegalStateException( + __FILE__, __LINE__, + "Set::Iterator::remove - Invalid State to call remove" ); + } + + this->set->erase( this->previous ); + this->previous = this->set->end(); + } + }; + + class ConstSetIterator : public Iterator { + private: + + typename std::set::const_iterator current; + typename std::set::const_iterator previous; + const typename std::set* set; + + public: + + ConstSetIterator( const typename std::set* set ) { + this->current = set->begin(); + this->previous = set->end(); + this->set = set; + } + virtual ~ConstSetIterator() {} + + virtual E next() throw( lang::exceptions::NoSuchElementException ){ + if( this->current == set->end() ) { + throw lang::exceptions::NoSuchElementException( + __FILE__, __LINE__, + "Set::Iterator::next - No more elements to return" ); + } + + this->previous = this->current; + return *( this->current++ ); + } + + virtual bool hasNext() const { + return ( this->current != set->end() ); + } + + virtual void remove() throw ( lang::exceptions::IllegalStateException, + lang::exceptions::UnsupportedOperationException ){ + throw lang::exceptions::UnsupportedOperationException( + __FILE__, __LINE__, + "Set::Iterator::remove - Not Valid on a Const Iterator" ); + } + }; + + public: + + /** + * Default constructor - does nothing. + */ + StlSet() {} + + /** + * Copy constructor - copies the content of the given set into this + * one. + * @param source The source set. + */ + StlSet( const StlSet& source ){ + copy( source ); + } + + /** + * Copy constructor - copies the content of the given set into this + * one. + * @param source The source set. + */ + StlSet( const Collection& source ){ + copy( source ); + } + + virtual ~StlSet() {} + + /** + * {@inheritDoc} + */ + Iterator* iterator() { + return new SetIterator( &values ); + } + Iterator* iterator() const { + return new ConstSetIterator( &values ); + } + + /** + * {@inheritDoc} + */ + virtual bool equals( const StlSet& source ) const { + return this->values == source.values; + } + virtual bool equals( const Collection& source ) const { + if( this->values.size() != source.size() ) { + return false; + } + + std::auto_ptr< Iterator > srcIter( source.iterator() ); + std::auto_ptr< Iterator > thisIter( this->iterator() ); + + while( srcIter->hasNext() ) { + if( !( thisIter->next() == srcIter->next() ) ) { + return false; + } + } + + return true; + } + + /** + * {@inheritDoc} + */ + virtual void copy( const StlSet& source ) { + this->values.clear(); + this->values = source.values; + } + virtual void copy( const Collection& source ) { + this->values.clear(); + + std::auto_ptr< Iterator > iter( source.iterator() ); + while( iter->hasNext() ) { + this->values.insert( iter->next() ); + } + } + + /** + * {@inheritDoc} + */ + virtual void clear() throw ( lang::exceptions::UnsupportedOperationException ) { + values.clear(); + } + + /** + * {@inheritDoc} + */ + virtual bool contains( const E& value ) const throw ( lang::Exception ) { + typename std::set::const_iterator iter; + iter = values.find( value ); + return iter != values.end(); + } + + /** + * {@inheritDoc} + */ + virtual bool containsAll( const Collection& source ) const + throw ( lang::Exception ) { + + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + if( !this->contains( srcIter->next() ) ) { + return false; + } + } + + return true; + } + + /** + * @return if the set contains any element or not, TRUE or FALSE + */ + virtual bool isEmpty() const { + return values.empty(); + } + + /** + * @return The number of elements in this set. + */ + virtual std::size_t size() const { + return values.size(); + } + + /** + * {@inheritDoc} + */ + virtual bool add( const E& value ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + return values.insert( value ).second; + } + + /** + * {@inheritDoc} + */ + virtual bool addAll( const Collection& source ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + bool result = false; + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + result = this->add( srcIter->next() ); + } + + return result; + } + + /** + * {@inheritDoc} + */ + virtual bool remove( const E& value ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + return values.erase( value ) != 0; + } + + /** + * {@inheritDoc} + */ + virtual bool removeAll( const Collection& source ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + bool result = false; + std::auto_ptr< Iterator > srcIter( source.iterator() ); + while( srcIter->hasNext() ) { + result = this->remove( srcIter->next() ); + } + + return result; + } + + /** + * {@inheritDoc} + */ + virtual bool retainAll( const Collection& collection ) + throw ( lang::exceptions::UnsupportedOperationException, + lang::exceptions::IllegalArgumentException ) { + + bool result = false; + std::auto_ptr< Iterator > iter( this->iterator() ); + while( iter->hasNext() ) { + if( !collection.contains( iter->next() ) ) { + iter->remove(); + result = true; + } + } + + return result; + } + + /** + * {@inheritDoc} + */ + virtual std::vector toArray() const { + std::vector valueArray( values.size() ); + + typename std::set::const_iterator iter; + iter=values.begin(); + for( int ix=0; iter != values.end(); ++iter, ++ix ){ + valueArray[ix] = *iter; + } + + return valueArray; + } + + public: + + virtual void lock() throw( lang::Exception ) { + mutex.lock(); + } + + virtual void unlock() throw( lang::Exception ) { + mutex.unlock(); + } + + virtual void wait() throw( lang::Exception ) { + mutex.wait(); + } + + virtual void wait( unsigned long millisecs ) throw( lang::Exception ) { + mutex.wait( millisecs ); + } + + virtual void notify() throw( lang::Exception ) { + mutex.notify(); + } + + virtual void notifyAll() throw( lang::Exception ) { + mutex.notifyAll(); + } + + }; + +}} + +#endif /*_DECAF_UTIL_STLSET_H_*/ Propchange: activemq/activemq-cpp/trunk/src/main/decaf/util/StlSet.h ------------------------------------------------------------------------------ svn:eol-style = native Copied: activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentStlMap.h (from r743103, activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentSTLMap.h) URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentStlMap.h?p2=activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentStlMap.h&p1=activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentSTLMap.h&r1=743103&r2=743923&rev=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentSTLMap.h (original) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ConcurrentStlMap.h Thu Feb 12 23:19:54 2009 @@ -41,7 +41,7 @@ * Java HashTable. */ template > - class ConcurrentSTLMap : public ConcurrentMap { + class ConcurrentStlMap : public ConcurrentMap { private: std::map valueMap; @@ -52,14 +52,14 @@ /** * Default constructor - does nothing. */ - ConcurrentSTLMap() : ConcurrentMap() {} + ConcurrentStlMap() : ConcurrentMap() {} /** * Copy constructor - copies the content of the given map into this * one. * @param source The source map. */ - ConcurrentSTLMap( const ConcurrentSTLMap& source ) : ConcurrentMap() { + ConcurrentStlMap( const ConcurrentStlMap& source ) : ConcurrentMap() { copy( source ); } @@ -68,11 +68,11 @@ * one. * @param source The source map. */ - ConcurrentSTLMap( const Map& source ) : ConcurrentMap() { + ConcurrentStlMap( const Map& source ) : ConcurrentMap() { copy( source ); } - virtual ~ConcurrentSTLMap() {} + virtual ~ConcurrentStlMap() {} /** * Comparison, equality is dependent on the method of determining @@ -80,7 +80,7 @@ * @param source - Map to compare to this one. * @returns true if the Map passed is equal in value to this one. */ - virtual bool equals( const ConcurrentSTLMap& source ) const { + virtual bool equals( const ConcurrentStlMap& source ) const { synchronized( &mutex ) { return this->valueMap == source.valueMap; } @@ -113,7 +113,7 @@ * all existing data in this map. * @param source The source object to copy from. */ - virtual void copy( const ConcurrentSTLMap& source ) { + virtual void copy( const ConcurrentStlMap& source ) { synchronized( &mutex ) { this->valueMap.clear(); this->valueMap.insert( source.valueMap.begin(), source.valueMap.end() ); @@ -237,7 +237,7 @@ * @param key The target key. * @param value The value to be set. */ - virtual void putAll( const ConcurrentSTLMap& other ) { + virtual void putAll( const ConcurrentStlMap& other ) { synchronized( &mutex ) { this->valueMap.insert( other.valueMap.begin(), other.valueMap.end() ); } Modified: activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ThreadPool.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ThreadPool.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ThreadPool.h (original) +++ activemq/activemq-cpp/trunk/src/main/decaf/util/concurrent/ThreadPool.h Thu Feb 12 23:19:54 2009 @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -40,16 +40,15 @@ * is queued then a new batch is allocated. The user can specify * the size of the blocks, otherwise a default value is used. *

- * When the user queues a task they must also queue a listner to + * When the user queues a task they must also queue a listener to * be notified when the task has completed, this provides the user * with a mechanism to know when a task object can be freed. *

* To have the Thread Pool perform a task, the user enqueue's an - * object that implements the Runnable insterface and + * object that implements the Runnable interface and * one of the worker threads will executing it in its thread context. */ - class DECAF_API ThreadPool : public PooledThreadListener - { + class DECAF_API ThreadPool : public PooledThreadListener { public: // Constants @@ -65,18 +64,18 @@ std::vector< PooledThread* > pool; // Queue of Task that are in need of completion - util::Queue queue; + util::StlQueue queue; - // Max number of Threads this Pool can contian + // Max number of Threads this Pool can contain std::size_t maxThreads; // Max number of tasks that can be allocated at a time std::size_t blockSize; - // boolean flag use to indocate that this object is shutting down. + // boolean flag use to indicate that this object is shutting down. bool shutdown; - // Count of threads that are currently free to perfom some work. + // Count of threads that are currently free to perform some work. std::size_t freeThreads; // Mutex for locking operations that affect the pool. @@ -123,7 +122,7 @@ * Returns the current number of Threads in the Pool, this is * how many there are now, not how many are active or the max * number that might exist. - * @return integer number of threads in existance. + * @return integer number of threads in existence. */ virtual std::size_t getPoolSize() const { return pool.size(); } @@ -175,9 +174,9 @@ /** * Returns the current number of available threads in the pool, threads * that are performing a user task are considered unavailable. This value - * could change immeadiately after calling as Threads could finish right + * could change immediately after calling as Threads could finish right * after and be available again. This is informational only. - * @return totoal free threads + * @return total free threads */ virtual std::size_t getFreeThreadCount() const { return freeThreads; @@ -208,7 +207,7 @@ * the callee should assume that the PooledThread is now no longer * running. * @param thread Pointer to the Pooled Thread that is making this call - * @param ex The Exception that occured. + * @param ex The Exception that occurred. */ virtual void onTaskException( PooledThread* thread, lang::Exception& ex ); @@ -226,7 +225,7 @@ private: /** - * Allocates the requested ammount of Threads, won't exceed + * Allocates the requested amount of Threads, won't exceed * maxThreads. * @param count the number of threads to create */ Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.cpp (original) +++ activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.cpp Thu Feb 12 23:19:54 2009 @@ -17,7 +17,7 @@ #include "MapBenchmark.h" #include -#include +#include using namespace decaf; using namespace decaf::util; @@ -33,8 +33,8 @@ int numRuns = 500; std::string test = "test"; std::string resultStr = ""; - STLMap stringCopy; - STLMap intCopy; + StlMap stringCopy; + StlMap intCopy; for( int i = 0; i < numRuns; ++i ) { stringMap.put( test + Integer::toString(i), test + Integer::toString(i) ); Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.h (original) +++ activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/MapBenchmark.h Thu Feb 12 23:19:54 2009 @@ -19,7 +19,7 @@ #define _DECAF_UTIL_MAPBENCHMARK_H_ #include -#include +#include namespace decaf{ namespace util{ @@ -30,8 +30,8 @@ { private: - STLMap< std::string, std::string> stringMap; - STLMap intMap; + StlMap< std::string, std::string> stringMap; + StlMap intMap; public: Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.cpp (original) +++ activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.cpp Thu Feb 12 23:19:54 2009 @@ -35,8 +35,8 @@ std::string test = "test"; std::string resultStr = ""; int resultInt = 0; - Queue stringQCopy; - Queue intQCopy; + StlQueue stringQCopy; + StlQueue intQCopy; for( int i = 0; i < numRuns; ++i ) { stringQ.push( test ); Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.h (original) +++ activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/QueueBenchmark.h Thu Feb 12 23:19:54 2009 @@ -19,19 +19,19 @@ #define _DECAF_QUEUE_QUEUEBENCHMARK_H_ #include -#include +#include namespace decaf{ namespace util{ class QueueBenchmark : public benchmark::BenchmarkBase< - decaf::util::QueueBenchmark, Queue > + decaf::util::QueueBenchmark, StlQueue > { private: - Queue stringQ; - Queue intQ; + StlQueue stringQ; + StlQueue intQ; public: Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.cpp (original) +++ activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.cpp Thu Feb 12 23:19:54 2009 @@ -34,8 +34,8 @@ int numRuns = 500; std::string test = "test"; std::string resultStr = ""; - Set stringCopy; - Set intCopy; + StlSet stringCopy; + StlSet intCopy; for( int i = 0; i < numRuns; ++i ) { stringSet.add( test + Integer::toString(i) ); Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.h (original) +++ activemq/activemq-cpp/trunk/src/test-benchmarks/decaf/util/SetBenchmark.h Thu Feb 12 23:19:54 2009 @@ -19,7 +19,7 @@ #define _DECAF_UTIL_SETBENCHMARK_H_ #include -#include +#include namespace decaf{ namespace util{ @@ -30,8 +30,8 @@ { private: - Set intSet; - Set stringSet; + StlSet intSet; + StlSet stringSet; public: Modified: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp Thu Feb 12 23:19:54 2009 @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include @@ -43,7 +43,7 @@ public: unsigned int count; - decaf::util::Set threadIds; + decaf::util::StlSet threadIds; SlowListener() { count = 0; } Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/Makefile.am (original) +++ activemq/activemq-cpp/trunk/src/test/Makefile.am Thu Feb 12 23:19:54 2009 @@ -99,11 +99,11 @@ decaf/util/UUIDTest.cpp \ decaf/util/RandomTest.cpp \ decaf/util/MapTest.cpp \ - decaf/util/STLMapTest.cpp \ + decaf/util/StlMapTest.cpp \ decaf/util/QueueTest.cpp \ decaf/util/ListTest.cpp \ decaf/util/SetTest.cpp \ - decaf/util/concurrent/ConcurrentSTLMapTest.cpp \ + decaf/util/concurrent/ConcurrentStlMapTest.cpp \ decaf/util/concurrent/CountDownLatchTest.cpp \ decaf/util/concurrent/MutexTest.cpp \ decaf/util/concurrent/ThreadPoolTest.cpp \ @@ -200,10 +200,10 @@ decaf/util/RandomTest.h \ decaf/util/ListTest.h \ decaf/util/MapTest.h \ - decaf/util/STLMapTest.h \ + decaf/util/StlMapTest.h \ decaf/util/QueueTest.h \ decaf/util/SetTest.h \ - decaf/util/concurrent/ConcurrentSTLMapTest.h \ + decaf/util/concurrent/ConcurrentStlMapTest.h \ decaf/util/concurrent/CountDownLatchTest.h \ decaf/util/concurrent/MutexTest.h \ decaf/util/concurrent/ThreadPoolTest.h \ Modified: activemq/activemq-cpp/trunk/src/test/activemq/commands/BrokerIdTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/commands/BrokerIdTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/commands/BrokerIdTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/activemq/commands/BrokerIdTest.cpp Thu Feb 12 23:19:54 2009 @@ -18,7 +18,7 @@ #include "BrokerIdTest.h" #include -#include +#include #include #include @@ -66,7 +66,7 @@ myCommand2.setValue( "B" ); myCommand3.setValue( "C" ); - STLMap< BrokerId*, int, BrokerIdComparitor > testMap; + StlMap< BrokerId*, int, BrokerIdComparitor > testMap; testMap.put( &myCommand1, 0 ); testMap.put( &myCommand3, 0 ); @@ -93,7 +93,7 @@ CPPUNIT_ASSERT( myCommand1->compareTo( *myCommand2 ) == 0 ); CPPUNIT_ASSERT( myCommand1->compareTo( *myCommand3 ) == -1 ); - STLMap< Pointer, int, COMPARATOR > testMap; + StlMap< Pointer, int, COMPARATOR > testMap; testMap.put( myCommand3, 0 ); testMap.put( myCommand1, 0 ); Modified: activemq/activemq-cpp/trunk/src/test/decaf/lang/SystemTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/lang/SystemTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/lang/SystemTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/lang/SystemTest.cpp Thu Feb 12 23:19:54 2009 @@ -18,7 +18,7 @@ #include "SystemTest.h" #include -#include +#include using namespace std; using namespace decaf; @@ -44,7 +44,7 @@ //////////////////////////////////////////////////////////////////////////////// void SystemTest::test_getenv2() { - STLMap values = System::getenv(); + StlMap values = System::getenv(); CPPUNIT_ASSERT( values.size() != 0 ); CPPUNIT_ASSERT( values.containsKey( "PATH" ) || values.containsKey( "Path" ) ); @@ -54,10 +54,10 @@ //////////////////////////////////////////////////////////////////////////////// void SystemTest::test_setenv() { - STLMap values1 = System::getenv(); + StlMap values1 = System::getenv(); CPPUNIT_ASSERT( !values1.containsKey( "PATH_ASDFGHJKL" ) ); System::setenv( "PATH_ASDFGHJKL", "test" ); - STLMap values2 = System::getenv(); + StlMap values2 = System::getenv(); CPPUNIT_ASSERT( values2.containsKey( "PATH_ASDFGHJKL" ) ); System::unsetenv( "PATH_ASDFGHJKL" ); } @@ -65,13 +65,13 @@ //////////////////////////////////////////////////////////////////////////////// void SystemTest::test_unsetenv() { - STLMap values1 = System::getenv(); + StlMap values1 = System::getenv(); CPPUNIT_ASSERT( !values1.containsKey( "PATH_ASDFGHJKL" ) ); System::setenv( "PATH_ASDFGHJKL", "test" ); - STLMap values2 = System::getenv(); + StlMap values2 = System::getenv(); CPPUNIT_ASSERT( values2.containsKey( "PATH_ASDFGHJKL" ) ); System::unsetenv( "PATH_ASDFGHJKL" ); - STLMap values3 = System::getenv(); + StlMap values3 = System::getenv(); CPPUNIT_ASSERT( !values3.containsKey( "PATH_ASDFGHJKL" ) ); } Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.cpp Thu Feb 12 23:19:54 2009 @@ -17,6 +17,10 @@ #include "ListTest.h" +#include +#include +#include + using namespace std; using namespace decaf; using namespace decaf::util; @@ -28,7 +32,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testContains(){ - List list; + StlList list; CPPUNIT_ASSERT( list.contains( "bob" ) == false); list.add( "bob" ); @@ -40,7 +44,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testIndexOf(){ - List list; + StlList list; list.add( "bob" ); // 0 list.add( "fred" ); // 1 @@ -68,7 +72,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testLastIndexOf(){ - List list; + StlList list; list.add( "bob" ); // 0 list.add( "fred" ); // 1 @@ -99,7 +103,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testClear(){ - List list; + StlList list; list.add( "bob" ); list.add( "fred" ); @@ -111,7 +115,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testIsEmpty(){ - List list; + StlList list; list.add( "bob" ); list.add( "fred" ); @@ -123,7 +127,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testSize(){ - List list; + StlList list; CPPUNIT_ASSERT( list.size() == 0 ); list.add( "bob" ); @@ -134,7 +138,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testGet(){ - List list; + StlList list; list.add( "fred" ); list.add( "fred" ); @@ -151,7 +155,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testSet(){ - List list; + StlList list; list.add( "fred" ); list.add( "fred" ); @@ -174,7 +178,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testAdd(){ - List list; + StlList list; list.add( "fred" ); list.add( "fred" ); @@ -188,7 +192,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testAdd2(){ - List list; + StlList list; list.add( "fred" ); list.add( "fred" ); @@ -223,7 +227,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testRemove(){ - List list; + StlList list; list.add( "fred" ); CPPUNIT_ASSERT( list.contains( "fred" ) == true ); @@ -233,7 +237,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testRemove2(){ - List list; + StlList list; list.add( "fred" ); list.add( "bob" ); @@ -256,7 +260,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testToArray(){ - List list; + StlList list; list.add( "fred1" ); list.add( "fred2" ); @@ -271,7 +275,7 @@ //////////////////////////////////////////////////////////////////////////////// void ListTest::testIterator(){ - List list; + StlList list; list.add( "fred1" ); list.add( "fred2" ); Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.h (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/ListTest.h Thu Feb 12 23:19:54 2009 @@ -21,9 +21,6 @@ #include #include -#include -#include - namespace decaf{ namespace util{ Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/MapTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/MapTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/MapTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/MapTest.cpp Thu Feb 12 23:19:54 2009 @@ -17,7 +17,7 @@ #include "MapTest.h" #include -#include +#include using namespace std; using namespace decaf; @@ -34,7 +34,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testContainsKey(){ - STLMap boolMap; + StlMap boolMap; CPPUNIT_ASSERT(boolMap.containsKey("bob") == false); boolMap.put( "bob", true ); @@ -46,7 +46,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testClear(){ - STLMap boolMap; + StlMap boolMap; boolMap.put( "bob", true ); boolMap.put( "fred", true ); @@ -58,7 +58,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testIsEmpty(){ - STLMap boolMap; + StlMap boolMap; boolMap.put( "bob", true ); boolMap.put( "fred", true ); @@ -70,7 +70,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testSize(){ - STLMap boolMap; + StlMap boolMap; CPPUNIT_ASSERT(boolMap.size() == 0 ); boolMap.put( "bob", true ); @@ -82,7 +82,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testValue(){ - STLMap boolMap; + StlMap boolMap; boolMap.put( "fred", true ); CPPUNIT_ASSERT( boolMap.get("fred") == true ); @@ -100,7 +100,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testRemove(){ - STLMap boolMap; + StlMap boolMap; boolMap.put( "fred", true ); CPPUNIT_ASSERT( boolMap.containsKey("fred") == true ); @@ -110,7 +110,7 @@ //////////////////////////////////////////////////////////////////////////////// void MapTest::testContiansValue(){ - STLMap boolMap; + StlMap boolMap; boolMap.put( "fred", true ); boolMap.put( "fred1", false ); Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.cpp Thu Feb 12 23:19:54 2009 @@ -17,6 +17,8 @@ #include "QueueTest.h" +#include + using namespace std; using namespace decaf; using namespace decaf::util; @@ -24,7 +26,7 @@ //////////////////////////////////////////////////////////////////////////////// void QueueTest::test() { - Queue q; + StlQueue q; CPPUNIT_ASSERT( q.empty() == true ); CPPUNIT_ASSERT( q.size() == 0 ); Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.h (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/QueueTest.h Thu Feb 12 23:19:54 2009 @@ -21,8 +21,6 @@ #include #include -#include - namespace decaf{ namespace util{ Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.cpp?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.cpp Thu Feb 12 23:19:54 2009 @@ -17,6 +17,9 @@ #include "SetTest.h" +#include +#include + using namespace std; using namespace decaf; using namespace decaf::util; @@ -28,7 +31,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testContains(){ - Set set; + StlSet set; CPPUNIT_ASSERT( set.contains( "bob" ) == false); set.add( "bob" ); @@ -40,7 +43,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testClear(){ - Set set; + StlSet set; set.add( "bob" ); set.add( "fred" ); @@ -52,7 +55,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testIsEmpty(){ - Set set; + StlSet set; set.add( "bob" ); set.add( "fred" ); @@ -64,7 +67,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testSize(){ - Set set; + StlSet set; CPPUNIT_ASSERT( set.size() == 0 ); set.add( "bob" ); @@ -75,7 +78,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testAdd(){ - Set set; + StlSet set; set.add( "fred" ); set.add( "fred" ); @@ -89,7 +92,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testRemove(){ - Set set; + StlSet set; set.add( "fred" ); CPPUNIT_ASSERT( set.contains( "fred" ) == true ); @@ -100,7 +103,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testToArray(){ - Set set; + StlSet set; set.add( "fred1" ); set.add( "fred2" ); @@ -115,7 +118,7 @@ //////////////////////////////////////////////////////////////////////////////// void SetTest::testIterator(){ - Set set; + StlSet set; set.add( "fred1" ); set.add( "fred2" ); Modified: activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.h?rev=743923&r1=743922&r2=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.h (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/SetTest.h Thu Feb 12 23:19:54 2009 @@ -21,9 +21,6 @@ #include #include -#include -#include - namespace decaf{ namespace util{ Copied: activemq/activemq-cpp/trunk/src/test/decaf/util/StlMapTest.cpp (from r743068, activemq/activemq-cpp/trunk/src/test/decaf/util/STLMapTest.cpp) URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/decaf/util/StlMapTest.cpp?p2=activemq/activemq-cpp/trunk/src/test/decaf/util/StlMapTest.cpp&p1=activemq/activemq-cpp/trunk/src/test/decaf/util/STLMapTest.cpp&r1=743068&r2=743923&rev=743923&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/decaf/util/STLMapTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/decaf/util/StlMapTest.cpp Thu Feb 12 23:19:54 2009 @@ -15,10 +15,10 @@ * limitations under the License. */ -#include "STLMapTest.h" +#include "StlMapTest.h" #include -#include +#include using namespace std; using namespace decaf; @@ -110,7 +110,7 @@ valueMap[key] = value; } - virtual void putAll( const STLMap& other DECAF_UNUSED ) { + virtual void putAll( const StlMap& other DECAF_UNUSED ) { // TODO } virtual void putAll( const Map& other DECAF_UNUSED ) { @@ -162,9 +162,9 @@ }; //////////////////////////////////////////////////////////////////////////////// -void STLMapTest::testConstructor() { +void StlMapTest::testConstructor() { - STLMap map1; + StlMap map1; CPPUNIT_ASSERT( map1.isEmpty() ); CPPUNIT_ASSERT( map1.size() == 0 ); @@ -173,7 +173,7 @@ map1.get( "TEST" ), decaf::lang::exceptions::NoSuchElementException ); - STLMap destMap; + StlMap destMap; STLTestMap srcMap; srcMap.put( "A", 1 );