xref: /haiku/headers/os/app/MessageRunner.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 //------------------------------------------------------------------------------
2 //	Copyright (c) 2001-2002, OpenBeOS
3 //
4 //	Permission is hereby granted, free of charge, to any person obtaining a
5 //	copy of this software and associated documentation files (the "Software"),
6 //	to deal in the Software without restriction, including without limitation
7 //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 //	and/or sell copies of the Software, and to permit persons to whom the
9 //	Software is furnished to do so, subject to the following conditions:
10 //
11 //	The above copyright notice and this permission notice shall be included in
12 //	all copies or substantial portions of the Software.
13 //
14 //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 //	DEALINGS IN THE SOFTWARE.
21 //
22 //	File Name:		MessageRunner.h
23 //	Author:			Ingo Weinhold (bonefish@users.sf.net)
24 //	Description:	A BMessageRunner periodically sends a message to a
25 //                  specified target.
26 //------------------------------------------------------------------------------
27 #ifndef _MESSAGE_RUNNER_H
28 #define _MESSAGE_RUNNER_H
29 
30 #include <Messenger.h>
31 
32 class BMessageRunner {
33 public:
34 	BMessageRunner(BMessenger target, const BMessage *message,
35 				   bigtime_t interval, int32 count = -1);
36 	BMessageRunner(BMessenger target, const BMessage *message,
37 				   bigtime_t interval, int32 count, BMessenger replyTo);
38 	virtual ~BMessageRunner();
39 
40 	status_t InitCheck() const;
41 
42 	status_t SetInterval(bigtime_t interval);
43 	status_t SetCount(int32 count);
44 	status_t GetInfo(bigtime_t *interval, int32 *count) const;
45 
46 
47 private:
48 	BMessageRunner(const BMessageRunner &);
49 	BMessageRunner &operator=(const BMessageRunner &);
50 
51 	void InitData(BMessenger target, const BMessage *message,
52 				  bigtime_t interval, int32 count, BMessenger replyTo);
53 	status_t SetParams(bool resetInterval, bigtime_t interval, bool resetCount,
54 					   int32 count);
55 
56 	virtual void _ReservedMessageRunner1();
57 	virtual void _ReservedMessageRunner2();
58 	virtual void _ReservedMessageRunner3();
59 	virtual void _ReservedMessageRunner4();
60 	virtual void _ReservedMessageRunner5();
61 	virtual void _ReservedMessageRunner6();
62 
63 	int32	fToken;
64 	uint32	_reserved[6];
65 };
66 
67 #endif	// _MESSAGE_RUNNER_H
68