Got rid of that unused and superfluous TokenSpace callback stuff.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17200 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-04-22 16:29:44 +00:00
parent 9b2a903688
commit 704c03b9e6
3 changed files with 9 additions and 26 deletions
+4 -10
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -30,23 +30,17 @@
namespace BPrivate { namespace BPrivate {
typedef void (*new_token_callback)(int16, void*);
typedef void (*remove_token_callback)(int16, void*);
typedef bool (*get_token_callback)(int16, void*);
class BTokenSpace : public BLocker { class BTokenSpace : public BLocker {
public: public:
BTokenSpace(); BTokenSpace();
~BTokenSpace(); ~BTokenSpace();
int32 NewToken(int16 type, void* object, int32 NewToken(int16 type, void* object);
new_token_callback callback = NULL);
void SetToken(int32 token, int16 type, void* object); void SetToken(int32 token, int16 type, void* object);
bool RemoveToken(int32 token, remove_token_callback callback = NULL); bool RemoveToken(int32 token);
bool CheckToken(int32 token, int16 type) const; bool CheckToken(int32 token, int16 type) const;
status_t GetToken(int32 token, int16 type, void** object, status_t GetToken(int32 token, int16 type, void** object) const;
get_token_callback callback = NULL) const;
private: private:
struct token_info { struct token_info {
+4 -15
View File
@@ -35,8 +35,7 @@ BTokenSpace::~BTokenSpace()
int32 int32
BTokenSpace::NewToken(int16 type, void* object, BTokenSpace::NewToken(int16 type, void* object)
new_token_callback callback)
{ {
BAutolock locker(this); BAutolock locker(this);
@@ -45,9 +44,6 @@ BTokenSpace::NewToken(int16 type, void* object,
fTokenMap[token] = tokenInfo; fTokenMap[token] = tokenInfo;
if (callback)
callback(type, object);
return token; return token;
} }
@@ -62,8 +58,8 @@ void
BTokenSpace::SetToken(int32 token, int16 type, void* object) BTokenSpace::SetToken(int32 token, int16 type, void* object)
{ {
BAutolock locker(this); BAutolock locker(this);
token_info tokenInfo = { type, object };
token_info tokenInfo = { type, object };
fTokenMap[token] = tokenInfo; fTokenMap[token] = tokenInfo;
// this makes sure SetToken() plays more or less nice with NewToken() // this makes sure SetToken() plays more or less nice with NewToken()
@@ -73,7 +69,7 @@ BTokenSpace::SetToken(int32 token, int16 type, void* object)
bool bool
BTokenSpace::RemoveToken(int32 token, remove_token_callback callback) BTokenSpace::RemoveToken(int32 token)
{ {
BAutolock locker(this); BAutolock locker(this);
@@ -81,9 +77,6 @@ BTokenSpace::RemoveToken(int32 token, remove_token_callback callback)
if (iterator == fTokenMap.end()) if (iterator == fTokenMap.end())
return false; return false;
if (callback)
callback(iterator->second.type, iterator->second.object);
fTokenMap.erase(iterator); fTokenMap.erase(iterator);
return true; return true;
} }
@@ -106,8 +99,7 @@ BTokenSpace::CheckToken(int32 token, int16 type) const
status_t status_t
BTokenSpace::GetToken(int32 token, int16 type, void** _object, BTokenSpace::GetToken(int32 token, int16 type, void** _object) const
get_token_callback callback) const
{ {
BAutolock locker(const_cast<BTokenSpace&>(*this)); BAutolock locker(const_cast<BTokenSpace&>(*this));
@@ -119,9 +111,6 @@ BTokenSpace::GetToken(int32 token, int16 type, void** _object,
if (iterator == fTokenMap.end() || iterator->second.type != type) if (iterator == fTokenMap.end() || iterator->second.type != type)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
if (callback && !callback(iterator->second.type, iterator->second.object))
return B_ENTRY_NOT_FOUND;
*_object = iterator->second.object; *_object = iterator->second.object;
return B_OK; return B_OK;
} }
+1 -1
View File
@@ -490,7 +490,7 @@ BMenuBar::RestoreFocus()
if (window != NULL && window->Lock()) { if (window != NULL && window->Lock()) {
BHandler *handler = NULL; BHandler *handler = NULL;
if (BPrivate::gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, if (BPrivate::gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN,
(void **)&handler, NULL) == B_OK) { (void **)&handler) == B_OK) {
BView *view = dynamic_cast<BView *>(handler); BView *view = dynamic_cast<BView *>(handler);
if (view != NULL && view->Window() == window) if (view != NULL && view->Window() == window)
view->MakeFocus(); view->MakeFocus();