Microsoft Information Protection SDK - observer concepts

The MIP SDK is almost entirely asynchronous. For example, the SDK performs any operation that results in network or file I/O asynchronously. To handle the event notifications for these asynchronous events, the SDK uses the observer pattern.

Implementation overview

When you construct an object that performs an asynchronous operation, implement an Observer class. Observers receive the notification events related to the various asynchronous operations in the MIP SDK and provide the result to the caller.

You can override virtual functions in each Observer class for the preferred asynchronous pattern. The SDK implements the event notification observer pattern by using std::promise and std::future.

Each class-specific observer contains a set of success and error/failure functions for the outcome of an async operation. Success functions return the object associated with the operation. Error/Failure functions return an exception that contains details on why the operation was unsuccessful.

For example, FileProfile supports the following two operations:

  • It can add a new engine to the profile by using FileProfile::AddEngineAsync.
  • It can unload an engine from the profile by using FileProfile::UnloadEngineAsync.

Because the SDK implements two Observer functions per asynchronous operation, you can assume that four Observer methods are associated with FileProfile:

  • FileProfileObserver::OnAddEngineSuccess()
  • FileProfileObserver::OnAddEngineError()
  • FileProfileObserver::OnUnloadEngineSuccess
  • FileProfileObserver::OnUnloadEngineError()

MIP SDK observer classes

The MIP File SDK contains two observers:

  • mip::FileProfile::Observer
  • mip::FileHandler::Observer

The MIP Policy SDK has one observer:

  • mip::Profile::Observer

The MIP Protection SDK has three observers:

  • mip::ProtectionProfile::Observer
  • mip::ProtectionEngine::Observer
  • mip::ProtectionHandler::Observer

Next steps

Learn more about how the various SDKs implement and use observers: