3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / kernel / file_systems / ext2 / Transaction.h
blob155d7fbb00570f701e73619e4a49891411b9e0e3
1 /*
2 * Copyright 2010, Haiku Inc. All rights reserved.
3 * Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de.
4 * This file may be used under the terms of the MIT License.
6 * Authors:
7 * Janito V. Ferreira Filho
8 */
9 #ifndef TRANSACTION_H
10 #define TRANSACTION_H
13 #include <util/DoublyLinkedList.h>
16 class Journal;
17 class Volume;
20 class TransactionListener
21 : public DoublyLinkedListLinkImpl<TransactionListener> {
22 public:
23 TransactionListener();
24 virtual ~TransactionListener();
26 virtual void TransactionDone(bool success) = 0;
27 virtual void RemovedFromTransaction() = 0;
30 typedef DoublyLinkedList<TransactionListener> TransactionListeners;
33 class Transaction {
34 public:
35 Transaction();
36 Transaction(Journal* journal);
37 ~Transaction();
39 status_t Start(Journal* journal);
40 status_t Done(bool success = true);
42 bool IsStarted() const;
43 bool HasParent() const;
45 status_t WriteBlocks(off_t blockNumber,
46 const uint8* buffer,
47 size_t numBlocks = 1);
49 void Split();
51 Volume* GetVolume() const;
52 int32 ID() const;
54 void AddListener(TransactionListener* listener);
55 void RemoveListener(
56 TransactionListener* listener);
58 void NotifyListeners(bool success);
59 void MoveListenersTo(Transaction* transaction);
61 void SetParent(Transaction* transaction);
62 Transaction* Parent() const;
63 private:
64 Transaction(const Transaction& other);
65 Transaction& operator=(const Transaction& other);
66 // no implementation
68 Journal* fJournal;
69 TransactionListeners fListeners;
70 Transaction* fParent;
73 #endif // TRANSACTION_H