2005-07-05 21:22:35 +04:00
|
|
|
/*
|
2011-10-30 01:04:22 +04:00
|
|
|
* Copyright 2001-2011, Haiku.
|
2005-07-05 21:22:35 +04:00
|
|
|
* 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
|
|
|
|
|
|
|
|
2007-01-26 16:59:56 +03:00
|
|
|
#include <map>
|
|
|
|
#include <stack>
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
#include <Locker.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
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 {
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2007-01-26 16:59:56 +03:00
|
|
|
class BDirectMessageTarget;
|
|
|
|
|
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
class BTokenSpace : public BLocker {
|
2011-10-30 01:04:22 +04:00
|
|
|
public:
|
|
|
|
BTokenSpace();
|
|
|
|
~BTokenSpace();
|
|
|
|
|
|
|
|
int32 NewToken(int16 type, void* object);
|
|
|
|
bool SetToken(int32 token, int16 type, void* object);
|
|
|
|
|
|
|
|
bool RemoveToken(int32 token);
|
|
|
|
bool CheckToken(int32 token, int16 type) const;
|
|
|
|
status_t GetToken(int32 token, int16 type,
|
|
|
|
void** _object) const;
|
|
|
|
|
|
|
|
status_t SetHandlerTarget(int32 token,
|
|
|
|
BDirectMessageTarget* target);
|
|
|
|
status_t AcquireHandlerTarget(int32 token,
|
|
|
|
BDirectMessageTarget** _target);
|
|
|
|
|
2011-10-30 01:17:59 +04:00
|
|
|
void InitAfterFork();
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
private:
|
|
|
|
struct token_info {
|
|
|
|
int16 type;
|
|
|
|
void* object;
|
|
|
|
BDirectMessageTarget* target;
|
|
|
|
};
|
|
|
|
typedef std::map<int32, token_info> TokenMap;
|
|
|
|
|
|
|
|
TokenMap fTokenMap;
|
|
|
|
int32 fTokenCount;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
extern BTokenSpace gDefaultTokens;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2011-10-30 01:04:22 +04:00
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
#endif // _TOKEN_SPACE_H
|