Xavax C++ Library | Class Index FAQ Overview |
Copy semantics for RCObject are controlled by a
shareable flag
which defaults to true
and is set by the
shareable method.
When a RCObject is shareable,
new references increment the reference count
and share the object.
If a RCObject is not shareable,
a new copy of the object is created for each new reference.
RCObject works in conjunction with
RCPointer
to implement a copy-on-write mechanism.
Any method which modifies an object deriving from RCObject
should call one of two methods provided by RCPointer.
The modify
method
should be called by methods which assign values
to all members of an object, such as operator=
.
If the object is shared and the copy-on-write flag is true,
modify
creates a new object.
The modifyCopy
method
should be called by methods which do not assign values
to all members of an object.
If the object is shared and the copy-on-write flag is true,
modifyCopy
creates a copy of the object.
Constructor Summary |
RCObject()
Construct a RCObject. |
RCObject(const RCObject&)
Construct a copy of a RCObject. |
Operator Summary | |
RCObject&
|
operator=(const RCObject&)
Assignment operator. |
Method Summary | |
void
|
attach()
Attach a reference to this object. |
void
|
copyOnWrite(bool flag)
Set the copyOnWrite flag. |
bool
|
copyOnWrite()
Return the state of the copyOnWrite flag. |
void
|
detach()
Detach a reference from this object. |
int
|
refCount()
Return the reference count. |
void
|
shareable(bool)
Set the state of the shareable flag. |
bool
|
shareable()
Return true if the object is shareable. |
bool
|
shared()
Return true if the object is shared. |
Methods Inherited From Object | |
cast<T>,
cast<T>,
classRecord,
ClassRecord,
clone,
hashCode
|
Related Classes | |
Object, RCPointer |
Constructor Detail |
RCObject()
RCObject(const RCObject& src)
src
- the object to be copied.
Operator Detail |
RCObject& operator=(const RCObject& src)
src
- the object to be copied.
Method Detail |
void attach()
void copyOnWrite(bool flag)
flag
.
flag
- the new state of the copyOnWrite flag.void copyOnWrite()
void detach()
void shareable(bool flag)
flag
- the new value of the shareable flag.bool shareable() const
bool shared() const
Example Code |
Copyright © 2003 Xavax Inc. -- All Rights Reserved