From e492be31954f5435ccdf2d364fc7b0a18493340a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 17 Nov 2010 23:23:09 +0000 Subject: [PATCH] Added versions of the constructors that take a const BMessage& instead of a pointer. Allows for passing a temporary object. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39472 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/app/MessageRunner.h | 6 ++++ src/kits/app/MessageRunner.cpp | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/headers/os/app/MessageRunner.h b/headers/os/app/MessageRunner.h index 63bff5e21f..9e492b366f 100644 --- a/headers/os/app/MessageRunner.h +++ b/headers/os/app/MessageRunner.h @@ -14,9 +14,15 @@ public: BMessageRunner(BMessenger target, const BMessage* message, bigtime_t interval, int32 count = -1); + BMessageRunner(BMessenger target, + const BMessage& message, bigtime_t interval, + int32 count = -1); BMessageRunner(BMessenger target, const BMessage* message, bigtime_t interval, int32 count, BMessenger replyTo); + BMessageRunner(BMessenger target, + const BMessage& message, bigtime_t interval, + int32 count, BMessenger replyTo); virtual ~BMessageRunner(); status_t InitCheck() const; diff --git a/src/kits/app/MessageRunner.cpp b/src/kits/app/MessageRunner.cpp index 033d8e11b4..3464f85fc5 100644 --- a/src/kits/app/MessageRunner.cpp +++ b/src/kits/app/MessageRunner.cpp @@ -47,6 +47,34 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message, } +/*! \brief Creates and initializes a new BMessageRunner. + + The target for replies to the delivered message(s) is \c be_app_messenger. + + The success of the initialization can (and should) be asked for via + InitCheck(). This object will not take ownership of the \a message, you + may freely change or delete it after creation. + + \note As soon as the last message has been sent, the message runner + becomes unusable. InitCheck() will still return \c B_OK, but + SetInterval(), SetCount() and GetInfo() will fail. + + \param target Target of the message(s). + \param message The message to be sent to the target. + \param interval Period of time before the first message is sent and + between messages (if more than one shall be sent) in microseconds. + \param count Specifies how many times the message shall be sent. + A value less than \c 0 for an unlimited number of repetitions. +*/ +BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message, + bigtime_t interval, int32 count) + : + fToken(-1) +{ + _InitData(target, &message, interval, count, be_app_messenger); +} + + /*! \brief Creates and initializes a new BMessageRunner. This constructor version additionally allows to specify the target for @@ -77,6 +105,36 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message, } +/*! \brief Creates and initializes a new BMessageRunner. + + This constructor version additionally allows to specify the target for + replies to the delivered message(s). + + The success of the initialization can (and should) be asked for via + InitCheck(). This object will not take ownership of the \a message, you + may freely change or delete it after creation. + + \note As soon as the last message has been sent, the message runner + becomes unusable. InitCheck() will still return \c B_OK, but + SetInterval(), SetCount() and GetInfo() will fail. + + \param target Target of the message(s). + \param message The message to be sent to the target. + \param interval Period of time before the first message is sent and + between messages (if more than one shall be sent) in microseconds. + \param count Specifies how many times the message shall be sent. + A value less than \c 0 for an unlimited number of repetitions. + \param replyTo Target replies to the delivered message(s) shall be sent to. +*/ +BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message, + bigtime_t interval, int32 count, BMessenger replyTo) + : + fToken(-1) +{ + _InitData(target, &message, interval, count, replyTo); +} + + /*! \brief Frees all resources associated with the object. */ BMessageRunner::~BMessageRunner()