source: source/ariba/utility/transport/tcpip/protlib/queuemanager.h@ 5993

Last change on this file since 5993 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 3.5 KB
Line 
1/// ----------------------------------------*- mode: C++; -*--
2/// @file queuemanager.h
3/// This is the queuemanager which records queues and message source IDs
4/// ----------------------------------------------------------
5/// $Id: queuemanager.h 2549 2007-04-02 22:17:37Z bless $
6/// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/include/queuemanager.h $
7// ===========================================================
8//
9// Copyright (C) 2005-2007, all rights reserved by
10// - Institute of Telematics, Universitaet Karlsruhe (TH)
11//
12// More information and contact:
13// https://projekte.tm.uka.de/trac/NSIS
14//
15// This program is free software; you can redistribute it and/or modify
16// it under the terms of the GNU General Public License as published by
17// the Free Software Foundation; version 2 of the License
18//
19// This program is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License along
25// with this program; if not, write to the Free Software Foundation, Inc.,
26// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27//
28// ===========================================================
29/** @ingroup queuemanager
30 *
31 * This is the queuemanager which records queues and message source IDs.
32 */
33
34#ifndef QUEUE_MANAGER_H
35#define QUEUE_MANAGER_H
36
37#include "protlib_types.h"
38#include "cleanuphandler.h"
39
40#include <vector>
41
42#include "fqueue.h"
43#include "messages.h"
44
45namespace protlib {
46
47/** @addtogroup queuemanager Queue Manager
48 * \ingroup fastqueue
49 * @{
50 */
51
52/// QueueManager errors
53class QueueManagerError : public ProtLibException {
54public:
55 /// error codes
56 enum error_t {
57 ERROR_NO_QUEUE_MANAGER,
58 ERROR_REGISTER
59 }; // end error_t
60 const error_t err;
61 /// constructor
62 QueueManagerError(error_t e);
63 virtual const char* getstr() const;
64 virtual const char *what() const throw() { return getstr(); }
65private:
66 /// QueueManager error strings
67 static const char* const errstr[];
68}; // end class QueueManagerError
69
70
71/**
72 * The Queue Manager singleton.
73 *
74 * The QueueManager manages several FastQueue objects. A queue is registered
75 * with the manager using a simple (key, value) scheme. The key is of type
76 * message:qaddr_t, and the value is a FastQueue object.
77 *
78 * You can send messages to a registered queue using the message::send_to(dest)
79 * method, where dest has to be the message::qaddr_t which has been used for
80 * registering the queue.
81 *
82 * This class is used as a singleton, so there will usually be only one
83 * object of this class.
84 */
85class QueueManager {
86public:
87 /// return QueueManager singleton instance
88 static QueueManager* instance();
89 /// clear QueueManager
90 static void clear();
91 /// register a queue
92 void register_queue(FastQueue* fq, message::qaddr_t s);
93 /// deregister a queue
94 void unregister_queue(message::qaddr_t s);
95
96 /// get queue
97 FastQueue* get_queue(message::qaddr_t s) const;
98private:
99 /// QueueManager instance
100 static QueueManager* inst;
101 /// constructor
102 QueueManager();
103 /// Destruktor
104 ~QueueManager();
105 /// QueueManager array
106 typedef vector<FastQueue*> qm_array_t;
107 /// QueueManager array iterator
108 typedef qm_array_t::iterator qm_array_it_t;
109 /// array
110 qm_array_t queue_arr;
111 /// locking
112 mutable pthread_mutex_t mutex;
113
114 static const size_t INITIAL_ARRAY_SIZE = 128;
115};
116
117//@}
118
119} // end namespace protlib
120
121#endif
Note: See TracBrowser for help on using the repository browser.