What are elements

This topic describes elements. All items that can be stored in the Comms Database are elements. The topic also discusses the structure of the unique numeric Id and the attributes that control access to elements.

An element is represented by the CMDBElement class. The class is a base class for all items that can be stored in the Comms Database. The class contains the data that is common to all items that can be stored in the Comms database.

Elements contain three pieces of information:

  • a unique numeric Id that defines the location of the element in the database. The Id defines the meaning of the element in the database schema as a specific Table, Column, Record or Field. A numeric Id also allows for fast access and retrieval of an element.

  • a set of attributes that controls access to the data.

  • a value that can be a single numeric type, a Boolean type, a descriptor, or a composite of one or more nested elements.

CMDBElement derives from MMetaDatabase. MMetaDatabase provides the behaviour that allows an element to operate with the Comms Database. [See accessing the database or words to that effect.]

The Element Id

The iElementId data member of CMDBElement is a 32 bit number that contains:

  • the unique numeric Id that shows the location of the element in the database. This numeric Id is known as the Element Id.

  • the set of attributes that controls access to the data. The bits define the access levels.

Both pieces of information are encoded in the 32 bit number. The 32 bit number is a TMDBElementId type.

The CMDBElement class provides member functions to access and to change the information in the Element Id.

The unique numeric Id

The unique numeric Id has two parts: the Type Id and the Record Id.

The Type Id defines the type of element; the Record Id identifies an instance of this type of element.

The class CMDBElement provides the member functions CommsDat::CMDBElement::TypeId() and CommsDat::CMDBElement::RecordId() to extract this information.

Internally, the Type Id includes a 8 bit number and a 7 bit number. The 8 bit number is the Table Id and the 7 bit number is the Column Id. The Type Id and the Record Id are in defined locations in the 32 bit number iElementId.

The header file comsdat.h contains the constants that define the location of these Ids in the 32 bit number:

Table Id

KCDMaskShowRecordType

Column Id

KCDMaskShowFieldType

Type Id

KCDMaskShowType

Record Id

KCDMaskShowRecordId

The set of attributes that controls access to the data

The access levels of an element are defined by the bits in the element. The TCDAttributeFlags enum defines the access levels of an element. These bits are stored in the fourth byte of the iElementId member of CMDBElement.

KCDMaskShowAttributes in the header file comsdat.h defines the location of these access control bits in the 32 bit number.