Utils::Memory::SharedData Class Reference

#include <SharedData.h> [code]

Inherited by Protocols::Generics::PacketBase::Data, and Protocols::Http::HeaderBase::Data.

Inheritance diagram for Utils::Memory::SharedData:

Inheritance graph
[legend]
List of all members.

Detailed Description

Implements implicit sharing of polymorphic data types.

R1 Easily add support for implicit sharing of the private data. Allow polimorphic classes, the private classes of which are polimorphic as well to readily use implicit sharing. Use QSharedData if you want to share non-polymorphic data types.

U1 You are designing a class hierarchy and want the base class to take care of implicit sharing of the private data by means of reference counting. The derived classes should be allowed to extend the private data class by adding new fields.

Simply derive your private data class from SharedMemory and declare a SharedDataPointer member in your class. The private data class of the derived classes must override the virtual function copy() otherwise when the private data is detached an incomplete copy will be created and the software will hopefully crash before doing any damage to data.

Note:
Always override copy() in each concrete derived class!

Definition at line 71 of file SharedData.h.

Public Member Functions

 SharedData ()
 SharedData (const SharedData &)
virtual SharedDatacopy () const =0
virtual ~SharedData ()

Public Attributes

QAtomic ref

Private Member Functions

SharedDataoperator= (const SharedData &)


Constructor & Destructor Documentation

Utils::Memory::SharedData::SharedData  )  [inline]
 

Definition at line 76 of file SharedData.h.

Utils::Memory::SharedData::SharedData const SharedData  )  [inline]
 

Definition at line 77 of file SharedData.h.

virtual Utils::Memory::SharedData::~SharedData  )  [inline, virtual]
 

Definition at line 79 of file SharedData.h.


Member Function Documentation

virtual SharedData* Utils::Memory::SharedData::copy  )  const [pure virtual]
 

SharedData& Utils::Memory::SharedData::operator= const SharedData  )  [private]
 


Member Data Documentation

QAtomic Utils::Memory::SharedData::ref
 

Definition at line 74 of file SharedData.h.


The documentation for this class was generated from the following file: