Vault  4.1
vmessage.cpp
00001 /*
00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved.
00003 This file is part of the Code Vault version 4.1
00004 http://www.bombaydigital.com/
00005 License: MIT. See LICENSE.md in the Vault top level directory.
00006 */
00007 
00008 #include "vmessage.h"
00009 
00010 #include "vlogger.h"
00011 
00012 // VMessage -------------------------------------------------------------------
00013 
00014 const VString VMessage::kMessageLoggerName("vault.messages");
00015 const int VMessage::kMessageContentRecordingLevel  = VLoggerLevel::INFO;
00016 const int VMessage::kMessageHeaderLevel            = VLoggerLevel::DEBUG;
00017 const int VMessage::kMessageContentFieldsLevel     = VLoggerLevel::DEBUG + 1;
00018 const int VMessage::kMessageTrafficDetailsLevel    = VLoggerLevel::DEBUG + 2;
00019 const int VMessage::kMessageHandlerDispatchLevel   = VLoggerLevel::DEBUG + 3;
00020 const int VMessage::kMessageHandlerDetailLevel     = VLoggerLevel::DEBUG + 4;
00021 const int VMessage::kMessageContentHexDumpLevel    = VLoggerLevel::DEBUG + 5;
00022 const int VMessage::kMessageQueueOpsLevel          = VLoggerLevel::DEBUG + 6;
00023 const int VMessage::kMessageTraceDetailLevel       = VLoggerLevel::TRACE;
00024 const int VMessage::kMessageHandlerLifecycleLevel  = VLoggerLevel::TRACE;
00025 
00026 VMessage::VMessage()
00027     : VBinaryIOStream(mMessageDataBuffer)
00028     , mMessageDataBuffer(1024)
00029     , mMessageID(0)
00030     {
00031 }
00032 
00033 VMessage::VMessage(VMessageID messageID, Vs64 initialBufferSize)
00034     : VBinaryIOStream(mMessageDataBuffer)
00035     , mMessageDataBuffer(initialBufferSize)
00036     , mMessageID(messageID)
00037     {
00038 }
00039 
00040 void VMessage::recycleForSend(VMessageID messageID) {
00041     mMessageID = messageID;
00042     (void) this->seek0();
00043 }
00044 
00045 void VMessage::recycleForReceive() {
00046     mMessageID = 0;
00047     mMessageDataBuffer.setEOF(CONST_S64(0));
00048 }
00049 
00050 void VMessage::copyMessageData(VMessage& targetMessage) const {
00051     Vs64 savedOffset = mMessageDataBuffer.getIOOffset();
00052 
00053     mMessageDataBuffer.seek0();
00054     (void) VStream::streamCopy(mMessageDataBuffer, targetMessage, mMessageDataBuffer.getEOFOffset());
00055     mMessageDataBuffer.seek(savedOffset, SEEK_SET);
00056 }
00057 
00058 VMessageLength VMessage::getMessageDataLength() const {
00059     return (VMessageLength) mMessageDataBuffer.getEOFOffset();
00060 }
00061 
00062 Vu8* VMessage::getBuffer() const {
00063     return mMessageDataBuffer.getBuffer();
00064 }
00065 
00066 Vs64 VMessage::getBufferSize() const {
00067     return mMessageDataBuffer.getBufferSize();
00068 }
00069 

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.