git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-01-03 09:23:08 +00:00
parent a31ddcb397
commit 5edcfe9619
17 changed files with 661 additions and 958 deletions
+46 -105
View File
@@ -1,128 +1,69 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Invoker.h
// Author: Frans van Nispen ([email protected])
// Description: BInvoker class defines a protocol for objects that
// post messages to a "target".
//------------------------------------------------------------------------------
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Frans van Nispen ([email protected])
*/
#ifndef _INVOKER_H
#define _INVOKER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Messenger.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
class BMessage;
// BInvoker class --------------------------------------------------------------
class BInvoker {
public:
BInvoker();
BInvoker(BMessage *message,
const BHandler *handler,
const BLooper *looper = NULL);
BInvoker(BMessage *message, BMessenger target);
virtual ~BInvoker();
public:
BInvoker();
BInvoker(BMessage* message, const BHandler* handler,
const BLooper* looper = NULL);
BInvoker(BMessage* message, BMessenger target);
virtual ~BInvoker();
virtual status_t SetMessage(BMessage *message);
BMessage *Message() const;
uint32 Command() const;
virtual status_t SetMessage(BMessage *message);
BMessage* Message() const;
uint32 Command() const;
virtual status_t SetTarget(const BHandler *h, const BLooper *loop = NULL);
virtual status_t SetTarget(BMessenger messenger);
bool IsTargetLocal() const;
BHandler *Target(BLooper **looper = NULL) const;
BMessenger Messenger() const;
virtual status_t SetTarget(const BHandler *handler,
const BLooper *looper = NULL);
virtual status_t SetTarget(BMessenger messenger);
bool IsTargetLocal() const;
BHandler* Target(BLooper** _looper = NULL) const;
BMessenger Messenger() const;
virtual status_t SetHandlerForReply(BHandler *handler);
BHandler *HandlerForReply() const;
virtual status_t SetHandlerForReply(BHandler* handler);
BHandler* HandlerForReply() const;
virtual status_t Invoke(BMessage *msg = NULL);
// Invoke with BHandler notification. Use this to perform an
// Invoke() with some other kind of notification change code.
// (A raw invoke should always notify as B_CONTROL_INVOKED.)
// Unlike a raw Invoke(), there is no standard message that is
// sent. If 'msg' is NULL, then nothing will be sent to this
// invoker's target... however, a notification message will
// still be sent to any watchers of the invoker's handler.
// Note that the BInvoker class does not actually implement
// any of this behavior -- it is up to subclasses to override
// Invoke() and call Notify() with the appropriate change code.
status_t InvokeNotify(BMessage *msg, uint32 kind = B_CONTROL_INVOKED);
status_t SetTimeout(bigtime_t timeout);
bigtime_t Timeout() const;
virtual status_t Invoke(BMessage* message = NULL);
status_t InvokeNotify(BMessage* message,
uint32 kind = B_CONTROL_INVOKED);
status_t SetTimeout(bigtime_t timeout);
bigtime_t Timeout() const;
protected:
// Return the change code for a notification. This is either
// B_CONTROL_INVOKED for raw Invoke() calls, or the kind
// supplied to InvokeNotify(). In addition, 'notify' will be
// set to true if this was an InvokeNotify() call, else false.
uint32 InvokeKind(bool* notify = NULL);
protected:
uint32 InvokeKind(bool* _notify = NULL);
void BeginInvokeNotify(uint32 kind = B_CONTROL_INVOKED);
void EndInvokeNotify();
// Start and end an InvokeNotify context around an Invoke() call.
// These are only needed for writing custom methods that
// emulate the standard InvokeNotify() call.
void BeginInvokeNotify(uint32 kind = B_CONTROL_INVOKED);
void EndInvokeNotify();
private:
virtual void _ReservedInvoker1();
virtual void _ReservedInvoker2();
virtual void _ReservedInvoker3();
// Private or reserved ---------------------------------------------------------
private:
// to be able to keep binary compatibility
virtual void _ReservedInvoker1();
virtual void _ReservedInvoker2();
virtual void _ReservedInvoker3();
BInvoker(const BInvoker&);
BInvoker& operator=(const BInvoker&);
BInvoker(const BInvoker&);
BInvoker &operator=(const BInvoker&);
BMessage *fMessage;
BMessenger fMessenger;
BHandler *fReplyTo;
bigtime_t fTimeout;
uint32 fNotifyKind;
uint32 _reserved[1]; // to be able to keep binary compatibility
BMessage* fMessage;
BMessenger fMessenger;
BHandler* fReplyTo;
bigtime_t fTimeout;
uint32 fNotifyKind;
uint32 _reserved[1];
};
//------------------------------------------------------------------------------
#endif // _INVOKER_H
/*
* $Log $
*
* $Id $
*
*/
+41 -82
View File
@@ -1,46 +1,17 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: MessageFilter.h
// Author: Erik Jaesler ([email protected])
// Description: BMessageFilter class creates objects that filter
// in-coming BMessages.
//------------------------------------------------------------------------------
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Erik Jaesler ([email protected])
*/
#ifndef _MESSAGE_FILTER_H
#define _MESSAGE_FILTER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
@@ -67,60 +38,48 @@ enum message_source {
B_LOCAL_SOURCE
};
// BMessageFilter Class --------------------------------------------------------
class BMessageFilter {
public:
BMessageFilter(uint32 what,
filter_hook func = NULL);
BMessageFilter(message_delivery delivery,
message_source source, filter_hook func = NULL);
BMessageFilter(message_delivery delivery,
message_source source, uint32 what,
filter_hook func = NULL);
BMessageFilter(const BMessageFilter& filter);
BMessageFilter(const BMessageFilter* filter);
virtual ~BMessageFilter();
public:
BMessageFilter( uint32 what,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
uint32 what,
filter_hook func = NULL);
BMessageFilter(const BMessageFilter& filter);
BMessageFilter(const BMessageFilter* filter);
virtual ~BMessageFilter();
BMessageFilter& operator=(const BMessageFilter& from);
BMessageFilter &operator=(const BMessageFilter& from);
// Hook function; ignored if filter_hook is non-NULL
virtual filter_result Filter(BMessage* message, BHandler** _target);
// Hook function; ignored if filter_hook is non-NULL
virtual filter_result Filter(BMessage* message, BHandler** target);
message_delivery MessageDelivery() const;
message_source MessageSource() const;
uint32 Command() const;
bool FiltersAnyCommand() const;
BLooper* Looper() const;
message_delivery MessageDelivery() const;
message_source MessageSource() const;
uint32 Command() const;
bool FiltersAnyCommand() const;
BLooper *Looper() const;
private:
friend class BLooper;
friend class BHandler;
// Private or reserved ---------------------------------------------------------
private:
friend class BLooper;
friend class BHandler;
virtual void _ReservedMessageFilter1();
virtual void _ReservedMessageFilter2();
virtual void _ReservedMessageFilter1();
virtual void _ReservedMessageFilter2();
void SetLooper(BLooper* owner);
filter_hook FilterFunction() const;
bool fFiltersAny;
uint32 what;
message_delivery fDelivery;
message_source fSource;
BLooper *fLooper;
filter_hook fFilterFunction;
uint32 _reserved[3];
void SetLooper(BLooper* owner);
filter_hook FilterFunction() const;
bool fFiltersAny;
uint32 fWhat;
message_delivery fDelivery;
message_source fSource;
BLooper *fLooper;
filter_hook fFilterFunction;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _MESSAGE_FILTER_H
/*
* $Log $
*
* $Id $
*
*/