diff --git a/include/Swiften/Elements/PubSubItem.h b/include/Swiften/Elements/PubSubItem.h new file mode 100644 index 0000000000000000000000000000000000000000..f0b3ef7007c8162df847904f809aea97b1f52c75 --- /dev/null +++ b/include/Swiften/Elements/PubSubItem.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011 Jan Kaluza + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include + +#include +#include + +namespace Swift { + class PubSubItem : public Payload { + public: + PubSubItem(); + + void addPayload(boost::shared_ptr payload) { + payloads.push_back(payload); + } + + const std::vector > getPayloads() const { + return payloads; + } + + template + const std::vector > getPayloads() const { + std::vector > matched_payloads; + for (std::vector >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { + boost::shared_ptr result = boost::dynamic_pointer_cast(*i); + if (result) { + matched_payloads.push_back(result); + } + } + + return matched_payloads; + + } + + template + const boost::shared_ptr getPayload() const { + boost::shared_ptr result; + for (std::vector >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { + result = boost::dynamic_pointer_cast(*i); + if (result) { + return result; + } + } + + return result; + } + + const std::string& getId() const { return id; } + + void setId(const std::string& id) { + this->id = id; + } + + private: + std::vector > payloads; + std::string id; + }; +}