~inkscape.dev/inkscape/trunk

« back to all changes in this revision

Viewing changes to src/jabber_whiteboard/typedefs.h

  • Committer: mental
  • Date: 2006-01-16 02:36:01 UTC
  • Revision ID: mental@users.sourceforge.net-20060116023601-wkr0h7edl5veyudq
moving trunk for module inkscape

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
12
 
 
13
#ifndef __WHITEBOARD_TYPEDEFS_H__
 
14
#define __WHITEBOARD_TYPEDEFS_H__
 
15
 
 
16
extern "C" {
 
17
#include <loudmouth/loudmouth.h>
 
18
}
 
19
 
 
20
#include <algorithm>
 
21
#include <cstring>
 
22
#include <string>
 
23
#include <map>
 
24
#include <set>
 
25
#include <bitset>
 
26
 
 
27
#include <glibmm.h>
 
28
#include <sigc++/sigc++.h>
 
29
 
 
30
#include "jabber_whiteboard/defines.h"
 
31
 
 
32
#include "gc-alloc.h"
 
33
 
 
34
namespace Inkscape {
 
35
 
 
36
namespace XML {
 
37
 
 
38
class Node;
 
39
 
 
40
}
 
41
 
 
42
namespace Util {
 
43
 
 
44
template< typename T >
 
45
class ListContainer;
 
46
 
 
47
}
 
48
 
 
49
}
 
50
 
 
51
// Various specializations of std::less for XMLNodeTracker maps.
 
52
namespace std {
 
53
using Inkscape::XML::Node;
 
54
 
 
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
        }
 
67
 
 
68
};
 
69
 
 
70
}
 
71
 
 
72
namespace Inkscape {
 
73
 
 
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
 
87
 
 
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;
 
91
 
 
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;
 
95
 
 
96
 
 
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.
 
99
 
 
100
// Temporary storage of new object messages and new nodes in said messages
 
101
typedef std::list< Glib::ustring > NewChildObjectMessageList;
 
102
 
 
103
typedef std::pair< std::string, XML::Node* > KeyNodePair;
 
104
typedef std::pair< KeyNodePair, NodeTrackerAction > SerializedEventNodeAction;
 
105
 
 
106
typedef std::list< SerializedEventNodeAction > KeyToNodeActionList;
 
107
 
 
108
//typedef std::map< std::string, SerializedEventNodeAction > KeyToNodeActionMap;
 
109
 
 
110
typedef std::set< std::string > AttributesScannedSet;
 
111
typedef std::set< XML::Node* > AttributesUpdatedSet;
 
112
 
 
113
typedef std::map< std::string, XML::Node const* > KeyToNodeMap;
 
114
typedef std::map< XML::Node const*, std::string > NodeToKeyMap;
 
115
 
 
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;
 
120
 
 
121
// Chatroom list participants
 
122
typedef std::set< char const* > ChatterList;
 
123
 
 
124
// Message context verification and processing
 
125
struct MessageProcessor;
 
126
class ReceiveMessageQueue;
 
127
 
 
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;
 
130
 
 
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;
 
133
 
 
134
typedef std::string ReceivedCommitEvent;
 
135
typedef std::list< ReceivedCommitEvent > CommitsQueue;
 
136
 
 
137
// Message serialization
 
138
typedef std::list< Glib::ustring > SerializedEventList;
 
139
 
 
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;
 
144
}
 
145
 
 
146
}
 
147
 
 
148
 
 
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 :