#ifndef PQPIXMAP_H #define PQPIXMAP_H /** * @brief pQPixmap a smart pointer to a QPixmap to avoid much data on the stack * The smart pointer always has an object (!) */ class pQPixmap : public std::shared_ptr { public: /** * @brief pQPixmap enforce a creation of an empty QPixmap */ pQPixmap() : std::shared_ptr(new QPixmap()) { } /** * @brief pPixmap load from file * @param filename the file */ pQPixmap(const QString& filename) : std::shared_ptr(new QPixmap(filename)) {} /** * @brief pQPixmap create this as reference to another pQPixmap * @param other the other smart pointer to the QPixmap */ pQPixmap(const pQPixmap& other) : std::shared_ptr() { this->reset(); std::shared_ptr::operator =( other); if (other.get() == 0) { std::shared_ptr::operator =( std::make_shared(QPixmap())); } } /** * @brief pQPixmap obtain ownership of a QPixmap pointer * @param other the pointer to an QPixmap -> must not be deleted somewhere else */ pQPixmap(QPixmap* other) : std::shared_ptr(other) { } /** * @brief pQPixmap a smart pointer to an image given an actual QPixmap object * @param image the object to be referenced to */ pQPixmap(const QPixmap& image) : std::shared_ptr(new QPixmap(image)) { } }; #endif // PQPIXMAP_H