2005-07-05 21:22:35 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2005, Haiku.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Erik Jaesler (erik@cgsoftware.com)
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
|
|
|
#ifndef _TOKEN_SPACE_H
|
|
|
|
#define _TOKEN_SPACE_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
#include <BeBuild.h>
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
// token types as specified in targets
|
2003-03-19 08:14:07 +03:00
|
|
|
#define B_PREFERRED_TOKEN -2 /* A little bird told me about this one */
|
2002-07-09 16:24:59 +04:00
|
|
|
#define B_NULL_TOKEN -1
|
|
|
|
#define B_ANY_TOKEN 0
|
2005-07-05 21:22:35 +04:00
|
|
|
|
|
|
|
// token types in the token list
|
2002-07-09 16:24:59 +04:00
|
|
|
#define B_HANDLER_TOKEN 1
|
2005-07-05 21:22:35 +04:00
|
|
|
#define B_SERVER_TOKEN 2
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
typedef void (*new_token_callback)(int16, void*);
|
|
|
|
typedef void (*remove_token_callback)(int16, void*);
|
|
|
|
typedef bool (*get_token_callback)(int16, void*);
|
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
class BTokenSpace : public BLocker {
|
2002-07-09 16:24:59 +04:00
|
|
|
public:
|
|
|
|
BTokenSpace();
|
|
|
|
~BTokenSpace();
|
|
|
|
|
|
|
|
int32 NewToken(int16 type, void* object,
|
2005-11-19 03:46:44 +03:00
|
|
|
new_token_callback callback = NULL);
|
2005-11-24 16:00:06 +03:00
|
|
|
void SetToken(int32 token, int16 type, void* object);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
bool RemoveToken(int32 token, remove_token_callback callback = NULL);
|
2005-07-05 21:22:35 +04:00
|
|
|
bool CheckToken(int32 token, int16 type) const;
|
|
|
|
status_t GetToken(int32 token, int16 type, void** object,
|
2005-11-19 03:46:44 +03:00
|
|
|
get_token_callback callback = NULL) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2005-11-19 03:46:44 +03:00
|
|
|
struct token_info {
|
2005-07-05 21:22:35 +04:00
|
|
|
int16 type;
|
|
|
|
void* object;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
2005-11-19 03:46:44 +03:00
|
|
|
typedef std::map<int32, token_info> TokenMap;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-19 03:46:44 +03:00
|
|
|
TokenMap fTokenMap;
|
|
|
|
int32 fTokenCount;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
extern _IMPEXP_BE BTokenSpace gDefaultTokens;
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
#endif // _TOKEN_SPACE_H
|