---
name: "QmcContext"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/QmcContext"
---

# QmcContext(3)

container for a PMAPI context and its metrics

## NAME

**QmcContext** - container for a PMAPI context and its metrics

## C++ SYNOPSIS

**#include \<QmcContext.h\>**

**c++ ... -lpcp\_qmc -lpcp**

## DESCRIPTION

A **QmcContext** object is a container for a single [**PMAPI**(3)](/PMAPI/3.md) context.  The object maintains a list of all the metric descriptors (**QmcDesc**), instance domains (**QmcIndom**) and metrics (**QmcMetric**) using the context to minimize the duplication of these objects.

## CONSTRUCTORS

A **QmcContext** object should be constructed through the **QmcGroup::use** interface.

## DESCRIPTOR LOOKUP

The metric and instance domain descriptors are cached by the **QmcContext** object to reduce duplicate [**QmcDesc**(3)](/QmcDesc/3.md) and [**QmcIndom**(3)](/QmcIndom/3.md) objects and [**PMAPI**(3)](/PMAPI/3.md) calls required to create them.  Also the mapping from metrics names to **pmID**s is also maintained to avoid [**pmLookupName**(3)](/pmLookupName/3.md) calls.

- **int lookupDesc(const char \*name, pmID& id);**

  Search for the metric *name* in the name list and set **id** to the known **pmID**. If not found, use [**pmLookupName**(3)](/pmLookupName/3.md) to get the mapping.  If this call fails, the [**PMAPI**(3)](/PMAPI/3.md) error code will be returned.

- **int lookupDesc(const char \*name, uint\_t& desc, uint\_t& indom);**

  Find the index *desc* and *indom* to the **QmcDesc** object and the **QmcIndom** object for the metric *name*. The indexes can then be used with **QmcContext::desc** and **QmcContext::indom** to obtain references to the real objects. The methods will return a [**PMAPI**(3)](/PMAPI/3.md) error code if the metric descriptor or instance domain could not be obtained.

- **int lookupDesc(pmID pmid, uint\_t& desc, uint\_t& indom);**

  Find the index *desc* and *indom* to the **QmcDesc** object and the **QmcIndom** object for the metric *pmid*. The indexes can then be used with **QmcContext::desc** and **QmcContext::indom** to obtain references to the real objects. The methods will return a [**PMAPI**(3)](/PMAPI/3.md) error code if the metric descriptor or instance domain could not be obtained.

## DIAGNOSTICS

Error messages are generated using [**pmprintf**(3)](/pmprintf/3.md) but are not flushed. It is the responsibility of the user to call [**pmflush**(3)](/pmflush/3.md) to output any messages.

Additional diagnostics may be activated by adding the options **pmc** and/or **optfetch** to the global debugging specification, as described in [**pmSetDebug**(3)](/pmSetDebug/3.md).

## SEE ALSO

[**PMAPI**(3)](/PMAPI/3.md), [**QMC**(3)](/QMC/3.md), [**QmcDesc**(3)](/QmcDesc/3.md), [**QmcGroup**(3)](/QmcGroup/3.md), [**QmcIndom**(3)](/QmcIndom/3.md), [**QmcMetric**(3)](/QmcMetric/3.md), [**pmflush**(3)](/pmflush/3.md), [**pmLookupName**(3)](/pmLookupName/3.md) and [**pmprintf**(3)](/pmprintf/3.md).
