|
Developer Documentation |
|
Centre for Vision, Speech & Signal Processing |
Comments:
Class BodyRefCounterC serves as a reference counter of object
with dynamically allocated parts which can be shared among
objects. It has the same functional set of member functions as
an object of class RefCounterC, but this reference counter is
assumed to be allocated with object which is reference counted.
Parent Classes:
Derived Classes:
Enumerated types:
- enum anon_enum?5 { UserBitOffset = 3 } ;
-
The corresponding bits of the flags.
Typedefs:
- typedef anon_enum?6 FlagT;
-
The corresponding bits of the flags.
Variables:
- atomic_t counter;
-
the reference counter
- BitSet16C flags;
-
An additional information about the object.
flag[0] .. if TRUE the object cannot be removed during its destruction,
flag[1] .. if TRUE the object is locked and should be treated as a
constant object.
flag[2] .. Used to resolve race conditions in delete.
- IntT BRCCheckVar;
-
Used in check for corruption.
In future versions this variable may be removed in
the optimised version. But this would make linking
optimised and check or develop code impossible. So
for the moment It'll be left in.
Methods:
- BodyRefCounterC(BooleanT removable = TRUE)
-
Creates the reference counter and initializes it.
If the value of the argument 'removable' is FALSE,
internal flag NOREMOVE is set on,
the reference counter still treats the current number
of references, but the value of member function
ToBeDeleted is always FALSE.
- BodyRefCounterC(const BodyRefCounterC & b)
-
It has not meaning to copy object 'b' because this new object
should be initialized as a first reference. However, this
constructor is provided from the consistency point of view and
it behaves as BodyRefCounterC(BooleanT removable = TRUE) does.
The reference counting content of 'b' is ignored, although
some useful flags can be passed.
- BodyRefCounterC(const BodyRefCounterC & b,BooleanT removable)
-
- ~BodyRefCounterC()
-
Destructor, used to check that all pointers have been removed before the memory has been free'd.
Updating functions
------------------
- void AddReference()
-
Another reference to the object has been created.
- void RemoveReference()
-
One reference to the object was deleted.
Locking scheme
--------------
The object is possible to lock (to make constant). The scheme
assumes that the object is created, it can be locked, after that
it can only be destroyed. The locked object cannot be unlocked.
This locking scheme is very useful
during debugging, using assert() function,
when it is necassary to check that object
is treated as constant and the constancy is not violated by
any casting or passing through the copy constructor of shared
objects.
- void SetConst(void) const
-
This locks the object.
Often objects you wish to lock are already const.
- void SetConst(void)
-
This locks the object.
- BooleanT IsConst(void) const
-
Returns TRUE if the object is locked, ie. it is assumed to be constant.
- BooleanT IsNotConst(void) const
-
Returns TRUE if the object is unlocked.
ie. there is no special
information if the object is constant or not.
Counter state information
-------------------------
- BooleanT ToBeDeleted() const
-
Returns TRUE if there is only one reference to the object and the whole object or its reference counting part can be deleted.
- BooleanT ToBeDeletedRemoveIgnoreNoRemove()
-
Decrement refrence by 1 return true if this leaves no refrences to the object.
- BooleanT ToBeDeletedRemove()
-
Decrement refrence by 1 return true if this leaves no refrences to the object. This also checks the NoRemove flag.
- BooleanT BodyMightBeDeleted() const
-
Returns TRUE if the reference counted part of the object can be deleted, ie. flag NOREMOVE is false .
- BooleanT IsCountZero() const
-
Are there any refrences left ?
- BooleanT BRCPtrCanDeleteObject() const
-
Used by BRRCPtrC to establish if an object has ZERO refrences and can be deleted.
- IntT Count() const
-
Returns the current state of the counter, ie. how many references to this object exist.
- const BodyRefCounterC & operator=(const BodyRefCounterC & b)
-
It has not meaning to assign object 'b' to this object because it would destroy a history of the object which is counted. So this is a dummy function.
- BooleanT IsValidObject() const
-
Test if object is valid.
When amma check is disabled this always returns true.
- BooleanT UserBitTest(IntT x) const
-
Test user flag.
- void UserBitSet(IntT x,BooleanT setit = TRUE)
-
Test user flag.
- void UserBitZero(IntT x)
-
Set bit to zero.
- void ReportBRCError(char * Msg)
-
Report error, used in BRCPtrC.
- UIntT Hash() const
-
Hash on address of object.
- void SetUndeletable()
-
Make object undeletable.
Usefull to prevent recursive deleting in graph structures.
Only hackers need this function.
- void ReportInvalidObject(char * Msg = 0) const
-
Tell user about validation failure.
- LabelT Label() const
-
Returns the label of this reference counter.
The member function
is useful mainly to recognize objects during debugging.
The value of the label is uniquely defined pointer.
|
Programmer:Radek Marik, Documentation by CxxDoc: Tue Mar 20 10:49:27 2001
|