close Warning: Can't use blame annotator:
No changeset 1891 in the repository

source: source/ariba/communication/modules/transport/protlib/connectionmap.h@ 2482

Last change on this file since 2482 was 2482, checked in by Christoph Mayer, 16 years ago

-added missing port and ip parameters to join

File size: 3.5 KB
RevLine 
1/// ----------------------------------------*- mode: C++; -*--
2/// @file connectionmap.h
3/// maintains connection mapping of application addresses to sockets and vice versa
4/// ----------------------------------------------------------
5/// $Id: connectionmap.h 2549 2007-04-02 22:17:37Z bless $
6/// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/include/connectionmap.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#ifndef CONNECTION_MAP_H
30#define CONNECTION_MAP_H
31
32#include "assocdata.h"
33#include <ext/hash_map>
34
35namespace protlib {
36
37/* @class ConnectionMap
38 * maintains connection mapping of application addresses to sockets and vice versa
39 * @ingroup network
40 * @{
41 */
42class ConnectionMap {
43 public:
44 // a constructor may be needed here in this class
45 /// Insert a new AssocData element into the ConnectionMap
46 bool insert(AssocData* assoc);
47 /// Search for existing connections to this specific socket
48 AssocData* lookup(socketfd_t socketfd) const;
49 /// Search for existing connections to this specific assoc id
50 AssocData* lookup(associd_t associd) const;
51 ///Search for existing connections to this address
52 AssocData* lookup(const appladdress& addr) const;
53 /// Erase the AssocData-element associated with this socket
54 bool erase(socketfd_t socketfd);
55 /// Erase the AssocData-element associated with this socket
56 bool erase(associd_t associd);
57 /// Erase the AssocData-element
58 bool erase(AssocData* assoc);
59 /// clear all
60 void clear();
61 /// get number of records
62 size_t get_size() const;
63 private:
64 // this hash_map uses the standard hashfunction on the first entry, int
65
66 // only typedefs
67 typedef hash_map<socketfd_t ,AssocData*> ass2data_t;
68 typedef ass2data_t::const_iterator const_ass2data_it_t;
69 typedef hash_map<appladdress,AssocData*> addr2data_t;
70 typedef addr2data_t::const_iterator const_addr2data_it_t;
71
72 // internal hashmaps
73 ass2data_t ass2data; ///< map: socket fd to association data
74 addr2data_t addr2data; ///< map: (application) address to association data
75 public:
76 /// connection map iterator
77 typedef const_ass2data_it_t const_it_t;
78 const_it_t begin() const;
79 const_it_t end() const;
80}; // end class ConnectionMap
81
82inline
83size_t
84ConnectionMap::get_size() const { return ass2data.size(); }
85
86inline
87ConnectionMap::const_it_t ConnectionMap::begin() const {
88 return ass2data.begin();
89} // end begin
90
91inline
92ConnectionMap::const_it_t ConnectionMap::end() const {
93 return ass2data.end();
94} // end end
95
96inline
97bool
98ConnectionMap::erase(AssocData* assoc) {
99 return assoc ? erase(assoc->socketfd) : false;
100} // end erase
101
102//@}
103
104} // end namespace protlib
105#endif
Note: See TracBrowser for help on using the repository browser.