util/queue/EraseQueueEntry.cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      EraseQueueEntry.cpp
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 ------------------------------------------------------------------------------*/
00006 
00007 #include <util/queue/EraseQueueEntry.h>
00008 #include <util/dispatch/I_ConnectionsHandler.h>
00009 
00010 namespace org { namespace xmlBlaster { namespace util { namespace queue {
00011 
00012 using namespace std;
00013 using namespace org::xmlBlaster::util::dispatch;
00014 using namespace org::xmlBlaster::util::qos;
00015 using namespace org::xmlBlaster::util::key;
00016 using namespace org::xmlBlaster::client::qos;
00017 using namespace org::xmlBlaster::client::key;
00018 
00019 EraseQueueEntry::EraseQueueEntry(Global& global, const EraseKey& eraseKey,
00020      const EraseQos& eraseQos, int priority, Timestamp uniqueId)
00021    : MsgQueueEntry(global, eraseKey.getData(), eraseQos.getData(), 
00022      org::xmlBlaster::util::Constants::ENTRY_TYPE_MSG_RAW + "|" + org::xmlBlaster::util::MethodName::ERASE,
00023      priority,
00024      eraseQos.getData().isPersistent(),
00025      uniqueId)
00026 {
00027    ME = "EraseQueueEntry";
00028 }
00029 
00030 EraseQueueEntry::~EraseQueueEntry() {
00031 }
00032 
00034 EraseQueueEntry::EraseQueueEntry(const EraseQueueEntry& rhs)
00035     //: MsgQueueEntry((MsgQueueEntry)rhs)
00036     : MsgQueueEntry(rhs.getGlobal(), rhs.getMsgUnit(), rhs.getEmbeddedType(), rhs.getPriority(), rhs.isPersistent(), rhs.getUniqueId())
00037 {
00038    memset(&blobHolder_, 0, sizeof(BlobHolder)); // reset cache
00039 }
00040 
00042 EraseQueueEntry& EraseQueueEntry::operator=(const EraseQueueEntry& rhs)
00043 {
00044    if (this == &rhs)
00045       return *this;
00046    memset(&blobHolder_, 0, sizeof(BlobHolder)); // reset cache
00047    return *this;
00048 }
00049 
00050 MsgQueueEntry *EraseQueueEntry::getClone() const
00051 {
00052    return new EraseQueueEntry(*this);
00053 }
00054 
00055 bool EraseQueueEntry::isErase() const {
00056    return true;
00057 }
00058 
00059 // this should actually be in another interface but since it is an only method we put it here.
00060 const MsgQueueEntry& EraseQueueEntry::send(I_ConnectionsHandler& connectionsHandler) const
00061 {
00062    if (log_.call()) log_.call(ME, "send");
00063    if (statusQosData_) {
00064       delete statusQosData_;
00065       statusQosData_ = NULL;
00066    }
00067 
00068    log_.error(ME, string("send() return is not implemented: ") + EraseQueueEntry::toXml());
00069    /*
00070    // ??? TODO:
00071    vector<EraseReturnQos> 
00072    */
00073   //statusQosData_ = new StatusQosData(
00074         connectionsHandler.getConnection().erase(getEraseKey(), getEraseQos());
00075     //.getData());
00076    return *this;
00077 }
00078 
00079 EraseQos EraseQueueEntry::getEraseQos() const
00080 {
00081    const QueryQosData *qos = dynamic_cast<const QueryQosData *>(&msgUnit_->getQos());
00082    return EraseQos(global_, *qos);
00083 }
00084 
00085 EraseKey EraseQueueEntry::getEraseKey() const
00086 {
00087    const QueryKeyData *key = dynamic_cast<const QueryKeyData *>(&msgUnit_->getKey());
00088    return EraseKey(global_, *key);
00089 }
00090 
00091 EraseReturnQos EraseQueueEntry::getEraseReturnQos() const
00092 {
00093    return EraseReturnQos(global_, *statusQosData_);
00094 }
00095 
00096 string EraseQueueEntry::toXml(const string& indent) const
00097 {
00098    string extraOffset = "   " + indent;
00099    string ret = indent + "<eraseQueueEntry>\n";
00100    if (msgUnit_) {
00101       ret += extraOffset + msgUnit_->toXml(indent);
00102    }
00103    ret += indent + "</eraseQueueEntry>\n";
00104    return ret;
00105 }
00106 
00107 
00108 }}}} // namespace
00109 
00110