Add skeletal EventStringifier
[quassel.git] / src / common / ircevent.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2010 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef IRCEVENT_H
22 #define IRCEVENT_H
23
24 #include "networkevent.h"
25
26 class IrcEvent : public NetworkEvent {
27 public:
28   explicit IrcEvent(EventManager::EventType type, Network *network, const QString &prefix, const QStringList &params = QStringList())
29     : NetworkEvent(type, network),
30       _prefix(prefix),
31       _params(params)
32   {}
33
34   inline QString prefix() const { return _prefix; }
35   inline void setPrefix(const QString &prefix) { _prefix = prefix; }
36
37   inline QStringList params() const { return _params; }
38   inline void setParams(const QStringList &params) { _params = params; }
39
40 protected:
41   virtual inline QString className() const { return "IrcEvent"; }
42   virtual inline void debugInfo(QDebug &dbg) const {
43     NetworkEvent::debugInfo(dbg);
44     dbg << ", prefix = " << qPrintable(prefix())
45         << ", params = " << params();
46   }
47
48 private:
49   QString _prefix;
50   QStringList _params;
51
52 };
53
54 class IrcEventNumeric : public IrcEvent {
55 public:
56   explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, const QString &target, const QStringList &params = QStringList())
57     : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
58       _number(number),
59       _target(target)
60   {}
61
62   inline uint number() const { return _number; }
63
64   inline QString target() const { return _target; }
65   inline void setTarget(const QString &target) { _target = target; }
66
67 protected:
68   virtual inline QString className() const { return "IrcEventNumeric"; }
69   virtual inline void debugInfo(QDebug &dbg) const {
70     dbg << ", num = " << number();
71     NetworkEvent::debugInfo(dbg);
72     dbg << ", target = " << qPrintable(target())
73         << ", prefix = " << qPrintable(prefix())
74         << ", params = " << params();
75   }
76
77 private:
78   uint _number;
79   QString _target;
80
81 };
82
83 class IrcEventRawMessage : public IrcEvent {
84 public:
85   explicit IrcEventRawMessage(EventManager::EventType type, Network *network, const QString &prefix, const QString &target, const QByteArray &rawMessage)
86     : IrcEvent(type, network, prefix, QStringList() << target),
87       _rawMessage(rawMessage)
88   {}
89
90   inline QString target() const { return params().at(0); }
91   inline void setTarget(const QString &target) { setParams(QStringList() << target); }
92
93   inline QByteArray rawMessage() const { return _rawMessage; }
94   inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
95
96 protected:
97   virtual inline QString className() const { return "IrcEventRawMessage"; }
98   virtual inline void debugInfo(QDebug &dbg) const {
99     NetworkEvent::debugInfo(dbg);
100     dbg << ", target = " << qPrintable(target())
101         << ", prefix = " << qPrintable(prefix())
102         << ", msg = " << rawMessage();
103   }
104
105
106 private:
107   QByteArray _rawMessage;
108 };
109
110 #endif