What are links

This topic describes the structure of links. A link is a container and an element. A link is an item that can be stored in the Comms Database.

A link is a container. A link refers to another record. A link can be included in a record.

A link is represented by the templated class [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBRecordLink<T>. The template parameter defines the type of record to which the link refers.

A link is a public data member of a class. The class defines the structure of record. This record is the 'parent' record of the linked record. For example, Symbian platform defines the class [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CCDIAPRecord that represents an Internet Access Point (IAP) record. A set of IAP records form an IAP table. The public data members of this class are the fields and links that make the record. The following code shows part of the class definition. Some parts are omitted - this is not the complete class definition.

class CCDIAPRecord : public CCDRecordBase
    {
    public:
        CMDBField<TDesC>                        iServiceType;
        CMDBRecordLink<CCDServiceRecordBase>    iService;
        CMDBField<TDesC>                        iBearerType;
        CMDBRecordLink<CCDBearerRecordBase>     iBearer;
        CMDBRecordLink<CCDNetworkRecord>        iNetwork;
        CMDBField<TUint32>                      iNetworkWeighting;
        CMDBRecordLink<CCDLocationRecord>       iLocation;
        ...
    }
 

A [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBRecordLink<T> object contains an integer. The integer is the element Id of the linked record in the database.

If you have a parent record in memory, you call the LoadL() function on the link object [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBRecordLink<T> to get the linked record into memory. You can access the linked record through the iLinkedRecord pointer. This pointer is a member of the CMDBRecordLinkBase class, but you can access this data member through the CMDBRecordLink<T> object.

There are two cases:

  • If you know what type of record the link refers to you cast the pointer to the correct type. For example:

    CCDDialOutISPRecord* ptrIspRecord = static_cast<CCDDialOutISPRecord*>(ptrSingleIAPRecord->iService.iLinkedRecord);

    where ptrSingleIAPRecord is of type [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CCDIAPRecord.

  • If you do not know what type of record the link refers to you cast the pointer to the base class for records. You use GetFieldByNameL() or GetFieldByIdLaccess() to access the data in the linked record. For example:

    CCDServiceRecordBase* ptrServiceRecord = static_cast<CCDServiceRecordBase*>(ptrSingleIAPRecord->iService.iLinkedRecord);
    CMDBField<TUint32>* field; 
    
    // Find a field by its Id. In this code fragment, the field we are looking for 
    // is the bearer speed field.
    field = (CMDBField<TUint32>*)ptrServiceRecord->GetFieldByIdL(KCDTIdBearerSpeed);

Related tasks