8365d9ecd2
* The FontFamily is no longer reference counting itself. * SharedObject is now more useful and destructs itself when unused. * Fixed FontStyle::GetHeight()/ServerFont::GetHeight() semantics. * Simplified ServerFont constructors. * Removed wrong function descriptions. * FontStyleHeight is no longer used: the FontStyle is calculating the base font height on construction - this reduces the resolution a bit, but it's hopefully not causing any troubles (doesn't look like it, at least). * A FontStyle now removes itself from its family on destruction. * More cleanup, removed unused stuff like FontStyleHeight. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14657 a95241bf-73f2-0310-859d-f6bbb57e9c96
56 lines
1018 B
C++
56 lines
1018 B
C++
/*
|
|
* Copyright 2001-2005, Haiku.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
*/
|
|
#ifndef SHARED_OBJECT_H
|
|
#define SHARED_OBJECT_H
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
/*!
|
|
\class SharedObject SharedObject.h
|
|
\brief Base class for shared objects
|
|
|
|
SharedObjects track dependencies upon a particular object. In this way, is is
|
|
possible to ensure that a shared resource is not deleted if something else
|
|
needs it. How the dependency tracking is done largely depends on the child class.
|
|
*/
|
|
class SharedObject {
|
|
public:
|
|
SharedObject()
|
|
: fReferenceCount(1) {}
|
|
virtual ~SharedObject() {}
|
|
|
|
inline void Acquire();
|
|
inline bool Release();
|
|
|
|
private:
|
|
int32 fReferenceCount;
|
|
};
|
|
|
|
|
|
inline void
|
|
SharedObject::Acquire()
|
|
{
|
|
atomic_add(&fReferenceCount, 1);
|
|
}
|
|
|
|
inline bool
|
|
SharedObject::Release()
|
|
{
|
|
if (atomic_add(&fReferenceCount, -1) == 1) {
|
|
delete this;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
#endif /* SHARED_OBJECT_H */
|