Cleanup. Added BTokenSpace::GetList(), though it's probably not needed after all

(we can still remove it later if needed).
Added B_SERVER_TOKEN type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13451 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-07-05 17:22:35 +00:00
parent 2e6a5805ba
commit ef571f678c
2 changed files with 50 additions and 38 deletions
+25 -33
View File
@@ -1,31 +1,32 @@
//------------------------------------------------------------------------------
// TokenSpace.h
//
//------------------------------------------------------------------------------
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Erik Jaesler ([email protected])
* Axel Dörfler, [email protected]
*/
#ifndef _TOKEN_SPACE_H
#define _TOKEN_SPACE_H
#ifndef TOKENSPACE_H
#define TOKENSPACE_H
// Standard Includes -----------------------------------------------------------
#include <map>
#include <stack>
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Locker.h>
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// token types as specified in targets
#define B_PREFERRED_TOKEN -2 /* A little bird told me about this one */
#define B_NULL_TOKEN -1
#define B_ANY_TOKEN 0
#define B_HANDLER_TOKEN 1
// Globals ---------------------------------------------------------------------
// token types in the token list
#define B_HANDLER_TOKEN 1
#define B_SERVER_TOKEN 2
namespace BPrivate {
@@ -33,19 +34,20 @@ typedef void (*new_token_callback)(int16, void*);
typedef void (*remove_token_callback)(int16, void*);
typedef bool (*get_token_callback)(int16, void*);
class BTokenSpace
{
class BTokenSpace : public BLocker {
public:
BTokenSpace();
~BTokenSpace();
int32 NewToken(int16 type, void* object,
new_token_callback callback= NULL);
new_token_callback callback = NULL);
bool RemoveToken(int32 token, remove_token_callback callback = NULL);
bool CheckToken(int32, int16) const;
status_t GetToken(int32, int16, void**,
bool CheckToken(int32 token, int16 type) const;
status_t GetToken(int32 token, int16 type, void** object,
get_token_callback callback = NULL) const;
status_t GetList(int32*& tokens, int32& count) const;
// Possible expansion
// void Dump(BDataIO&, bool) const;
// int32 NewToken(void*, BDirectMessageTarget*, void (*)(short, void*));
@@ -53,10 +55,9 @@ class BTokenSpace
// BDirectMessageTarget* TokenTarget(uint32 token, int16 type);
private:
struct TTokenInfo
{
int16 type;
void* object;
struct TTokenInfo {
int16 type;
void* object;
};
typedef std::map<int32, TTokenInfo> TTokenMap;
@@ -64,7 +65,6 @@ class BTokenSpace
TTokenMap fTokenMap;
std::stack<int32> fTokenBin;
int32 fTokenCount;
BLocker fLocker;
};
// Possible expansion
@@ -79,12 +79,4 @@ extern _IMPEXP_BE BTokenSpace gDefaultTokens;
} // namespace BPrivate
#endif //TOKENSPACE_H
/*
* $Log $
*
* $Id $
*
*/
#endif // _TOKEN_SPACE_H