source: source/ariba/utility/transport/tcpip/protlib/connectionmap_uds.h@ 9652

Last change on this file since 9652 was 6922, checked in by mies, 15 years ago

replaced deprecated hash_map, hash_set classes with boost
added unsigned serialization
fixed more warnings
included -Wall to Makefile.am

File size: 3.7 KB
RevLine 
[5284]1/// ----------------------------------------*- mode: C++; -*--
2/// @file connectionmap_uds.h
3/// maintains connection mapping of application addresses to
4/// UNIX domain sockets and vice versa
5/// ----------------------------------------------------------
6/// $Id: connectionmap_uds.h 2549 2007-04-02 22:17:37Z bless $
7/// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/include/connectionmap_uds.h $
8// ===========================================================
9//
10// Copyright (C) 2005-2007, all rights reserved by
11// - Institute of Telematics, Universitaet Karlsruhe (TH)
12//
13// More information and contact:
14// https://projekte.tm.uka.de/trac/NSIS
15//
16// This program is free software; you can redistribute it and/or modify
17// it under the terms of the GNU General Public License as published by
18// the Free Software Foundation; version 2 of the License
19//
20// This program is distributed in the hope that it will be useful,
21// but WITHOUT ANY WARRANTY; without even the implied warranty of
22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23// GNU General Public License for more details.
24//
25// You should have received a copy of the GNU General Public License along
26// with this program; if not, write to the Free Software Foundation, Inc.,
27// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28//
29// ===========================================================
30#ifndef CONNECTION_MAP_UDS_H
31#define CONNECTION_MAP_UDS_H
32
33#include "assocdata_uds.h"
[6922]34#include <boost/unordered_map.hpp>
[5284]35
36namespace protlib {
37
[6922]38using boost::unordered_map;
39
[5284]40/* @class ConnectionMap
41 * maintains connection mapping of application addresses to sockets and vice versa
42 * @ingroup network
43 * @{
44 */
45class ConnectionMapUDS {
46 public:
47 // a constructor may be needed here in this class
48 /// Insert a new AssocDataUDS element into the ConnectionMapUDS
49 bool insert(AssocDataUDS* assoc);
50 /// Search for existing connections to this specific socket
51 AssocDataUDS* lookup(socketfd_t socketfd) const;
52 /// Search for existing connections to this specific assoc id
53 AssocDataUDS* lookup(associd_t associd) const;
54 ///Search for existing connections to this address
55 AssocDataUDS* lookup(const udsaddress& addr) const;
56 /// Erase the AssocDataUDS-element associated with this socket
57 bool erase(socketfd_t socketfd);
58 /// Erase the AssocDataUDS-element associated with this socket
59 bool erase(associd_t associd);
60 /// Erase the AssocDataUDS-element
61 bool erase(AssocDataUDS* assoc);
62 /// clear all
63 void clear();
64 /// get number of records
65 size_t get_size() const;
66 private:
[6922]67 // this unordered_map uses the standard hashfunction on the first entry, int
[5284]68
69 // only typedefs
[6922]70 typedef unordered_map<socketfd_t ,AssocDataUDS*> ass2data_t;
[5284]71 typedef ass2data_t::const_iterator const_ass2data_it_t;
[6922]72 typedef unordered_map<udsaddress,AssocDataUDS*> addr2data_t;
[5284]73 typedef addr2data_t::const_iterator const_addr2data_it_t;
74
75 // internal hashmaps
76 ass2data_t ass2data; ///< map: socket fd to association data
77 addr2data_t addr2data; ///< map: (application) address to association data
78 public:
79 /// connection map iterator
80 typedef const_ass2data_it_t const_it_t;
81 const_it_t begin() const;
82 const_it_t end() const;
83}; // end class ConnectionMapUDS
84
85inline
86size_t
87ConnectionMapUDS::get_size() const { return ass2data.size(); }
88
89inline
90ConnectionMapUDS::const_it_t ConnectionMapUDS::begin() const {
91 return ass2data.begin();
92} // end begin
93
94inline
95ConnectionMapUDS::const_it_t ConnectionMapUDS::end() const {
96 return ass2data.end();
97} // end end
98
99inline
100bool
101ConnectionMapUDS::erase(AssocDataUDS* assoc) {
102 return assoc ? erase(assoc->socketfd) : false;
103} // end erase
104
105//@}
106
107} // end namespace protlib
108#endif
Note: See TracBrowser for help on using the repository browser.