axeld+bonefish: Got rid of the ParentType in the HashTableDefinition; it doesn't really
belong there. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21766 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,15 +5,15 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Hugo Santos, [email protected]
|
* Hugo Santos, [email protected]
|
||||||
*/
|
*/
|
||||||
|
#ifndef _KERNEL_UTIL_MULTI_HASH_TABLE_H
|
||||||
|
#define _KERNEL_UTIL_MULTI_HASH_TABLE_H
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MULTI_HASH_TABLE_H_
|
|
||||||
#define _MULTI_HASH_TABLE_H_
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
|
|
||||||
|
|
||||||
// MultiHashTable is a container which acts a bit like multimap<>
|
// MultiHashTable is a container which acts a bit like multimap<>
|
||||||
// but with hash table semantics.
|
// but with hash table semantics.
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@ public:
|
|||||||
MultiHashTable(size_t initialSize = HashTable::kMinimumSize)
|
MultiHashTable(size_t initialSize = HashTable::kMinimumSize)
|
||||||
: HashTable(initialSize) {}
|
: HashTable(initialSize) {}
|
||||||
|
|
||||||
MultiHashTable(typename Definition::ParentType *parent,
|
MultiHashTable(const Definition& definition,
|
||||||
size_t initialSize = HashTable::kMinimumSize)
|
size_t initialSize = HashTable::kMinimumSize)
|
||||||
: HashTable(parent, initialSize) {}
|
: HashTable(definition, initialSize) {}
|
||||||
|
|
||||||
status_t InitCheck() const { return HashTable::InitCheck(); }
|
status_t InitCheck() const { return HashTable::InitCheck(); }
|
||||||
|
|
||||||
@@ -174,4 +174,4 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _KERNEL_UTIL_MULTI_HASH_TABLE_H
|
||||||
|
|||||||
@@ -5,36 +5,37 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Hugo Santos, [email protected]
|
* Hugo Santos, [email protected]
|
||||||
*/
|
*/
|
||||||
|
#ifndef _KERNEL_UTIL_OPEN_HASH_TABLE_H
|
||||||
|
#define _KERNEL_UTIL_OPEN_HASH_TABLE_H
|
||||||
|
|
||||||
|
|
||||||
#ifndef _OPEN_HASH_TABLE_H_
|
|
||||||
#define _OPEN_HASH_TABLE_H_
|
|
||||||
|
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
|
|
||||||
// the Definition template must have four methods: `HashKey', `Hash',
|
|
||||||
// `Compare' and `GetLink;. It must also define several types as shown in the
|
/*!
|
||||||
// following example:
|
The Definition template must have four methods: `HashKey', `Hash',
|
||||||
//
|
`Compare' and `GetLink;. It must also define several types as shown in the
|
||||||
// struct Foo : HashTableLink<Foo> {
|
following example:
|
||||||
// int bar;
|
|
||||||
//
|
struct Foo : HashTableLink<Foo> {
|
||||||
// HashTableLink<Foo> otherLink;
|
int bar;
|
||||||
// };
|
|
||||||
//
|
HashTableLink<Foo> otherLink;
|
||||||
// struct HashTableDefinition {
|
};
|
||||||
// typedef void ParentType;
|
|
||||||
// typedef int KeyType;
|
struct HashTableDefinition {
|
||||||
// typedef Foo ValueType;
|
typedef int KeyType;
|
||||||
//
|
typedef Foo ValueType;
|
||||||
// HashTableDefinition(void *parent) {}
|
|
||||||
//
|
HashTableDefinition(const HashTableDefinition&) {}
|
||||||
// size_t HashKey(int key) const { return key >> 1; }
|
|
||||||
// size_t Hash(Foo *value) const { return HashKey(value->bar); }
|
size_t HashKey(int key) const { return key >> 1; }
|
||||||
// bool Compare(int key, Foo *value) const { return value->bar == key; }
|
size_t Hash(Foo *value) const { return HashKey(value->bar); }
|
||||||
// HashTableLink<Foo> *GetLink(Foo *value) const { return value; }
|
bool Compare(int key, Foo *value) const { return value->bar == key; }
|
||||||
// };
|
HashTableLink<Foo> *GetLink(Foo *value) const { return value; }
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
struct HashTableLink {
|
struct HashTableLink {
|
||||||
@@ -59,15 +60,22 @@ public:
|
|||||||
// 50 / 256 = 19.53125%
|
// 50 / 256 = 19.53125%
|
||||||
|
|
||||||
OpenHashTable(size_t initialSize = kMinimumSize)
|
OpenHashTable(size_t initialSize = kMinimumSize)
|
||||||
: fTableSize(0), fItemCount(0), fTable(NULL)
|
:
|
||||||
|
fTableSize(0),
|
||||||
|
fItemCount(0),
|
||||||
|
fTable(NULL)
|
||||||
{
|
{
|
||||||
if (initialSize > 0)
|
if (initialSize > 0)
|
||||||
_Resize(initialSize);
|
_Resize(initialSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenHashTable(typename Definition::ParentType *parent,
|
OpenHashTable(const Definition& definition,
|
||||||
size_t initialSize = kMinimumSize)
|
size_t initialSize = kMinimumSize)
|
||||||
: fDefinition(parent), fTableSize(0), fItemCount(0), fTable(NULL)
|
:
|
||||||
|
fDefinition(definition),
|
||||||
|
fTableSize(0),
|
||||||
|
fItemCount(0),
|
||||||
|
fTable(NULL)
|
||||||
{
|
{
|
||||||
if (initialSize > 0)
|
if (initialSize > 0)
|
||||||
_Resize(initialSize);
|
_Resize(initialSize);
|
||||||
@@ -273,4 +281,4 @@ protected:
|
|||||||
ValueType **fTable;
|
ValueType **fTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _KERNEL_UTIL_OPEN_HASH_TABLE_H
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ typedef MulticastGroupInterface<IPv4Multicast> IPv4GroupInterface;
|
|||||||
typedef MulticastFilter<IPv4Multicast> IPv4MulticastFilter;
|
typedef MulticastFilter<IPv4Multicast> IPv4MulticastFilter;
|
||||||
|
|
||||||
struct MulticastStateHash {
|
struct MulticastStateHash {
|
||||||
typedef void ParentType;
|
|
||||||
typedef std::pair<const in_addr *, uint32> KeyType;
|
typedef std::pair<const in_addr *, uint32> KeyType;
|
||||||
typedef IPv4GroupInterface ValueType;
|
typedef IPv4GroupInterface ValueType;
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Hugo Santos, [email protected]
|
* Hugo Santos, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PRIVATE_MULTICAST_H_
|
#ifndef _PRIVATE_MULTICAST_H_
|
||||||
#define _PRIVATE_MULTICAST_H_
|
#define _PRIVATE_MULTICAST_H_
|
||||||
|
|
||||||
|
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
struct net_buffer;
|
struct net_buffer;
|
||||||
struct net_protocol;
|
struct net_protocol;
|
||||||
|
|
||||||
@@ -164,7 +165,6 @@ public:
|
|||||||
bool FilterAccepts(net_buffer *buffer) const;
|
bool FilterAccepts(net_buffer *buffer) const;
|
||||||
|
|
||||||
struct HashDefinition {
|
struct HashDefinition {
|
||||||
typedef void ParentType;
|
|
||||||
typedef std::pair<const AddressType *, uint32> KeyType;
|
typedef std::pair<const AddressType *, uint32> KeyType;
|
||||||
typedef ThisType ValueType;
|
typedef ThisType ValueType;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
|
* Hugo Santos, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +31,11 @@ static const uint16 kFirstEphemeralPort = 40000;
|
|||||||
|
|
||||||
|
|
||||||
ConnectionHashDefinition::ConnectionHashDefinition(EndpointManager *manager)
|
ConnectionHashDefinition::ConnectionHashDefinition(EndpointManager *manager)
|
||||||
: fManager(manager) {}
|
:
|
||||||
|
fManager(manager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ConnectionHashDefinition::HashKey(const KeyType &key) const
|
ConnectionHashDefinition::HashKey(const KeyType &key) const
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
|
* Hugo Santos, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef ENDPOINT_MANAGER_H
|
#ifndef ENDPOINT_MANAGER_H
|
||||||
#define ENDPOINT_MANAGER_H
|
#define ENDPOINT_MANAGER_H
|
||||||
|
|
||||||
|
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
|
|
||||||
#include <AddressUtilities.h>
|
#include <AddressUtilities.h>
|
||||||
@@ -27,12 +29,16 @@ class TCPEndpoint;
|
|||||||
|
|
||||||
struct ConnectionHashDefinition {
|
struct ConnectionHashDefinition {
|
||||||
public:
|
public:
|
||||||
typedef EndpointManager ParentType;
|
|
||||||
typedef std::pair<const sockaddr *, const sockaddr *> KeyType;
|
typedef std::pair<const sockaddr *, const sockaddr *> KeyType;
|
||||||
typedef TCPEndpoint ValueType;
|
typedef TCPEndpoint ValueType;
|
||||||
|
|
||||||
ConnectionHashDefinition(EndpointManager *manager);
|
ConnectionHashDefinition(EndpointManager *manager);
|
||||||
|
|
||||||
|
ConnectionHashDefinition(const ConnectionHashDefinition& definition)
|
||||||
|
: fManager(definition.fManager)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
size_t HashKey(const KeyType &key) const;
|
size_t HashKey(const KeyType &key) const;
|
||||||
size_t Hash(TCPEndpoint *endpoint) const;
|
size_t Hash(TCPEndpoint *endpoint) const;
|
||||||
bool Compare(const KeyType &key, TCPEndpoint *endpoint) const;
|
bool Compare(const KeyType &key, TCPEndpoint *endpoint) const;
|
||||||
@@ -45,7 +51,6 @@ private:
|
|||||||
|
|
||||||
class EndpointHashDefinition {
|
class EndpointHashDefinition {
|
||||||
public:
|
public:
|
||||||
typedef EndpointManager ParentType;
|
|
||||||
typedef uint16 KeyType;
|
typedef uint16 KeyType;
|
||||||
typedef TCPEndpoint ValueType;
|
typedef TCPEndpoint ValueType;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Andrew Galante, [email protected]
|
* Andrew Galante, [email protected]
|
||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
|
* Hugo Santos, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef TCP_ENDPOINT_H
|
#ifndef TCP_ENDPOINT_H
|
||||||
#define TCP_ENDPOINT_H
|
#define TCP_ENDPOINT_H
|
||||||
@@ -14,7 +15,6 @@
|
|||||||
#include "EndpointManager.h"
|
#include "EndpointManager.h"
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
|
|
||||||
|
|
||||||
#include <ProtocolUtilities.h>
|
#include <ProtocolUtilities.h>
|
||||||
#include <net_protocol.h>
|
#include <net_protocol.h>
|
||||||
#include <net_stack.h>
|
#include <net_stack.h>
|
||||||
|
|||||||
@@ -115,8 +115,10 @@ struct UdpHashDefinition {
|
|||||||
typedef std::pair<const sockaddr *, const sockaddr *> KeyType;
|
typedef std::pair<const sockaddr *, const sockaddr *> KeyType;
|
||||||
typedef UdpEndpoint ValueType;
|
typedef UdpEndpoint ValueType;
|
||||||
|
|
||||||
UdpHashDefinition(net_address_module_info *parent)
|
UdpHashDefinition(net_address_module_info *_module)
|
||||||
: module(parent) {}
|
: module(_module) {}
|
||||||
|
UdpHashDefinition(const UdpHashDefinition& definition)
|
||||||
|
: module(definition.module) {}
|
||||||
|
|
||||||
size_t HashKey(const KeyType &key) const
|
size_t HashKey(const KeyType &key) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ struct HashedObjectCache : object_cache {
|
|||||||
typedef Link ValueType;
|
typedef Link ValueType;
|
||||||
|
|
||||||
Definition(HashedObjectCache *_parent) : parent(_parent) {}
|
Definition(HashedObjectCache *_parent) : parent(_parent) {}
|
||||||
|
Definition(const Definition& definition) : parent(definition.parent) {}
|
||||||
|
|
||||||
size_t HashKey(const void *key) const
|
size_t HashKey(const void *key) const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user