The DataEditor class is now subclasses from BLocker instead of aggregating

it. This way, it can directly be used in the BAutolock class, and also provides
some more sophisticated locking functions.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6621 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-02-18 02:31:48 +00:00
parent 8e900a6933
commit f7efc8f447
2 changed files with 13 additions and 36 deletions

View File

@ -136,31 +136,27 @@ ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
DataEditor::DataEditor()
:
fLock("data view")
: BLocker("data view")
{
}
DataEditor::DataEditor(entry_ref &ref, const char *attribute)
:
fLock("data view")
: BLocker("data view")
{
SetTo(ref, attribute);
}
DataEditor::DataEditor(BEntry &entry, const char *attribute)
:
fLock("data view")
: BLocker("data view")
{
SetTo(entry, attribute);
}
DataEditor::DataEditor(const DataEditor &editor)
:
fLock("data view")
: BLocker("data view")
{
}
@ -290,7 +286,7 @@ DataEditor::AddChange(DataChange *change)
status_t
DataEditor::Replace(off_t offset, const uint8 *data, size_t length)
{
if (!fLock.IsLocked())
if (!IsLocked())
debugger("DataEditor: view not locked");
if (fNeedsUpdate) {
@ -309,7 +305,7 @@ DataEditor::Replace(off_t offset, const uint8 *data, size_t length)
status_t
DataEditor::Remove(off_t offset, off_t length)
{
if (!fLock.IsLocked())
if (!IsLocked())
debugger("DataEditor: view not locked");
// not yet implemented
@ -321,7 +317,7 @@ DataEditor::Remove(off_t offset, off_t length)
status_t
DataEditor::Insert(off_t offset, const uint8 *text, size_t length)
{
if (!fLock.IsLocked())
if (!IsLocked())
debugger("DataEditor: view not locked");
// not yet implemented
@ -369,7 +365,7 @@ DataEditor::RemoveRedos()
status_t
DataEditor::Undo()
{
BAutolock locker(fLock);
BAutolock locker(this);
if (!CanUndo())
return B_ERROR;
@ -389,7 +385,7 @@ DataEditor::Undo()
status_t
DataEditor::Redo()
{
BAutolock locker(fLock);
BAutolock locker(this);
if (!CanRedo())
return B_ERROR;
@ -490,7 +486,7 @@ DataEditor::Update()
status_t
DataEditor::GetViewBuffer(const uint8 **_buffer)
{
if (!fLock.IsLocked())
if (!IsLocked())
debugger("DataEditor: view not locked");
status_t status = B_OK;
@ -509,20 +505,6 @@ DataEditor::GetViewBuffer(const uint8 **_buffer)
}
bool
DataEditor::Lock()
{
return fLock.Lock();
}
void
DataEditor::Unlock()
{
fLock.Unlock();
}
void
DataEditor::SendNotices(uint32 what, BMessage *message)
{
@ -551,7 +533,7 @@ DataEditor::SendNotices(uint32 what, BMessage *message)
status_t
DataEditor::StartWatching(BMessenger target)
{
BAutolock locker(fLock);
BAutolock locker(this);
node_ref node;
status_t status = fFile.GetNodeRef(&node);
@ -574,7 +556,7 @@ DataEditor::StartWatching(BHandler *handler, BLooper *looper)
void
DataEditor::StopWatching(BMessenger target)
{
BAutolock locker(fLock);
BAutolock locker(this);
for (int32 i = fObservers.CountItems(); i-- > 0;) {
BMessenger *messenger = fObservers.ItemAt(i);

View File

@ -14,7 +14,7 @@
class DataChange;
class DataEditor {
class DataEditor : public BLocker {
public:
DataEditor();
DataEditor(entry_ref &ref, const char *attribute = NULL);
@ -63,10 +63,6 @@ class DataEditor {
status_t GetViewBuffer(const uint8 **_buffer);
BLocker &Locker() { return fLock; }
bool Lock();
void Unlock();
status_t StartWatching(BMessenger target);
status_t StartWatching(BHandler *handler, BLooper *looper = NULL);
void StopWatching(BMessenger target);
@ -92,7 +88,6 @@ class DataEditor {
DataChange *fFirstChange;
DataChange *fLastChange;
BLocker fLock;
uint8 *fView;
off_t fRealViewOffset, fViewOffset;
size_t fRealViewSize, fViewSize;