1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 03:51:35 +01:00

Added Packet conversion to bool.

This commit is contained in:
Matias Fontanini
2012-11-26 15:22:29 -03:00
parent 16a29fab3e
commit 88faee9b26

View File

@@ -146,8 +146,7 @@ public:
* This calls PDU::clone on the rhs's PDU* member.
*/
Packet(const Packet &rhs) : ts(rhs.timestamp()) {
if(rhs.pdu())
pdu_ = rhs.pdu()->clone();
pdu_ = rhs.pdu() ? rhs.pdu()->clone() : 0;
}
/**
@@ -175,7 +174,7 @@ public:
/**
* Move assignment operator.
*/
Packet& operator=(Packet &&rhs){
Packet& operator=(Packet &&rhs) {
if(this != &rhs) {
std::swap(pdu_, rhs.pdu_);
ts = rhs.timestamp();
@@ -232,6 +231,15 @@ public:
pdu_ = 0;
return some_pdu;
}
/**
* \brief Tests whether this is Packet contains a valid PDU.
*
* \return true if pdu() == nullptr, false otherwise.
*/
operator bool() const {
return pdu_;
}
private:
PDU *pdu_;
Timestamp ts;