~nico-izo-ya/+junk/aaron2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/****************************************************************************
 * delayedmessage.h
 *  Copyright © 2012, Vsevolod Velichko <torkvema@gmail.com>.
 *  Licence: GPLv3 or later
 *
 ****************************************************************************
 *                                                                          *
 *   This library is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation; either version 3 of the License, or      *
 *   (at your option) any later version.                                    *
 *                                                                          *
 ****************************************************************************/

#ifndef DELAYEDMESSAGE_ESM61D3O
#define DELAYEDMESSAGE_ESM61D3O

#include <QDataStream>
#include <QDateTime>
#include <QString>
#include <QMetaType>
#include <QQueue>
#include <QSharedPointer>
#include <QHash>

struct DelayedMessage
{
	QString from;
	QDateTime timeAdded;
	QString message;
};

template<typename T> class AutocreatedSharedPointer : public QSharedPointer<T>
{
	typedef QSharedPointer<T> BaseClass;
	public:
		inline AutocreatedSharedPointer() : BaseClass(new T()){}
};

Q_DECLARE_METATYPE(DelayedMessage)
Q_DECLARE_METATYPE(AutocreatedSharedPointer<QQueue<DelayedMessage>>)
typedef QHash<QString,AutocreatedSharedPointer<QQueue<DelayedMessage>>> MSGHASH;
Q_DECLARE_METATYPE(MSGHASH)

typedef AutocreatedSharedPointer<QQueue<DelayedMessage> > DelayedMessages;

QDataStream &operator<<(QDataStream &out, const DelayedMessage &msg);
QDataStream &operator>>(QDataStream &in, DelayedMessage &msg);

QDataStream &operator<<(QDataStream &out, const DelayedMessages &msgs);
QDataStream &operator>>(QDataStream &in, DelayedMessages &msg);

#endif /* end of include guard: DELAYEDMESSAGE_ESM61D3O */