KCMS CMM Reference Manual

Chapter 1 KcsShareable Class

This chapter describes the KCMS framework's primary base class, the KcsShareable class. This class is at the top of the KCMS class hierarchy. The KcsShareable class allows any of its derivatives to be shared.

As you read this chapter, you will find it helpful to have access to the kcsshare.h header file.

The constant and #define identifiers for this class are defined in the kcsids.h header file as:

const KcsId KcsRlocSharLoadId = {(0x53686172UL)}; /* 'Shar' */
#define KcsRlocSharLoadIdd (0x53686172UL) /* 'Shar' */

The protected and public members are described.

Protected Members

The KcsShareable class provides the following protected members.

Table 1-1 KcsShareable Protected Members

Protected Member 

Description 

virtual ~KcsShareable();

Destructor. A protected member. 

Public Members

The KcsShareable class provides the following public members.

Table 1-2 KcsShareable Public Members

Public Member 

Description 

virtual KcsShareable *attach(
 	long howMany = 1,
 	KcsAttachType aAttachFlag = KcsAttMem,
 	KcsStatus *aStatus = NULL);

Use this method when you want to share an object already allocated. It returns a pointer to the shared object. All shared objects must dettach() instead of using delete. aAttachFlag and aStatus are only used with the KcsLoadable class override.

void dettach(long howMany = 1,
 	KcsAttachType aDettachFlag = KcsAttMem,
 	KcsStatus *aStatus = NULL);

Deletes an object. The actual deallocation only happens when no other object is sharing this object. aDettachFlag and aStatus are only used with the KcsLoadable class override.

static long getGlobalCount();

Returns the total number of objects sharing any other objects in the system. Use for debugging. 

long getUseCount() {return(useCount);};

Returns the current number of objects sharing this object. Use for debugging. 

KcsShareable(KcsStatus *status, long nUse = 1);

Constructor.