tdesktop/Telegram/SourceFiles/history/admin_log/history_admin_log_item.h

52 lines
1.3 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace AdminLog {
class HistoryItemOwned;
class LocalIdManager;
2017-06-21 21:38:31 +00:00
void GenerateItems(not_null<History*> history, LocalIdManager &idManager, const MTPDchannelAdminLogEvent &event, base::lambda<void(HistoryItemOwned item)> callback);
// Smart pointer wrapper for HistoryItem* that destroys the owned item.
class HistoryItemOwned {
public:
explicit HistoryItemOwned(not_null<HistoryItem*> data) : _data(data) {
2017-06-21 21:38:31 +00:00
}
HistoryItemOwned(const HistoryItemOwned &other) = delete;
HistoryItemOwned &operator=(const HistoryItemOwned &other) = delete;
HistoryItemOwned(HistoryItemOwned &&other) : _data(base::take(other._data)) {
}
HistoryItemOwned &operator=(HistoryItemOwned &&other) {
_data = base::take(other._data);
return *this;
}
~HistoryItemOwned() {
if (_data) {
_data->destroy();
}
}
HistoryItem *get() const {
return _data;
}
HistoryItem *operator->() const {
return get();
}
operator HistoryItem*() const {
return get();
}
private:
HistoryItem *_data = nullptr;
};
} // namespace AdminLog