2005-07-05 21:22:35 +04:00
|
|
|
/*
|
2007-01-26 16:59:56 +03:00
|
|
|
* Copyright 2001-2007, 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
|
|
|
|
|
|
|
|
|
|
|
#include <BeBuild.h>
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
2007-01-26 16:59:56 +03:00
|
|
|
#include <map>
|
|
|
|
#include <stack>
|
|
|
|
|
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 {
|
|
|
|
|
2007-01-26 16:59:56 +03:00
|
|
|
class BDirectMessageTarget;
|
|
|
|
|
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
class BTokenSpace : public BLocker {
|
2002-07-09 16:24:59 +04:00
|
|
|
public:
|
|
|
|
BTokenSpace();
|
|
|
|
~BTokenSpace();
|
|
|
|
|
2006-04-22 20:29:44 +04:00
|
|
|
int32 NewToken(int16 type, void* object);
|
2009-11-04 15:19:59 +03:00
|
|
|
bool SetToken(int32 token, int16 type, void* object);
|
2005-11-24 16:00:06 +03:00
|
|
|
|
2006-04-22 20:29:44 +04:00
|
|
|
bool RemoveToken(int32 token);
|
2005-07-05 21:22:35 +04:00
|
|
|
bool CheckToken(int32 token, int16 type) const;
|
2007-01-26 16:59:56 +03:00
|
|
|
status_t GetToken(int32 token, int16 type, void** _object) const;
|
|
|
|
|
|
|
|
status_t SetHandlerTarget(int32 token, BDirectMessageTarget* target);
|
|
|
|
status_t AcquireHandlerTarget(int32 token, BDirectMessageTarget** _target);
|
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;
|
2007-01-26 16:59:56 +03:00
|
|
|
BDirectMessageTarget* target;
|
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
|
|
|
};
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
extern BTokenSpace gDefaultTokens;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
2005-07-05 21:22:35 +04:00
|
|
|
#endif // _TOKEN_SPACE_H
|