---
name: "kdb_Context"
section: "3elektra"
platform: "linux"
package: "elektra-doc"
version: "0.8.7-4"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/kdb_Context"
---

# kdb\_Context(3elektra)

Provides a context for configuration.

## NAME

kdb::Context -

Provides a context for configuration.

## SYNOPSIS

`#include <contextual.hpp>`

Inherits kdb::Subject.

### Public Member Functions

std::string **operator\[\]** (std::string const &layer) const \
 void **attachByName** (std::string const &key\_name, Observer &observer)\
 std::string **evaluate** (std::string const &key\_name) const \
 std::string **evaluate** (std::string const &key\_name, std::function\< bool(std::string const &, std::string &, bool in\_group)\> const &on\_layer) const \
 template\<typename T , typename... Args\> void **activate** (Args &&...args)\
 *Globally activate the layer.*

## Detailed Description

Provides a context for configuration.

Is a subject for observers.

Holds currently active layers and allows global/scoped activation of layers.

## Member Function Documentation

### template\<typename T , typename... Args\> void kdb::Context::activate (Args &&...args)` [inline]`

Globally activate the layer.

**Template Parameters:**

*T* the layer to activate \
 *Args* the types for the arguments to pass to layer construction

**Parameters:**

*args* the arguments to pass to layer construction

### void kdb::Context::attachByName (std::string const &key\_name, Observer &observer)` [inline]`

Attach observer using to all events given by its specification (name)

**Parameters:**

*key\_name* the name with placeholders to be used for attaching \
 *observer* the observer to attach to

### std::string kdb::Context::evaluate (std::string const &key\_name) const` [inline]`

Evaluate a specification (name) and return a key name under current context

**Parameters:**

*key\_name* the name with placeholders to be evaluated

### std::string kdb::Context::evaluate (std::string const &key\_name, std::function\< bool(std::string const &, std::string &, bool in\_group)\> const &on\_layer) const` [inline]`

Evaluate specification with this context.

**Parameters:**

*key\_name* the keyname with placeholders to evaluate \
 *on\_layer* the function to be called for every placeholder found

**on\_layer is called for every layer in the**

specification.

### std::string kdb::Context::operator\[\] (std::string const &layer) const` [inline]`

Lookup value for a current active layer

**Parameters:**

*layer* the name of the requested layer

## Author

Generated automatically by Doxygen for Elektra from the source code.
