Interface IEnvironment
interface IEnvironment
Extends IStandard
An environment is a self-contained set of settings, search paths,
object caches, and other facilities. In OmniKit, we keep global
state to a minimum. The job of the process object is essentially
to keep track of a default environment: the environment contains
all the “smarts” of the system.
An OmniKit process starts life with a default environment that
the OmniKit creates on process startup. This default environment
is created as if by (in pseudo-Python):
Methods
tryGetComponent()
Get a component by name.IStandard?tryGetComponent(stringname)
Parameters
name
string — Required
component name
Returns
IStandard?
The return value is optional and might be absent.
component or nullptr if the component can’t be found
makeConfigBuilder()
Make a configuration builder. A configuration builder can be used to build a new configuration for an environment.IConfigBuilder*makeConfigBuilder(IConfig?oldConfig)
Parameters
oldConfig
IConfig? — Optional
if present, base the new config on
oldConfig; if not present, the new config is empty.
Returns
IConfigBuilder*
Config builder
getConfig()
Get the current configuration of this environment.IConfig*getConfig()
Returns
IConfig*
Config
trySetConfig()
Install a new configuration in this environment. This method does and atomic compare-and-replace ofbooltrySetConfig(IConfig*oldConfig,IConfig*newConfig)
oldConfig with newConfig. This technique
allows us to atomically change environment configuration without
calling external code under a lock.
Configs are immutable once created. One does not “change”
a configuration: one instead builds a new configuration (perhaps
based on an existing configuration) and atomically installs the
new configuration.
Parameters
oldConfig
IConfig* — Required
the caller’s last-known old configuration
newConfig
IConfig* — Required
the desired new configuration
Returns
bool
True iff we atomically replaced oldConfig or false
if the current configuration is not oldConfig.
clone()
Clone this environment. The returned environment has a configuration independent of the calling environment but shares cached loaded components and other state present at the time of the clone.IEnvironment*clone()
Returns
IEnvironment*
Cloned environment

