2006-06-14 22:31:15 +04:00
|
|
|
/*
|
2007-02-01 19:08:01 +03:00
|
|
|
* Copyright 2001-2007, Haiku Inc. All Rights Reserved.
|
2006-06-14 22:31:15 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Erik Jaesler (erik@cgsoftware.com)
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _HANDLER_H
|
|
|
|
#define _HANDLER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <Archivable.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BLooper;
|
|
|
|
class BMessageFilter;
|
|
|
|
class BMessage;
|
2007-10-16 00:13:55 +04:00
|
|
|
class BMessenger;
|
2002-07-09 16:24:59 +04:00
|
|
|
class BList;
|
|
|
|
|
|
|
|
#define B_OBSERVE_WHAT_CHANGE "be:observe_change_what"
|
|
|
|
#define B_OBSERVE_ORIGINAL_WHAT "be:observe_orig_what"
|
|
|
|
const uint32 B_OBSERVER_OBSERVE_ALL = 0xffffffff;
|
|
|
|
|
2007-02-01 19:08:01 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
class ObserverList;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-06-14 22:31:15 +04:00
|
|
|
class BHandler : public BArchivable {
|
2002-07-09 16:24:59 +04:00
|
|
|
public:
|
|
|
|
BHandler(const char* name = NULL);
|
|
|
|
virtual ~BHandler();
|
|
|
|
|
|
|
|
// Archiving
|
|
|
|
BHandler(BMessage* data);
|
|
|
|
static BArchivable* Instantiate(BMessage* data);
|
|
|
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
|
|
|
|
|
|
|
// BHandler guts.
|
|
|
|
virtual void MessageReceived(BMessage* message);
|
|
|
|
BLooper* Looper() const;
|
|
|
|
void SetName(const char* name);
|
|
|
|
const char* Name() const;
|
|
|
|
virtual void SetNextHandler(BHandler* handler);
|
|
|
|
BHandler* NextHandler() const;
|
|
|
|
|
|
|
|
// Message filtering
|
|
|
|
virtual void AddFilter(BMessageFilter* filter);
|
|
|
|
virtual bool RemoveFilter(BMessageFilter* filter);
|
|
|
|
virtual void SetFilterList(BList* filters);
|
|
|
|
BList* FilterList();
|
|
|
|
|
|
|
|
bool LockLooper();
|
|
|
|
status_t LockLooperWithTimeout(bigtime_t timeout);
|
|
|
|
void UnlockLooper();
|
|
|
|
|
|
|
|
// Scripting
|
2007-02-01 19:08:01 +03:00
|
|
|
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
|
|
|
|
BMessage* specifier, int32 form,
|
|
|
|
const char* property);
|
2002-07-09 16:24:59 +04:00
|
|
|
virtual status_t GetSupportedSuites(BMessage* data);
|
|
|
|
|
|
|
|
// Observer calls, inter-looper and inter-team
|
2007-02-01 19:08:01 +03:00
|
|
|
status_t StartWatching(BMessenger target, uint32 what);
|
|
|
|
status_t StartWatchingAll(BMessenger target);
|
|
|
|
status_t StopWatching(BMessenger target, uint32 what);
|
|
|
|
status_t StopWatchingAll(BMessenger target);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-02-01 19:08:01 +03:00
|
|
|
// Observer calls for observing targets in the local team
|
|
|
|
status_t StartWatching(BHandler* observer, uint32 what);
|
|
|
|
status_t StartWatchingAll(BHandler* observer);
|
|
|
|
status_t StopWatching(BHandler* observer, uint32 what);
|
|
|
|
status_t StopWatchingAll(BHandler* observer);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Reserved
|
|
|
|
virtual status_t Perform(perform_code d, void* arg);
|
|
|
|
|
|
|
|
// Notifier calls
|
2007-02-01 19:08:01 +03:00
|
|
|
virtual void SendNotices(uint32 what, const BMessage* notice = NULL);
|
2002-07-09 16:24:59 +04:00
|
|
|
bool IsWatched() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef BArchivable _inherited;
|
|
|
|
friend inline int32 _get_object_token_(const BHandler* );
|
|
|
|
friend class BLooper;
|
|
|
|
friend class BMessageFilter;
|
|
|
|
|
|
|
|
virtual void _ReservedHandler2();
|
|
|
|
virtual void _ReservedHandler3();
|
|
|
|
virtual void _ReservedHandler4();
|
|
|
|
|
2007-02-01 19:08:01 +03:00
|
|
|
void _InitData(const char* name);
|
|
|
|
BPrivate::ObserverList* _ObserverList();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
BHandler(const BHandler&);
|
|
|
|
BHandler& operator=(const BHandler&);
|
2007-02-01 19:08:01 +03:00
|
|
|
void SetLooper(BLooper* looper);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
int32 fToken;
|
|
|
|
char* fName;
|
|
|
|
BLooper* fLooper;
|
|
|
|
BHandler* fNextHandler;
|
|
|
|
BList* fFilters;
|
2007-02-01 19:08:01 +03:00
|
|
|
BPrivate::ObserverList* fObserverList;
|
2002-07-09 16:24:59 +04:00
|
|
|
uint32 _reserved[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _HANDLER_H
|