Configuration

class cppmicroservices::service::cm::Configuration
#include <cppmicroservices/cm/Configuration.hpp>

The Configuration object (normally obtained as a std::shared_ptr<Configuration>) is the principal means for clients of ConfigurationAdmin to inspect or update the Configuration of a given service or service factory.

Public Functions

virtual ~Configuration()
virtual std::string GetPid() const = 0

Get the PID of this Configuration.

Return
the PID of this Configuration
Exceptions
  • std::runtime_error: if this Configuration object has been Removed

virtual std::string GetFactoryPid() const = 0

Get the Factory PID which is responsible for this Configuration.

If this Configuration does not belong to any Factory, returns an empty string.

Return
the Factory PID associated with this Configuration, if applicable
Exceptions
  • std::runtime_error: if this Configuration object has been Removed

virtual AnyMap GetProperties() const = 0

Get the properties of this Configuration.

Returns a copy.

Return
the properties of this Configuration
Exceptions
  • std::runtime_error: if this Configuration object has been Removed

virtual unsigned long GetChangeCount() const = 0

Get the change count.

Each Configuration must maintain a change counter that is incremented with a positive value every time the configuration is updated and its properties are stored. The counter must be incremented before the targets are updated and events are sent out.

Return
A monotonically increasing value reflecting changes in this Configuration.
Exceptions
  • std::runtime_error: if this Configuration object has been Removed

virtual std::shared_future<void> Update(AnyMap properties = AnyMap { AnyMap::UNORDERED_MAP_CASEINSENSITIVE_KEYS }) = 0

Update the properties of this Configuration.

Invoking this method will trigger the ConfigurationAdmin impl to push the updated properties to any ManagedService / ManagedServiceFactory / ConfigurationListener which has a matching PID / Factory PID.

If the properties are empty, the Configuration will not be removed, but instead updated with an empty properties map.

Remark
The shared_future<void> returned can contain a cppmicroservices::SecurityException if the Configuration caused a bundle’s shared library to be loaded and the bundle failed a security check.
Return
a shared_future<void> which can be used to wait for the asynchronous operation that pushed the update to a ManagedService, ManagedServiceFactory or ConfigurationListener to complete. If an exception occurs during the execution of the service component’s Modified method, this exception is intercepted and logged by Declarative Services. This exception is not returned in the shared_future.
Exceptions
  • std::runtime_error: if this Configuration object has been Removed
Parameters

virtual std::pair<bool, std::shared_future<void>> UpdateIfDifferent(AnyMap properties = AnyMap { AnyMap::UNORDERED_MAP_CASEINSENSITIVE_KEYS }) = 0

Update the properties of this Configuration if they differ from the current properties.

Invoking this method will trigger the ConfigurationAdmin impl to push the updated properties to any ManagedService / ManagedServiceFactory / ConfigurationListener which has a matching PID / Factory PID, but only if the properties differ from the current properties. It will return true in this case, and false otherwise.

If the properties are empty, the Configuration will not be removed, but instead updated with an empty properties map, unless it already had empty properties.

Remark
The shared_future<void> returned can contain a cppmicroservices::SecurityException if the Configuration caused a bundle’s shared library to be loaded and the bundle failed a security check.
Return
std::pair<boolean, std::shared_future<void>> The boolean indicates whether the properties were updated or not. The shared_future<void> allows access to the result of the asynchronous operation that pushed the update operation to a ManagedService, ManagedServiceFactory or ConfigurationListener. If an exception occurs during the execution of the service component’s Modified method, this exception is intercepted and logged by Declarative Services. This exception is not returned in the shared_future.
Exceptions
  • std::runtime_error: if this Configuration object has been Removed
Parameters
  • properties: The properties to update this Configuration with (if they differ)

virtual std::shared_future<void> Remove() = 0

Remove this Configuration from ConfigurationAdmin.

This will trigger a push to any ConfigurationListener. This will also trigger the ConfigurationAdmin implementation to update any corresponding ManagedService with an empty AnyMap. Any corresponding ManagedServiceFactory will have its Removed method invoked with the corresponding PID.

Return
a shared_future<void> to access the result of the asynchronous operation that pushed the remove operation to a ManagedService, ManagedServiceFactory or ConfigurationListener. If an exception occurs during the execution of the service component’s Modified method, this exception is intercepted and logged by Declarative Services. This exception is not returned in the shared_future.
Exceptions
  • std::runtime_error: if this Configuration object has been Removed already