2 * Copyright 2011, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #ifndef TEAM_MEMORY_BLOCK_H
6 #define TEAM_MEMORY_BLOCK_H
12 #include <Referenceable.h>
13 #include <util/DoublyLinkedList.h>
18 class TeamMemoryBlockOwner
;
21 class TeamMemoryBlock
: public BReferenceable
,
22 public DoublyLinkedListLinkImpl
<TeamMemoryBlock
> {
27 TeamMemoryBlock(target_addr_t baseAddress
,
28 TeamMemoryBlockOwner
* owner
);
31 void AddListener(Listener
* listener
);
32 bool HasListener(Listener
* listener
);
33 void RemoveListener(Listener
* listener
);
35 bool IsValid() const { return fValid
; };
39 target_addr_t
BaseAddress() const { return fBaseAddress
; };
40 uint8
* Data() { return fData
; };
41 size_t Size() const { return sizeof(fData
); };
42 bool Contains(target_addr_t address
) const;
44 bool IsWritable() const { return fWritable
; }
45 void SetWritable(bool writable
);
47 void NotifyDataRetrieved(status_t result
= B_OK
);
50 virtual void LastReferenceReleased();
53 typedef DoublyLinkedList
<Listener
> ListenerList
;
58 target_addr_t fBaseAddress
;
59 uint8 fData
[B_PAGE_SIZE
];
60 ListenerList fListeners
;
67 class TeamMemoryBlock::Listener
: public DoublyLinkedListLinkImpl
<Listener
> {
71 virtual void MemoryBlockRetrieved(TeamMemoryBlock
* block
);
73 virtual void MemoryBlockRetrievalFailed(TeamMemoryBlock
* block
,
78 #endif // TEAM_MEMORY_BLOCK_H