Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace LtsScriptTimeline
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class TemporaryPointerVector : public QVector<T>
|
||||
{
|
||||
static_assert(std::is_pointer<T>::value, "Type must be of pointer type");
|
||||
|
||||
public:
|
||||
TemporaryPointerVector() = default;
|
||||
|
||||
explicit TemporaryPointerVector(const QVector<T> &other)
|
||||
{
|
||||
discard();
|
||||
this->append(other);
|
||||
}
|
||||
|
||||
|
||||
~TemporaryPointerVector()
|
||||
{
|
||||
discard();
|
||||
}
|
||||
|
||||
|
||||
void setDiscardable(bool discardable)
|
||||
{
|
||||
m_discard = discardable;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool m_discard = true;
|
||||
|
||||
|
||||
void discard()
|
||||
{
|
||||
if (m_discard)
|
||||
qDeleteAll(this->begin(), this->end());
|
||||
this->clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user