You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/05/19 20:13:53 UTC
svn commit: r776399 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main:
Makefile.am decaf/util/Properties.cpp decaf/util/Properties.h
decaf/util/Random.h
Author: tabish
Date: Tue May 19 18:13:53 2009
New Revision: 776399
URL: http://svn.apache.org/viewvc?rev=776399&view=rev
Log:
Code cleanup and some initial refactoring to make the future work needed a bit easier.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.cpp (with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=776399&r1=776398&r2=776399&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Tue May 19 18:13:53 2009
@@ -28,6 +28,7 @@
decaf/lang/Long.cpp \
decaf/lang/Character.cpp \
decaf/lang/Thread.cpp \
+ decaf/util/Properties.cpp \
decaf/util/StringTokenizer.cpp \
decaf/util/Random.cpp \
decaf/util/concurrent/TimeUnit.cpp \
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.cpp?rev=776399&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.cpp Tue May 19 18:13:53 2009
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+#include "Properties.h"
+
+#include <decaf/util/Date.h>
+
+using namespace decaf;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+Properties::Properties() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Properties::~Properties() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Properties::isEmpty() const {
+ return properties.empty();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const char* Properties::getProperty( const std::string& name ) const{
+
+ std::map< std::string, std::string >::const_iterator iter =
+ properties.find( name );
+ if( iter == properties.end() ){
+ return NULL;
+ }
+
+ return iter->second.c_str();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Properties::getProperty( const std::string& name,
+ const std::string& defaultValue ) const {
+
+ std::map< std::string, std::string >::const_iterator iter =
+ properties.find( name );
+ if( iter == properties.end() ){
+ return defaultValue;
+ }
+
+ return iter->second;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Properties::setProperty( const std::string& name,
+ const std::string& value ){
+ properties[name] = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Properties::hasProperty( const std::string& name ) const {
+
+ if( properties.find(name) != properties.end() ) {
+ return true;
+ }
+
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Properties::remove( const std::string& name ){
+ properties.erase( name );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector< std::pair< std::string, std::string > > Properties::toArray() const{
+
+ // Create a vector big enough to hold all the elements in the map.
+ std::vector< std::pair<std::string, std::string> > vec(
+ properties.begin(), properties.end() );
+
+ return vec;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Properties::copy( const Properties* source ){
+
+ clear();
+ this->properties = source->properties;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Properties* Properties::clone() const{
+
+ Properties* props = new Properties();
+
+ props->properties = properties;
+
+ return props;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Properties::clear(){
+ properties.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Properties::toString() const {
+
+ std::ostringstream stream;
+ std::map< std::string, std::string >::const_iterator iter;
+
+ stream << "Begin Class decaf::util::Properties:" << std::endl;
+
+ for( iter = properties.begin(); iter != properties.end(); ++iter ){
+ stream << " properties[" << iter->first << "] = "
+ << iter->second << std::endl;
+ }
+
+ stream << "End Class decaf::util::Properties:" << std::endl;
+
+ return stream.str();
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.h?rev=776399&r1=776398&r2=776399&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Properties.h Tue May 19 18:13:53 2009
@@ -29,6 +29,8 @@
/**
* Java-like properties class for mapping string names to string values.
+ *
+ * @since 1.0
*/
class DECAF_API Properties{
private:
@@ -37,15 +39,15 @@
public:
- virtual ~Properties(){}
+ Properties();
+
+ virtual ~Properties();
/**
* Returns true if the properties object is empty
* @return true if empty
*/
- virtual bool isEmpty() const {
- return properties.empty();
- }
+ virtual bool isEmpty() const;
/**
* Looks up the value for the given property.
@@ -53,17 +55,7 @@
* @return the value of the property with the given name, if it
* exists. If it does not exist, returns NULL.
*/
- virtual const char* getProperty( const std::string& name ) const{
-
- std::map< std::string, std::string >::const_iterator iter =
- properties.find( name );
- if( iter == properties.end() ){
- return NULL;
- }
-
- return iter->second.c_str();
- }
-
+ virtual const char* getProperty( const std::string& name ) const;
/**
* Looks up the value for the given property.
* @param name the name of the property to be looked up.
@@ -73,16 +65,7 @@
* exists, otherwise the <code>defaultValue</code>.
*/
virtual std::string getProperty( const std::string& name,
- const std::string& defaultValue ) const {
-
- std::map< std::string, std::string >::const_iterator iter =
- properties.find( name );
- if( iter == properties.end() ){
- return defaultValue;
- }
-
- return iter->second;
- }
+ const std::string& defaultValue ) const;
/**
* Sets the value for a given property. If the property already
@@ -91,100 +74,51 @@
* @param value The value to be written.
*/
virtual void setProperty( const std::string& name,
- const std::string& value ){
- properties[name] = value;
- //properties.insert( std::make_pair( name, value ) );
- }
-
+ const std::string& value );
/**
* Check to see if the Property exists in the set
* @param name - property name to check for in this properties set.
* @return true if property exists, false otherwise.
*/
- virtual bool hasProperty( const std::string& name ) const
- {
- if(properties.find(name) != properties.end())
- {
- return true;
- }
-
- return false;
- }
+ virtual bool hasProperty( const std::string& name ) const;
/**
* Removes the property with the given name.
* @param name the name of the property to remove.
*/
- virtual void remove( const std::string& name ){
- properties.erase( name );
- }
+ virtual void remove( const std::string& name );
/**
* Method that serializes the contents of the property map to
- * an arryay.
+ * an array.
* @return list of pairs where the first is the name and the second
* is the value.
*/
- virtual std::vector< std::pair< std::string, std::string > > toArray() const{
-
- // Create a vector big enough to hold all the elements in the map.
- std::vector< std::pair<std::string, std::string> > vec(
- properties.begin(), properties.end() );
-
- return vec;
- }
+ virtual std::vector< std::pair< std::string, std::string > > toArray() const;
/**
* Copies the contents of the given properties object to this one.
* @param source The source properties object.
*/
- virtual void copy( const Properties* source ){
-
- clear();
- this->properties = source->properties;
- }
+ virtual void copy( const Properties* source );
/**
* Clones this object.
* @returns a replica of this object.
*/
- virtual Properties* clone() const{
-
- Properties* props = new Properties();
-
- props->properties = properties;
-
- return props;
- }
+ virtual Properties* clone() const;
/**
* Clears all properties from the map.
*/
- virtual void clear(){
- properties.clear();
- }
+ virtual void clear();
/**
* Formats the contents of the Properties Object into a string
* that can be logged, etc.
* @returns string value of this object.
*/
- virtual std::string toString() const {
-
- std::ostringstream stream;
- std::map< std::string, std::string >::const_iterator iter;
-
- stream << "Begin Class activemq::util::Properties:" << std::endl;
-
- for( iter = properties.begin(); iter != properties.end(); ++iter ){
- stream << " properties[" << iter->first << "] = "
- << iter->second << std::endl;
- }
-
- stream << "End Class activemq::util::Properties:" << std::endl;
-
- return stream.str();
- }
+ virtual std::string toString() const;
};
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h?rev=776399&r1=776398&r2=776399&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h Tue May 19 18:13:53 2009
@@ -26,8 +26,34 @@
namespace decaf{
namespace util{
- class DECAF_API Random
- {
+ /**
+ * Random Value Generator which is used to generate a stream of pseudorandom numbers.
+ * <p>
+ * The algorithms implemented by class Random use a protected utility method that
+ * on each invocation can supply up to 32 pseudorandomly generated bits.
+ *
+ * @since 1.0
+ */
+ class DECAF_API Random {
+ private:
+
+ static unsigned long long multiplier;
+
+ /**
+ * The boolean value indicating if the second Gaussian number is available.
+ */
+ bool haveNextNextGaussian;
+
+ /**
+ * It is associated with the internal state of this generator.
+ */
+ unsigned long long seed;
+
+ /**
+ * The second Gaussian generated number.
+ */
+ double nextNextGaussian;
+
public:
/**
@@ -172,26 +198,7 @@
* @see #nextGaussian
* @see #nextLong
*/
- int next( int bits );
-
- private:
-
- static unsigned long long multiplier;
-
- /**
- * The boolean value indicating if the second Gaussian number is available.
- */
- bool haveNextNextGaussian;
-
- /**
- * It is associated with the internal state of this generator.
- */
- unsigned long long seed;
-
- /**
- * The second Gaussian generated number.
- */
- double nextNextGaussian;
+ virtual int next( int bits );
};