You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2007/08/18 05:34:11 UTC
svn commit: r567221 - in /incubator/qpid/trunk/qpid/cpp/src:
qpid/client/Response.h qpid/framing/Blob.h qpid/framing/MethodHolder.cpp
qpid/framing/MethodHolder.h tests/quick_perftest
Author: aconway
Date: Fri Aug 17 20:34:09 2007
New Revision: 567221
URL: http://svn.apache.org/viewvc?view=rev&rev=567221
Log:
* src/qpid/framing/MethodHolder.h
* src/qpid/framing/Blob.h
- add empty() test
- get() returns 0 when empty
* src/qpid/client/Response.h: assert checks.
* src/tests/perftest.cpp: default to listen and publish.
Added:
incubator/qpid/trunk/qpid/cpp/src/tests/quick_perftest (with props)
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h?view=diff&rev=567221&r1=567220&r2=567221
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Response.h Fri Aug 17 20:34:09 2007
@@ -39,7 +39,8 @@
template <class T> T& as()
{
framing::AMQMethodBody* response(future->getResponse());
- return dynamic_cast<T&>(*response);
+ assert(response);
+ return *boost::polymorphic_downcast<T*>(response);
}
template <class T> bool isA()
{
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h?view=diff&rev=567221&r1=567220&r2=567221
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Blob.h Fri Aug 17 20:34:09 2007
@@ -97,6 +97,7 @@
void construct (const TypedInPlaceFactory& factory,
const boost::typed_in_place_factory_base* )
{
+ assert(empty());
typedef typename TypedInPlaceFactory::value_type T;
assert(sizeof(T) <= Size);
factory.apply(store.address());
@@ -104,6 +105,7 @@
}
void assign(const Blob& b) {
+ assert(empty());
b.copy(this->get(), b.get());
copy = b.copy;
destroy = b.destroy;
@@ -114,7 +116,13 @@
Blob() { setType<void>(); }
/** Copy a blob. */
- Blob(const Blob& b) { assign(b); }
+ Blob(const Blob& b) { setType<void>(); assign(b); }
+
+ /** @see construct() */
+ template<class Expr>
+ Blob( const Expr & expr ) { setType<void>(); construct(expr,&expr); }
+
+ ~Blob() { clear(); }
/** Assign a blob */
Blob& operator=(const Blob& b) {
@@ -123,12 +131,6 @@
return *this;
}
- /** @see construct() */
- template<class Expr>
- Blob( const Expr & expr ) { construct(expr,&expr); }
-
- ~Blob() { clear(); }
-
/** Construcct an object in the blob. Destroyes the previous object.
*@param expr an expresion of the form: in_place<T>(x,y,z)
* will construct an object using the constructor T(x,y,z)
@@ -144,7 +146,7 @@
void* get() { return store.address(); }
/** Get const pointer to blob contents */
- const void* get() const { return store.address(); }
+ const void* get() const { return empty() ? 0 : store.address(); }
/** Destroy the object in the blob making it empty. */
void clear() {
@@ -153,6 +155,8 @@
oldDestroy(store.address());
}
+ bool empty() const { return destroy == BlobHelper<void>::destroy; }
+
static size_t size() { return Size; }
};
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp?view=diff&rev=567221&r1=567220&r2=567221
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.cpp Fri Aug 17 20:34:09 2007
@@ -31,6 +31,14 @@
namespace qpid {
namespace framing {
+AMQMethodBody* MethodHolder::get() {
+ return static_cast<AMQMethodBody*>(blob.get());
+}
+
+const AMQMethodBody* MethodHolder::get() const {
+ return const_cast<MethodHolder*>(this)->get();
+}
+
void MethodHolder::encode(Buffer& b) const {
const AMQMethodBody* body = get();
b.putShort(body->amqpClassId());
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h?view=diff&rev=567221&r1=567220&r2=567221
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/MethodHolder.h Fri Aug 17 20:34:09 2007
@@ -75,13 +75,13 @@
void encode(Buffer&) const;
void decode(Buffer&);
uint32_t size() const;
-
- AMQMethodBody* get() {
- return reinterpret_cast<AMQMethodBody*>(blob.get());
- }
- const AMQMethodBody* get() const {
- return reinterpret_cast<const AMQMethodBody*>(blob.get());
- }
+
+ /** Return method pointer or 0 if empty. */
+ AMQMethodBody* get();
+ const AMQMethodBody* get() const;
+
+ /** True if no method has been set */
+ bool empty() const { return blob.empty(); }
private:
Blob<MAX_METHODBODY_SIZE> blob;
Added: incubator/qpid/trunk/qpid/cpp/src/tests/quick_perftest
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/quick_perftest?view=auto&rev=567221
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/quick_perftest (added)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/quick_perftest Fri Aug 17 20:34:09 2007
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec `dirname $0`/test_env ./perftest --listen --publish --count 1000
Propchange: incubator/qpid/trunk/qpid/cpp/src/tests/quick_perftest
------------------------------------------------------------------------------
svn:executable = *