You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2007/01/21 14:18:46 UTC
svn commit: r498308 - in
/incubator/activemq/activemq-cpp/trunk/activemq-cpp: ./ src/main/
src/main/activemq/concurrent/ src/main/activemq/connector/stomp/
src/main/activemq/connector/stomp/commands/ src/main/activemq/util/
Author: nmittler
Date: Sun Jan 21 05:18:45 2007
New Revision: 498308
URL: http://svn.apache.org/viewvc?view=rev&rev=498308
Log:
[AMQCPP-49] Reducing number of includes of Config.h from headers
Added:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.cpp
Modified:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.h
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac Sun Jan 21 05:18:45 2007
@@ -86,8 +86,7 @@
AM_CONDITIONAL(BUILD_CPPUNIT_TESTS, test x$cppunit = xyes)
# Define globals for all platforms
-CXXFLAGS="$CXXFLAGS -fstrict-aliasing -Wstrict-aliasing=2 -W -Wall"
-#-Wno-unused-parameter
+CXXFLAGS="$CXXFLAGS -fstrict-aliasing -Wstrict-aliasing=2 -W -Wall -ansi -pedantic -D HAVE_ACTIVEMQ_CONFIG"
LIBS="$LIBS"
@@ -171,6 +170,7 @@
if test x$cppunit = xyes
then
+ CXXFLAGS="-D HAVE_ACTIVEMQ_CONFIG"
AC_CONFIG_FILES(src/test/Makefile)
AC_CONFIG_FILES(src/test-integration/Makefile)
fi
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Sun Jan 21 05:18:45 2007
@@ -48,6 +48,7 @@
activemq/connector/stomp/StompConnectorFactory.cpp \
activemq/connector/stomp/marshal/Marshaler.cpp \
activemq/connector/stomp/StompConnector.cpp \
+ activemq/connector/stomp/StompSelector.cpp \
activemq/connector/openwire/OpenWireFormat.cpp \
activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp \
activemq/connector/openwire/utils/HexTable.cpp \
@@ -70,6 +71,7 @@
activemq/transport/TransportFilter.cpp \
activemq/util/StringTokenizer.cpp \
activemq/util/Guid.cpp \
+ activemq/util/Endian.cpp \
activemq/util/Date.cpp \
activemq/util/Math.cpp \
activemq/util/PrimitiveMap.cpp
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.cpp?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.cpp Sun Jan 21 05:18:45 2007
@@ -14,8 +14,248 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include <activemq/concurrent/Mutex.h>
using namespace activemq::concurrent;
////////////////////////////////////////////////////////////////////////////////
+Mutex::Mutex()
+{
+#ifdef AMQCPP_USE_PTHREADS
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutex_init(&mutex, &attr);
+ pthread_mutexattr_destroy(&attr);
+#else
+ InitializeCriticalSection(&mutex);
+#endif
+
+ lock_owner = 0;
+ lock_count = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Mutex::~Mutex()
+{
+ // Unlock the mutex.
+ unlock();
+
+#ifdef AMQCPP_USE_PTHREADS
+ pthread_mutex_destroy(&mutex);
+#else
+ DeleteCriticalSection(&mutex);
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::lock() throw( exceptions::ActiveMQException )
+{
+ if(isLockOwner())
+ {
+ lock_count++;
+ }
+ else
+ {
+#ifdef AMQCPP_USE_PTHREADS
+ pthread_mutex_lock(&mutex);
+#else
+ EnterCriticalSection(&mutex);
+#endif
+
+ lock_count = 1;
+ lock_owner = Thread::getId();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::unlock() throw( exceptions::ActiveMQException )
+{
+ if(lock_owner == 0)
+ {
+ return;
+ }
+
+ if(!isLockOwner())
+ {
+ throw exceptions::ActiveMQException(
+ __FILE__, __LINE__,
+ "Mutex::unlock - Failed, not Lock Owner!" );
+ }
+
+ lock_count--;
+
+ if(lock_count == 0)
+ {
+ lock_owner = 0;
+
+ #ifdef AMQCPP_USE_PTHREADS
+ pthread_mutex_unlock(&mutex);
+ #else
+ LeaveCriticalSection(&mutex);
+ #endif
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::wait() throw( exceptions::ActiveMQException )
+{
+ // Delegate to the timed version
+ wait( WAIT_INFINITE );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::wait( unsigned long millisecs )
+ throw( exceptions::ActiveMQException )
+{
+ if(!isLockOwner())
+ {
+ throw exceptions::ActiveMQException(
+ __FILE__, __LINE__,
+ "Mutex::wait - Failed, not Lock Owner!");
+ }
+
+ // Save the current owner and Lock count as we are going to
+ // unlock and release for someone else to lock on potentially.
+ // When we come back and re-lock we want to restore to the
+ // state we were in before.
+ unsigned long lock_owner = this->lock_owner;
+ int lock_count = this->lock_count;
+
+ this->lock_count = 0;
+ this->lock_owner = 0;
+
+ #ifdef AMQCPP_USE_PTHREADS
+
+ // Create this threads wait event
+ pthread_cond_t waitEvent;
+ pthread_cond_init(&waitEvent, NULL);
+
+ // Store the event in the queue so that a notify can
+ // call it and wake up the thread.
+ eventQ.push_back(&waitEvent);
+
+ int returnValue = 0;
+ if(millisecs != WAIT_INFINITE)
+ {
+ timeval now = {0,0};
+ gettimeofday(&now, NULL);
+
+ timespec wait = {0,0};
+ wait.tv_sec = now.tv_sec + (millisecs / 1000);
+ wait.tv_nsec = (now.tv_usec * 1000) + ((millisecs % 1000) * 1000000);
+
+ if(wait.tv_nsec > 1000000000)
+ {
+ wait.tv_sec++;
+ wait.tv_nsec -= 1000000000;
+ }
+
+ returnValue = pthread_cond_timedwait(&waitEvent, &mutex, &wait);
+ }
+ else
+ {
+ returnValue = pthread_cond_wait(&waitEvent, &mutex);
+ }
+
+ // If the wait did not succeed for any reason, remove it
+ // from the queue.
+ if( returnValue != 0 ){
+ std::list<pthread_cond_t*>::iterator iter = eventQ.begin();
+ for( ; iter != eventQ.end(); ++iter ){
+ if( *iter == &waitEvent ){
+ eventQ.erase(iter);
+ break;
+ }
+ }
+ }
+
+ // Destroy our wait event now, the notify method will have removed it
+ // from the event queue.
+ pthread_cond_destroy(&waitEvent);
+
+ #else
+
+ // Create the event to wait on
+ HANDLE waitEvent = CreateEvent( NULL, false, false, NULL );
+
+ if(waitEvent == NULL)
+ {
+ throw exceptions::ActiveMQException(
+ __FILE__, __LINE__,
+ "Mutex::Mutex - Failed Creating Event." );
+ }
+
+ eventQ.push_back( waitEvent );
+
+ // Release the Lock
+ LeaveCriticalSection( &mutex );
+
+ // Wait for a signal
+ WaitForSingleObject( waitEvent, millisecs );
+
+ // Reaquire the Lock
+ EnterCriticalSection( &mutex );
+
+ // Clean up the event, the notif methods will have
+ // already poped it from the queue.
+ CloseHandle( waitEvent );
+
+ #endif
+
+ // restore the owner
+ this->lock_owner = lock_owner;
+ this->lock_count = lock_count;
+ }
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::notify() throw( exceptions::ActiveMQException )
+{
+ if( !isLockOwner() )
+ {
+ throw exceptions::ActiveMQException(
+ __FILE__, __LINE__,
+ "Mutex::Notify - Failed, not Lock Owner!" );
+ }
+
+ if( !eventQ.empty() )
+ {
+ #ifdef AMQCPP_USE_PTHREADS
+ pthread_cond_signal( eventQ.front() );
+ eventQ.pop_front();
+ #else
+ SetEvent( eventQ.front() );
+ eventQ.pop_front();
+ #endif
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::notifyAll() throw( exceptions::ActiveMQException )
+{
+ if(!isLockOwner())
+ {
+ throw exceptions::ActiveMQException(
+ __FILE__, __LINE__,
+ "Mutex::NotifyAll - Failed, not Lock Owner!" );
+ }
+
+ #ifdef AMQCPP_USE_PTHREADS
+
+ while(!eventQ.empty())
+ {
+ pthread_cond_signal( eventQ.front() );
+ eventQ.pop_front();
+ }
+
+ #else
+
+ while(!eventQ.empty())
+ {
+ SetEvent( eventQ.front() );
+ eventQ.pop_front();
+ }
+
+ #endif
+}
+
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h Sun Jan 21 05:18:45 2007
@@ -82,101 +82,31 @@
/**
* Constructor - creates and initializes the mutex.
*/
- Mutex()
- {
- #ifdef AMQCPP_USE_PTHREADS
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutex_init(&mutex, &attr);
- pthread_mutexattr_destroy(&attr);
- #else
- InitializeCriticalSection(&mutex);
- #endif
-
- lock_owner = 0;
- lock_count = 0;
- }
+ Mutex();
/**
* Destructor - destroys the mutex object.
*/
- virtual ~Mutex()
- {
- // Unlock the mutex.
- unlock();
-
- #ifdef AMQCPP_USE_PTHREADS
- pthread_mutex_destroy(&mutex);
- #else
- DeleteCriticalSection(&mutex);
- #endif
- }
+ virtual ~Mutex();
/**
* Locks the object.
* @throws ActiveMQException
*/
- virtual void lock() throw( exceptions::ActiveMQException )
- {
- if(isLockOwner())
- {
- lock_count++;
- }
- else
- {
- #ifdef AMQCPP_USE_PTHREADS
- pthread_mutex_lock(&mutex);
- #else
- EnterCriticalSection(&mutex);
- #endif
-
- lock_count = 1;
- lock_owner = Thread::getId();
- }
- }
+ virtual void lock() throw( exceptions::ActiveMQException );
/**
* Unlocks the object.
* @throws ActiveMQException
*/
- virtual void unlock() throw( exceptions::ActiveMQException )
- {
- if(lock_owner == 0)
- {
- return;
- }
-
- if(!isLockOwner())
- {
- throw exceptions::ActiveMQException(
- __FILE__, __LINE__,
- "Mutex::unlock - Failed, not Lock Owner!" );
- }
-
- lock_count--;
-
- if(lock_count == 0)
- {
- lock_owner = 0;
-
- #ifdef AMQCPP_USE_PTHREADS
- pthread_mutex_unlock(&mutex);
- #else
- LeaveCriticalSection(&mutex);
- #endif
- }
- }
+ virtual void unlock() throw( exceptions::ActiveMQException );
/**
* Waits on a signal from this object, which is generated
* by a call to Notify.
* @throws ActiveMQException
*/
- virtual void wait() throw( exceptions::ActiveMQException )
- {
- // Delegate to the timed version
- wait( WAIT_INFINITE );
- }
+ virtual void wait() throw( exceptions::ActiveMQException );
/**
* Waits on a signal from this object, which is generated
@@ -187,166 +117,21 @@
* @throws ActiveMQException
*/
virtual void wait( unsigned long millisecs )
- throw( exceptions::ActiveMQException )
- {
- if(!isLockOwner())
- {
- throw exceptions::ActiveMQException(
- __FILE__, __LINE__,
- "Mutex::wait - Failed, not Lock Owner!");
- }
-
- // Save the current owner and Lock count as we are going to
- // unlock and release for someone else to lock on potentially.
- // When we come back and re-lock we want to restore to the
- // state we were in before.
- unsigned long lock_owner = this->lock_owner;
- int lock_count = this->lock_count;
-
- this->lock_count = 0;
- this->lock_owner = 0;
-
- #ifdef AMQCPP_USE_PTHREADS
-
- // Create this threads wait event
- pthread_cond_t waitEvent;
- pthread_cond_init(&waitEvent, NULL);
-
- // Store the event in the queue so that a notify can
- // call it and wake up the thread.
- eventQ.push_back(&waitEvent);
-
- int returnValue = 0;
- if(millisecs != WAIT_INFINITE)
- {
- timeval now = {0,0};
- gettimeofday(&now, NULL);
-
- timespec wait = {0,0};
- wait.tv_sec = now.tv_sec + (millisecs / 1000);
- wait.tv_nsec = (now.tv_usec * 1000) + ((millisecs % 1000) * 1000000);
-
- if(wait.tv_nsec > 1000000000)
- {
- wait.tv_sec++;
- wait.tv_nsec -= 1000000000;
- }
-
- returnValue = pthread_cond_timedwait(&waitEvent, &mutex, &wait);
- }
- else
- {
- returnValue = pthread_cond_wait(&waitEvent, &mutex);
- }
-
- // If the wait did not succeed for any reason, remove it
- // from the queue.
- if( returnValue != 0 ){
- std::list<pthread_cond_t*>::iterator iter = eventQ.begin();
- for( ; iter != eventQ.end(); ++iter ){
- if( *iter == &waitEvent ){
- eventQ.erase(iter);
- break;
- }
- }
- }
-
- // Destroy our wait event now, the notify method will have removed it
- // from the event queue.
- pthread_cond_destroy(&waitEvent);
-
- #else
-
- // Create the event to wait on
- HANDLE waitEvent = CreateEvent( NULL, false, false, NULL );
-
- if(waitEvent == NULL)
- {
- throw exceptions::ActiveMQException(
- __FILE__, __LINE__,
- "Mutex::Mutex - Failed Creating Event." );
- }
-
- eventQ.push_back( waitEvent );
-
- // Release the Lock
- LeaveCriticalSection( &mutex );
-
- // Wait for a signal
- WaitForSingleObject( waitEvent, millisecs );
-
- // Reaquire the Lock
- EnterCriticalSection( &mutex );
-
- // Clean up the event, the notif methods will have
- // already poped it from the queue.
- CloseHandle( waitEvent );
-
- #endif
-
- // restore the owner
- this->lock_owner = lock_owner;
- this->lock_count = lock_count;
- }
+ throw( exceptions::ActiveMQException );
/**
* Signals a waiter on this object that it can now wake
* up and continue.
* @throws ActiveMQException
*/
- virtual void notify() throw( exceptions::ActiveMQException )
- {
- if( !isLockOwner() )
- {
- throw exceptions::ActiveMQException(
- __FILE__, __LINE__,
- "Mutex::Notify - Failed, not Lock Owner!" );
- }
-
- if( !eventQ.empty() )
- {
- #ifdef AMQCPP_USE_PTHREADS
- pthread_cond_signal( eventQ.front() );
- eventQ.pop_front();
- #else
- SetEvent( eventQ.front() );
- eventQ.pop_front();
- #endif
- }
- }
+ virtual void notify() throw( exceptions::ActiveMQException );
/**
* Signals the waiters on this object that it can now wake
* up and continue.
* @throws ActiveMQException
*/
- virtual void notifyAll() throw( exceptions::ActiveMQException )
- {
- if(!isLockOwner())
- {
- throw exceptions::ActiveMQException(
- __FILE__, __LINE__,
- "Mutex::NotifyAll - Failed, not Lock Owner!" );
- }
-
- #ifdef AMQCPP_USE_PTHREADS
-
- while(!eventQ.empty())
- {
- pthread_cond_signal( eventQ.front() );
- eventQ.pop_front();
- }
-
- #else
-
- while(!eventQ.empty())
- {
- SetEvent( eventQ.front() );
- eventQ.pop_front();
- }
-
- #endif
- }
+ virtual void notifyAll() throw( exceptions::ActiveMQException );
private:
Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.cpp?view=auto&rev=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.cpp Sun Jan 21 05:18:45 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 "StompSelector.h"
+#include <activemq/util/Config.h>
+
+using namespace activemq::connector::stomp;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+bool StompSelector::isSelected( const string& selector ACTIVEMQ_ATTRIBUTE_UNUSED,
+ cms::Message* msg ACTIVEMQ_ATTRIBUTE_UNUSED)
+{
+ return true;
+}
+
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.h?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSelector.h Sun Jan 21 05:18:45 2007
@@ -20,7 +20,6 @@
#include <cms/Message.h>
#include <string>
-#include <activemq/util/Config.h>
namespace activemq{
namespace connector{
@@ -36,11 +35,7 @@
class StompSelector{
public:
- static bool isSelected( const std::string& selector ACTIVEMQ_ATTRIBUTE_UNUSED,
- cms::Message* msg ACTIVEMQ_ATTRIBUTE_UNUSED)
- {
- return true;
- }
+ static bool isSelected( const std::string& selector, cms::Message* msg );
};
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp Sun Jan 21 05:18:45 2007
@@ -26,6 +26,7 @@
#include <activemq/connector/stomp/commands/UnsubscribeCommand.h>
#include <activemq/connector/stomp/StompSelector.h>
#include <activemq/util/Properties.h>
+#include <activemq/util/Config.h>
using namespace std;
using namespace activemq;
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h Sun Jan 21 05:18:45 2007
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef ACTIVEMQ_CONNECTOR_STOMP_COMMANDS_ABSTRACTCOMMAND_H_
#define ACTIVEMQ_CONNECTOR_STOMP_COMMANDS_ABSTRACTCOMMAND_H_
@@ -37,7 +38,6 @@
* Commands help to abstract the stomp frame by providing a
* more user-friendly interface to the frame content.
*/
-
template<typename T>
class AbstractCommand
:
@@ -51,7 +51,7 @@
protected:
- StompFrame& getFrame(void) {
+ StompFrame& getFrame() {
if( frame == NULL ){
throw exceptions::NullPointerException(
__FILE__, __LINE__,
@@ -61,7 +61,7 @@
return *frame;
}
- const StompFrame& getFrame(void) const {
+ const StompFrame& getFrame() const {
if( frame == NULL ){
throw exceptions::NullPointerException(
__FILE__, __LINE__,
@@ -71,7 +71,7 @@
return *frame;
}
- void destroyFrame(void)
+ void destroyFrame()
{
if( frame != NULL ){
delete frame;
@@ -111,13 +111,13 @@
public:
- AbstractCommand(void){
+ AbstractCommand(){
frame = new StompFrame;
}
AbstractCommand( StompFrame* frame ){
this->frame = frame;
}
- virtual ~AbstractCommand(void){
+ virtual ~AbstractCommand(){
destroyFrame();
}
@@ -125,10 +125,10 @@
* Gets the properties map for this command.
* @return Reference to a Properties object
*/
- virtual util::Properties& getProperties(void){
+ virtual util::Properties& getProperties(){
return getFrame().getProperties();
}
- virtual const util::Properties& getProperties(void) const{
+ virtual const util::Properties& getProperties() const{
return getFrame().getProperties();
}
@@ -147,7 +147,7 @@
* Gets the Command Id of this Message
* @return Command Id
*/
- virtual unsigned int getCommandId(void) const {
+ virtual unsigned int getCommandId() const {
return util::Integer::parseInt(
getPropertyValue(
CommandConstants::toString(
@@ -166,7 +166,7 @@
* Is a Response required for this Command
* @return true if a response is required.
*/
- virtual bool isResponseRequired(void) const {
+ virtual bool isResponseRequired() const {
return frame->getProperties().hasProperty(
CommandConstants::toString(
CommandConstants::HEADER_REQUESTID) );
@@ -176,7 +176,7 @@
* Gets the Correlation Id that is associated with this message
* @return the Correlation Id
*/
- virtual unsigned int getCorrelationId(void) const {
+ virtual unsigned int getCorrelationId() const {
return util::Integer::parseInt(
getPropertyValue(
CommandConstants::toString(
@@ -199,7 +199,7 @@
* Get the Transaction Id of this Command
* @return the Id of the Transaction
*/
- virtual std::string getTransactionId(void) const{
+ virtual std::string getTransactionId() const{
return getPropertyValue(
CommandConstants::toString(
CommandConstants::HEADER_TRANSACTIONID ), "" );
@@ -220,7 +220,7 @@
* Retrieve the Stomp Command Id for this message.
* @return Stomp CommandId enum
*/
- virtual CommandConstants::CommandId getStompCommandId(void) const {
+ virtual CommandConstants::CommandId getStompCommandId() const {
return CommandConstants::toCommandId(
getFrame().getCommand() );
}
@@ -232,7 +232,7 @@
* @throws MarshalException if the command is not
* in a state that can be marshaled.
*/
- virtual const StompFrame& marshal(void)
+ virtual const StompFrame& marshal()
throw (marshal::MarshalException)
{
if( frame == NULL || !validate( *frame ) ){
@@ -250,7 +250,7 @@
* Fetch the number of bytes in the Stomp Frame Body
* @return number of bytes
*/
- virtual unsigned long long getNumBytes(void) const{
+ virtual unsigned long long getNumBytes() const{
return getFrame().getBodyLength();
}
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Config.h Sun Jan 21 05:18:45 2007
@@ -22,33 +22,32 @@
// of the platform when the ./configure script is not being used to generate
// the config.h file.
//
-#if defined(HAVE_CONFIG_H)
+#if defined(HAVE_ACTIVEMQ_CONFIG)
// config.h is generated by the ./configure script and it only
// used by unix like systems (including cygwin)
#include <config.h>
-#else /* !defined(HAVE_CONFIG_H) */
+#else /* !defined(HAVE_ACTIVEMQ_CONFIG) */
// Not using ./configure script and make system.. chances are your using the native build tools
// of Windows or OS X to do this build
- #if defined(__APPLE__)
- #define HAVE_UUID_UUID_H
- #elif defined(_WIN32) || defined( __CYGWIN__ )
+
+ #if defined(_WIN32) || defined( __CYGWIN__ )
#define HAVE_OBJBASE_H
#define HAVE_RPCDCE_H
#define HAVE_WINSOCK2_H
#define HAVE_STRUCT_ADDRINFO
#define HAVE_SYS_TIMEB_H
#define HAVE_FTIME
- #elif defined( unix )
+ #elif defined(unix) || defined(__unix__) || defined(__APPLE__)
#define HAVE_UUID_UUID_H
#else
#error "Unknown Platform"
#endif
-#endif /* !defined(HAVE_CONFIG_H) */
+#endif /* !defined(HAVE_ACTIVEMQ_CONFIG) */
// Macro to mark attributes as unused
#ifdef __GNUC__
Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.cpp?view=auto&rev=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.cpp Sun Jan 21 05:18:45 2007
@@ -0,0 +1,116 @@
+/*
+ * 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 "Endian.h"
+#include <activemq/util/Config.h>
+#include <string.h>
+
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+void Endian::byteSwap(unsigned char* data, int dataLength) {
+
+ #ifdef WORDS_BIGENDIAN
+ return;
+ #endif
+
+ for (int i = 0; i<dataLength/2; i++) {
+ unsigned char temp = data[i];
+ data[i] = data[dataLength-1-i];
+ data[dataLength-1-i] = temp;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char Endian::byteSwap( unsigned char value ){
+
+ #ifdef WORDS_BIGENDIAN
+ return value;
+ #endif
+
+ return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned short Endian::byteSwap( unsigned short value ){
+
+ #ifdef WORDS_BIGENDIAN
+ return value;
+ #endif
+
+ return (((unsigned short)value & 0xFF00 ) >> 8 ) |
+ (((unsigned short)value & 0x00FF ) << 8 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned int Endian::byteSwap( unsigned int value ){
+
+ #ifdef WORDS_BIGENDIAN
+ return value;
+ #endif
+
+ return (((unsigned int)value & 0xFF000000 ) >> 24 ) |
+ (((unsigned int)value & 0x00FF0000 ) >> 8 ) |
+ (((unsigned int)value & 0x0000FF00 ) << 8 ) |
+ (((unsigned int)value & 0x000000FF ) << 24 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned long long Endian::byteSwap( unsigned long long value ){
+
+ #ifdef WORDS_BIGENDIAN
+ return value;
+ #endif
+
+ return (((unsigned long long)value & 0xFF00000000000000ULL ) >> 56 ) |
+ (((unsigned long long)value & 0x00FF000000000000ULL ) >> 40 ) |
+ (((unsigned long long)value & 0x0000FF0000000000ULL ) >> 24 ) |
+ (((unsigned long long)value & 0x000000FF00000000ULL ) >> 8 ) |
+ (((unsigned long long)value & 0x00000000FF000000ULL ) << 8 ) |
+ (((unsigned long long)value & 0x0000000000FF0000ULL ) << 24 ) |
+ (((unsigned long long)value & 0x000000000000FF00ULL ) << 40 ) |
+ (((unsigned long long)value & 0x00000000000000FFULL ) << 56 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float Endian::byteSwap( float value ){
+
+ #ifdef WORDS_BIGENDIAN
+ return value;
+ #endif
+
+ unsigned int lvalue = 0;
+ memcpy( &lvalue, &value, sizeof( float ) );
+ lvalue = byteSwap( lvalue );
+ memcpy( &value, &lvalue, sizeof( unsigned int ) );
+ return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Endian::byteSwap( double value ){
+
+ #ifdef WORDS_BIGENDIAN
+ return value;
+ #endif
+
+ unsigned long long lvalue = 0;
+ memcpy( &lvalue, &value, sizeof( double ) );
+ lvalue = byteSwap( lvalue );
+ memcpy( &value, &lvalue, sizeof( unsigned long long ) );
+ return value;
+}
+
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.h?view=diff&rev=498308&r1=498307&r2=498308
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Endian.h Sun Jan 21 05:18:45 2007
@@ -17,99 +17,25 @@
#ifndef ACTIVEMQ_UTIL_ENDIAN_H
#define ACTIVEMQ_UTIL_ENDIAN_H
-#include <activemq/util/Config.h>
-
namespace activemq{
namespace util{
class Endian{
public:
- static void byteSwap(unsigned char* data, int dataLength) {
-
- #ifdef WORDS_BIGENDIAN
- return;
- #endif
-
- for (int i = 0; i<dataLength/2; i++) {
- unsigned char temp = data[i];
- data[i] = data[dataLength-1-i];
- data[dataLength-1-i] = temp;
- }
- }
+ static void byteSwap(unsigned char* data, int dataLength);
- static unsigned char byteSwap( unsigned char value ){
-
- #ifdef WORDS_BIGENDIAN
- return value;
- #endif
-
- return value;
- }
+ static unsigned char byteSwap( unsigned char value );
- static unsigned short byteSwap( unsigned short value ){
-
- #ifdef WORDS_BIGENDIAN
- return value;
- #endif
-
- return (((unsigned short)value & 0xFF00 ) >> 8 ) |
- (((unsigned short)value & 0x00FF ) << 8 );
- }
+ static unsigned short byteSwap( unsigned short value );
- static unsigned int byteSwap( unsigned int value ){
-
- #ifdef WORDS_BIGENDIAN
- return value;
- #endif
-
- return (((unsigned int)value & 0xFF000000 ) >> 24 ) |
- (((unsigned int)value & 0x00FF0000 ) >> 8 ) |
- (((unsigned int)value & 0x0000FF00 ) << 8 ) |
- (((unsigned int)value & 0x000000FF ) << 24 );
- }
+ static unsigned int byteSwap( unsigned int value );
- static unsigned long long byteSwap( unsigned long long value ){
+ static unsigned long long byteSwap( unsigned long long value );
- #ifdef WORDS_BIGENDIAN
- return value;
- #endif
-
- return (((unsigned long long)value & 0xFF00000000000000ULL ) >> 56 ) |
- (((unsigned long long)value & 0x00FF000000000000ULL ) >> 40 ) |
- (((unsigned long long)value & 0x0000FF0000000000ULL ) >> 24 ) |
- (((unsigned long long)value & 0x000000FF00000000ULL ) >> 8 ) |
- (((unsigned long long)value & 0x00000000FF000000ULL ) << 8 ) |
- (((unsigned long long)value & 0x0000000000FF0000ULL ) << 24 ) |
- (((unsigned long long)value & 0x000000000000FF00ULL ) << 40 ) |
- (((unsigned long long)value & 0x00000000000000FFULL ) << 56 );
- }
-
- static float byteSwap( float value ){
-
- #ifdef WORDS_BIGENDIAN
- return value;
- #endif
-
- unsigned int lvalue = 0;
- memcpy( &lvalue, &value, sizeof( float ) );
- lvalue = byteSwap( lvalue );
- memcpy( &value, &lvalue, sizeof( unsigned int ) );
- return value;
- }
+ static float byteSwap( float value );
- static double byteSwap( double value ){
-
- #ifdef WORDS_BIGENDIAN
- return value;
- #endif
-
- unsigned long long lvalue = 0;
- memcpy( &lvalue, &value, sizeof( double ) );
- lvalue = byteSwap( lvalue );
- memcpy( &value, &lvalue, sizeof( unsigned long long ) );
- return value;
- }
+ static double byteSwap( double value );
};
}}