xref: /haiku/src/tests/add-ons/kernel/file_systems/bfs/btree/Journal.h (revision 579f1dbca962a2a03df54f69fdc6e9423f91f20e)
1 #ifndef JOURNAL_H
2 #define JOURNAL_H
3 /* Journal - emulation for the B+Tree torture test
4 **
5 ** Initial version by Axel Dörfler, axeld@pinc-software.de
6 ** This file may be used under the terms of the OpenBeOS License.
7 */
8 
9 
10 #include <stdio.h>
11 
12 #include "Volume.h"
13 #include "Debug.h"
14 #include "Utility.h"
15 
16 #include "cache.h"
17 
18 
19 class TransactionListener
20 	: public DoublyLinkedListLinkImpl<TransactionListener> {
21 public:
22 								TransactionListener();
23 	virtual						~TransactionListener();
24 
25 	virtual void				TransactionDone(bool success) = 0;
26 	virtual void				RemovedFromTransaction() = 0;
27 };
28 
29 typedef DoublyLinkedList<TransactionListener> TransactionListeners;
30 
31 
32 class Transaction {
33 	public:
34 		Transaction(Volume *volume,off_t refBlock)
35 			:
36 			fVolume(volume)
37 		{
38 		}
39 
40 		~Transaction()
41 		{
42 		}
43 
44 		status_t WriteBlocks(off_t blockNumber,const uint8 *buffer,size_t numBlocks = 1)
45 		{
46 			return cached_write(fVolume->Device(),blockNumber,buffer,numBlocks,fVolume->BlockSize());
47 		}
48 
49 		void Done()
50 		{
51 		}
52 
53 	protected:
54 		Volume	*fVolume;
55 };
56 
57 
58 #endif	/* JOURNAL_H */
59