Skip to main content
Version: 3.0.0 (experimental)

Policy Headers

dmr_test_policies.h and dmr_CE_policy.h are the only headers an application includes by name besides dmr.h. They stay out of the barrel because the policies behind them are optional at build time, so what they declare depends on how DMR was compiled.

#include "dmr.h" /* the policy interface itself */
#include "dmr_test_policies.h" /* round and list constructors */
#include "dmr_CE_policy.h" /* CE constructor */

The interface these constructors return, DMRPolicy and friends, comes from the barrel and is documented under Policies.

Declarations​

HeaderGuardConstructors
dmr_test_policies.hDMR_WITH_TEST_POLICIESDMRPolicy *dmr_get_policy_round(void);
DMRPolicy *dmr_get_policy_list(void);
dmr_CE_policy.hDMR_WITH_CE_POLICYDMRPolicy *dmr_get_policy_ce(void);

Each declaration sits inside #if defined(<guard>), so calling a constructor whose policy was not built is a compile error naming the function, not a link error at the end of the build.

Build flags​

The guards are set by CMake:

CMake flagDefaultCompile definitionPolicies
DMR_BUILD_TEST_POLICIESONDMR_WITH_TEST_POLICIESround, list
DMR_BUILD_CE_POLICYON when DMR_USE_TALP=ONDMR_WITH_CE_POLICYce

DMR_BUILD_CE_POLICY=ON requires DMR_USE_TALP=ON. CMake errors out if you ask for one without the other.

Behaviour common to all three​

Every constructor returns a pointer to a static singleton, so there is nothing to free and destroy is NULL. Two consequences:

  • Registering the same built-in twice with different parameters does not work. The second call overwrites the first one's state.
  • Parameters are re-read from the environment on every call, so re-registering is how you re-parameterise a built-in at runtime.
setenv("DMR_DEFAULT_POLICY_MAX", "16", 1);
dmr_set_policy(dmr_get_policy_round()); /* collective, picks up the new value */

What each policy decides, and which environment variables it reads, is in Built-in Policies.