summaryrefslogtreecommitdiff
path: root/cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2012-06-21 12:09:00 +0000
committerKim van der Riet <kpvdr@apache.org>2012-06-21 12:09:00 +0000
commitb95f9427ede4a2045ac6424a6341de9185a13602 (patch)
treeef1950c1d03961fe9a08a2bfdb84355c139d57e4 /cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp
parent5083cef28cd7d1f594a7632ffec109567f5a3b2b (diff)
downloadqpid-python-b95f9427ede4a2045ac6424a6341de9185a13602.tar.gz
QPID-3858: WIP: New classes for transactional consumption of messages
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1352509 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp')
-rw-r--r--cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp b/cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp
new file mode 100644
index 0000000000..29db6ceaf2
--- /dev/null
+++ b/cpp/src/tests/storePerftools/asyncPerf/SimpleMessage.cpp
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+/**
+ * \file SimpleMessage.cpp
+ */
+
+#include "SimpleMessage.h"
+
+#include "qpid/asyncStore/AsyncStoreImpl.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+SimpleMessage::SimpleMessage(const char* msgData,
+ const uint32_t msgSize,
+ qpid::asyncStore::AsyncStoreImpl* store) :
+ m_persistenceId(0ULL),
+ m_msg(msgData, static_cast<size_t>(msgSize)),
+ m_msgHandle(store ? store->createMessageHandle(this) : qpid::broker::MessageHandle(0))
+{}
+
+SimpleMessage::~SimpleMessage()
+{}
+
+const qpid::broker::MessageHandle&
+SimpleMessage::getHandle() const
+{
+ return m_msgHandle;
+}
+
+qpid::broker::MessageHandle&
+SimpleMessage::getHandle()
+{
+ return m_msgHandle;
+}
+
+uint64_t
+SimpleMessage::contentSize() const
+{
+ return static_cast<uint64_t>(m_msg.size());
+}
+
+void
+SimpleMessage::setPersistenceId(uint64_t id) const
+{
+ m_persistenceId = id;
+}
+
+uint64_t
+SimpleMessage::getPersistenceId() const
+{
+ return m_persistenceId;
+}
+
+void
+SimpleMessage::encode(qpid::framing::Buffer& buffer) const
+{
+ buffer.putRawData(m_msg);
+}
+
+uint32_t
+SimpleMessage::encodedSize() const
+{
+ return static_cast<uint32_t>(m_msg.size());
+}
+
+void
+SimpleMessage::allDequeuesComplete()
+{}
+
+uint32_t
+SimpleMessage::encodedHeaderSize() const
+{
+ return 0;
+}
+
+bool
+SimpleMessage::isPersistent() const
+{
+ return m_msgHandle.isValid();
+}
+
+uint64_t
+SimpleMessage::getSize()
+{
+ return m_msg.size();
+}
+
+void
+SimpleMessage::write(char* target)
+{
+ ::memcpy(target, m_msg.data(), m_msg.size());
+}
+
+}}} // namespace tests::storePerftools::asyncPerf