1 /**
2 * Whiteboard message queue and queue handler functions
3 * Node for storing messages in message queues
4 *
5 * Authors:
6 * David Yip <yipdw@rose-hulman.edu>
7 *
8 * Copyright (c) 2005 Authors
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
13 #ifndef __WHITEBOARD_MESSAGE_NODE_H__
14 #define __WHITEBOARD_MESSAGE_NODE_H__
16 #include <string>
17 #include <glibmm.h>
19 #include "gc-managed.h"
20 #include "gc-anchored.h"
21 #include "gc-finalized.h"
23 namespace Inkscape {
25 namespace Whiteboard {
27 /**
28 * Encapsulates a document change message received by or sent to an Inkboard client.
29 *
30 * Received messages that end up in a MessageNode are of the following types:
31 * <ol>
32 * <li>CHANGE_REPEATABLE</li>
33 * <li>CHANGE_NOT_REPEATABLE</li>
34 * <li>CHANGE_COMMIT</li>
35 * <li>DOCUMENT_BEGIN</li>
36 * <li>DOCUMENT_END</li>
37 * <li>DUMMY_CHANGE</li>
38 * </ol>
39 *
40 * This class is intended for use in MessageQueues, although it could potentially
41 * see use outside of that context.
42 *
43 * \see Inkscape::Whiteboard::MessageQueue
44 */
45 class MessageNode : public GC::Managed<>, public GC::Anchored, public GC::Finalized {
46 public:
47 /**
48 * Constructor.
49 *
50 * \param seq The sequence number of the message being encapsulated.
51 * \param sender The sender of the message.
52 * \param recip The intended recipient.
53 * \param message_body The body of the message.
54 * \param type The type of the message.
55 * \param chatroom Whether or not this message is to be sent to / was received from a chatroom.
56 */
57 MessageNode(unsigned int seq, std::string sender, std::string recip, Glib::ustring const& message_body, MessageType type, bool document, bool chatroom) :
58 _seq(seq), _type(type), _message(message_body), _document(document), _chatroom(chatroom)
59 {
60 this->_sender = sender;
61 this->_recipient = recip;
62 }
64 ~MessageNode()
65 {
66 // g_log(NULL, G_LOG_LEVEL_DEBUG, "MessageNode destructor");
67 /*
68 if (this->_message) {
69 delete this->_message;
70 }
71 */
72 }
74 unsigned int sequence()
75 {
76 return this->_seq;
77 }
79 MessageType type()
80 {
81 return this->_type;
82 }
84 bool chatroom()
85 {
86 return this->_chatroom;
87 }
89 bool document()
90 {
91 return this->_document;
92 }
94 std::string recipient()
95 {
96 return this->_recipient;
97 }
99 std::string sender()
100 {
101 return this->_sender;
102 }
104 Glib::ustring const& message()
105 {
106 return this->_message;
107 }
109 private:
110 unsigned int _seq;
111 std::string _sender;
112 std::string _recipient;
113 MessageType _type;
114 Glib::ustring _message;
115 bool _document;
116 bool _chatroom;
117 };
119 }
121 }
123 #endif
125 /*
126 Local Variables:
127 mode:c++
128 c-file-style:"stroustrup"
129 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
130 indent-tabs-mode:nil
131 fill-column:99
132 End:
133 */
134 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :