Class Context

Class Documentation

class Context

Context object with global resources.

It gets initialized only once. It owns global objects which get created & initialized.

Public Functions

Context()

Constructor.

Not to be used directly: use get_global_context() instead.

~Context()
void init()

Initialize context using config file.

Shouldn’t be called directly: use email::init() instead.

Throws:
void init(int argc, char const *const argv[])

Initialize context using commandline arguments.

Shouldn’t be called directly: use email::init(argc, argv) instead.

The process will exit with error code 1 if parsing of CLI options fails.

Throws:
bool shutdown()

Shut down context.

This should be called at the end before context destruction. However, it shouldn’t be called directly: use email::shutdown() instead.

Returns:

true if successful, false otherwise

bool is_valid() const

Get context validity status.

Returns:

true if valid, false otherwise

std::shared_ptr<Options> get_options() const

Get options.

Throws:

ContextNotInitializedError – if context has not been initialized

Returns:

the options

std::shared_ptr<EmailReceiver> get_receiver() const

Get the email reception object.

Will have been initialized.

Throws:

ContextNotInitializedError – if context has not been initialized

Returns:

the EmailReceiver object

std::shared_ptr<EmailSender> get_sender() const

Get the email sender object.

Will have been initialized.

Throws:

ContextNotInitializedError – if context has not been initialized

Returns:

the EmailSender object

std::shared_ptr<PollingManager> get_polling_manager() const

Get the polling manager.

Will have been started.

Throws:

ContextNotInitializedError – if context has not been initialized

Returns:

the PollingManager object

std::shared_ptr<SubscriptionHandler> get_subscription_handler() const

Get the subscription handler.

Throws:

ContextNotInitializedError – if context has not been initialized

Returns:

the SubscriptionHandler object

std::shared_ptr<ServiceHandler> get_service_handler() const

Get the service handler.

Throws:

ContextNotInitializedError – if context has not been initialized

Returns:

the ServiceHandler object