Code

moving trunk for module inkscape
[inkscape.git] / src / jabber_whiteboard / typedefs.h
1 /**
2  * Whiteboard session manager
3  * Typedef declarations and template specializations
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_TYPEDEFS_H__
14 #define __WHITEBOARD_TYPEDEFS_H__
16 extern "C" {
17 #include <loudmouth/loudmouth.h>
18 }
20 #include <algorithm>
21 #include <cstring>
22 #include <string>
23 #include <map>
24 #include <set>
25 #include <bitset>
27 #include <glibmm.h>
28 #include <sigc++/sigc++.h>
30 #include "jabber_whiteboard/defines.h"
32 #include "gc-alloc.h"
34 namespace Inkscape {
36 namespace XML {
38 class Node;
40 }
42 namespace Util {
44 template< typename T >
45 class ListContainer;
47 }
49 }
51 // Various specializations of std::less for XMLNodeTracker maps.
52 namespace std {
53 using Inkscape::XML::Node;
55 /**
56  * Specialization of std::less<> for pointers to XML::Nodes.a
57  *
58  * \see Inkscape::XML::Node
59  */
60 template<>
61 struct less< Node* > : public binary_function < Node*, Node*, bool >
62 {
63         bool operator()(Node* _x, Node* _y) const
64         {
65                 return _x < _y;
66         }
68 };
70 }
72 namespace Inkscape {
74 namespace Whiteboard {
75 // I am assuming that std::string (which will not properly represent Unicode data) will
76 // suffice for associating (integer, Jabber ID) identifiers with nodes. 
77 // We do not need to preserve all semantics handled by Unicode; we just need to have 
78 // the byte representation.  std::string is good enough for that.
79 //
80 // The reason for this is that comparisons with std::string are much faster than 
81 // comparisons with Glib::ustring (simply because the latter is using significantly
82 // more complex text-handling algorithms), and we need speed here.  We _could_ use
83 // Glib::ustring::collate_key() here and therefore get the best of both worlds,
84 // but collation keys are rather big.
85 //
86 // XML node tracker maps
88 /// Associates node keys to pointers to XML::Nodes.
89 /// \see Inkscape::Whiteboard::XMLNodeTracker
90 typedef std::map< std::string, XML::Node*, std::less< std::string >, GC::Alloc< std::pair< const std::string, XML::Node* >, GC::MANUAL > > KeyToTrackerNodeMap;
92 /// Associates pointers to XML::Nodes with node keys.
93 /// \see Inkscape::Whiteboard::XMLNodeTracker
94 typedef std::map< XML::Node*, std::string, std::less< XML::Node* >, GC::Alloc< std::pair< XML::Node* const, std::string >, GC::MANUAL > > TrackerNodeToKeyMap;
97 // TODO: Clean up these typedefs.  I'm sure quite a few of these aren't used anymore; additionally,
98 // it's probably possible to consolidate a few of these types into one.
100 // Temporary storage of new object messages and new nodes in said messages
101 typedef std::list< Glib::ustring > NewChildObjectMessageList;
103 typedef std::pair< std::string, XML::Node* > KeyNodePair;
104 typedef std::pair< KeyNodePair, NodeTrackerAction > SerializedEventNodeAction;
106 typedef std::list< SerializedEventNodeAction > KeyToNodeActionList;
108 //typedef std::map< std::string, SerializedEventNodeAction > KeyToNodeActionMap;
110 typedef std::set< std::string > AttributesScannedSet;
111 typedef std::set< XML::Node* > AttributesUpdatedSet;
113 typedef std::map< std::string, XML::Node const* > KeyToNodeMap;
114 typedef std::map< XML::Node const*, std::string > NodeToKeyMap;
116 // Buddy list management
117 typedef std::set< std::string > BuddyList;
118 typedef sigc::signal< void, std::string const& > BuddyListSignal;
119 typedef sigc::slot< void, std::string const& > BuddyListListener;
121 // Chatroom list participants
122 typedef std::set< char const* > ChatterList;
124 // Message context verification and processing
125 struct MessageProcessor;
126 class ReceiveMessageQueue;
128 typedef std::map< MessageType, std::bitset< NUM_FLAGS > > MessageContextMap;
129 typedef std::map< MessageType, MessageProcessor*, std::less< MessageType >, GC::Alloc< std::pair< const MessageType, MessageProcessor* >, GC::MANUAL > > MessageProcessorMap;
131 typedef std::map< std::string, ReceiveMessageQueue*, std::less< std::string >, GC::Alloc< std::pair< const std::string, ReceiveMessageQueue* >, GC::MANUAL > > RecipientToReceiveQueueMap;
132 typedef std::map< std::string, unsigned int > ReceipientToLatestTransactionMap;
134 typedef std::string ReceivedCommitEvent;
135 typedef std::list< ReceivedCommitEvent > CommitsQueue;
137 // Message serialization
138 typedef std::list< Glib::ustring > SerializedEventList;
140 // Error handling -- someday
141 // TODO: finish and integrate this
142 //typedef boost::function< LmHandlerResult (unsigned int code) > ErrorHandlerFunctor;
143 //typedef std::map< unsigned int, ErrorHandlerFunctor > ErrorHandlerFunctorMap;
149 #endif
150 /*
151   Local Variables:
152   mode:c++
153   c-file-style:"stroustrup"
154   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
155   indent-tabs-mode:nil
156   fill-column:99
157   End:
158 */
159 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :