1 /*------------------------------------------------------------------------------
  2 Name:      EraseQueueEntry.cpp
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 
  7 #include <util/queue/EraseQueueEntry.h>
  8 #include <util/dispatch/I_ConnectionsHandler.h>
  9 #include <cstring> // memset()
 10 
 11 namespace org { namespace xmlBlaster { namespace util { namespace queue {
 12 
 13 using namespace std;
 14 using namespace org::xmlBlaster::util::dispatch;
 15 using namespace org::xmlBlaster::util::qos;
 16 using namespace org::xmlBlaster::util::key;
 17 using namespace org::xmlBlaster::client::qos;
 18 using namespace org::xmlBlaster::client::key;
 19 
 20 EraseQueueEntry::EraseQueueEntry(Global& global, const EraseKey& eraseKey,
 21      const EraseQos& eraseQos, int priority, Timestamp uniqueId)
 22    : MsgQueueEntry(global, eraseKey.getData(), eraseQos.getData(), 
 23      org::xmlBlaster::util::Constants::ENTRY_TYPE_MSG_RAW + "|" + org::xmlBlaster::util::MethodName::ERASE,
 24      priority,
 25      eraseQos.getData().isPersistent(),
 26      uniqueId)
 27 {
 28    ME = "EraseQueueEntry";
 29 }
 30 
 31 EraseQueueEntry::~EraseQueueEntry() {
 32 }
 33 
 34 /** copy constructor */
 35 EraseQueueEntry::EraseQueueEntry(const EraseQueueEntry& rhs)
 36     //: MsgQueueEntry((MsgQueueEntry)rhs)
 37     : MsgQueueEntry(rhs.getGlobal(), rhs.getMsgUnit(), rhs.getEmbeddedType(), rhs.getPriority(), rhs.isPersistent(), rhs.getUniqueId())
 38 {
 39    memset(&blobHolder_, 0, sizeof(BlobHolder)); // reset cache
 40 }
 41 
 42 /** assignment constructor */
 43 EraseQueueEntry& EraseQueueEntry::operator=(const EraseQueueEntry& rhs)
 44 {
 45    if (this == &rhs)
 46       return *this;
 47    memset(&blobHolder_, 0, sizeof(BlobHolder)); // reset cache
 48    return *this;
 49 }
 50 
 51 MsgQueueEntry *EraseQueueEntry::getClone() const
 52 {
 53    return new EraseQueueEntry(*this);
 54 }
 55 
 56 bool EraseQueueEntry::isErase() const {
 57         return true;
 58 }
 59 
 60 // this should actually be in another interface but since it is an only method we put it here.
 61 const MsgQueueEntry& EraseQueueEntry::send(I_ConnectionsHandler& connectionsHandler) const
 62 {
 63    if (log_.call()) log_.call(ME, "send");
 64    if (statusQosData_) {
 65       delete statusQosData_;
 66       statusQosData_ = NULL;
 67    }
 68 
 69    log_.error(ME, string("send() return is not implemented: ") + EraseQueueEntry::toXml());
 70    /*
 71    // ??? TODO:
 72    vector<EraseReturnQos> 
 73    */
 74   //statusQosData_ = new StatusQosData(
 75         connectionsHandler.getConnection().erase(getEraseKey(), getEraseQos());
 76     //.getData());
 77    return *this;
 78 }
 79 
 80 EraseQos EraseQueueEntry::getEraseQos() const
 81 {
 82    const QueryQosData *qos = dynamic_cast<const QueryQosData *>(&msgUnit_->getQos());
 83    return EraseQos(global_, *qos);
 84 }
 85 
 86 EraseKey EraseQueueEntry::getEraseKey() const
 87 {
 88    const QueryKeyData *key = dynamic_cast<const QueryKeyData *>(&msgUnit_->getKey());
 89    return EraseKey(global_, *key);
 90 }
 91 
 92 EraseReturnQos EraseQueueEntry::getEraseReturnQos() const
 93 {
 94    return EraseReturnQos(global_, *statusQosData_);
 95 }
 96 
 97 string EraseQueueEntry::toXml(const string& indent) const
 98 {
 99    string extraOffset = "   " + indent;
100    string ret = indent + "<eraseQueueEntry>\n";
101    if (msgUnit_) {
102       ret += extraOffset + msgUnit_->toXml(indent);
103    }
104    ret += indent + "</eraseQueueEntry>\n";
105    return ret;
106 }
107 
108 
109 }}}} // namespace


syntax highlighted by Code2HTML, v. 0.9.1