×


BaseTargetHelper
- Found In File: TargetHelper.h





This class controls the methods for enabling and disabling multi-threading support as well as setting and retrieving the current policy in place. This class is one of the building blocks for all in-house targets.

Click here for a file snippet:

This struct is found under the namespace serenity::target::helpers in file TargetHelper.h

class BaseTargetHelper { public: explicit BaseTargetHelper(); BaseTargetHelper(BaseTargetHelper&) = delete; BaseTargetHelper& operator=(BaseTargetHelper&); ~BaseTargetHelper() = default; void EnableMultiThreadingSupport(bool enableMultiThreading = true); bool isMTSupportEnabled(); void SetFlushPolicy(const Flush_Policy& fPolicy); const std::unique_ptr<Flush_Policy>& Policy() const; private: bool multiThreadSupport; protected: std::unique_ptr<Flush_Policy> policy; };


Public Functions
explicit BaseTargetHelper();
This is the only constructor available for this class.
BaseTargetHelper& operator=(BaseTargetHelper&);
This copy operator copies the multi-threading support option and the flush policy currently in place.
void EnableMultiThreadingSupport(bool enableMultiThreading=true);
This function uses a boolean value to simply toggle whether or not multi-threading support is enabled.
bool isMTSupportEnabled();
Simply returns `true` or `false` based on the current state of multi-threading support.
void SetFlushPolicy(const Flush_Policy& fPolicy);
This functions is responsible for setting the flush policy used and covers the flush mode, flush type, and flushing values.
const std::unique_ptr<Flush_Policy>& Policy() const;
This function simply returns a const pointer to the policy currently in place.
More Information About BaseTargetHelper


explicit BaseTargetHelper();
This is the only constructor available for this class. By default, it sets:
  • multi-threading support to false
    • multi-threading support is disabled
  • policy to FlushSetting::never
    • effectively never flushes until explicitly told to flush from the logger


BaseTargetHelper&operator=(BaseTargetHelper&);
This copy operator copies the multi-threading support option and the flush policy currently in place.


void EnableMultiThreadingSupport(bool enableMultiThreading =true);
This function uses a boolean value to simply toggle whether or not multi-threading support is enabled.
  • Set `enableMultiThreading=false` to disable support
  • Set `enableMultiThreading=true` to enable support


bool isMTSupportEnabled();
Simply returns `true` or `false` based on the current state of multi-threading support.
  • Returns `true` if multi-threading support is enabled.
  • Returns `false` if multi-threading support is disabled.


void SetFlushPolicy(const Flush_Policy& fPolicy);
This function takes a reference to a Flush_Policy class object as its parameter.

Flush_Policy covers the following options:
  • A FlushSetting
    - This can be one of three choices:
    • always - Always flushes the buffer after each log message
    • periodically - As it implies, periodically flush the buffer. This is contingent on either a time based or a log level based sub-option
    • never - Never flush the buffer contents to disk; this means you must call the Flush() function manually
  • A PeriodicOptions
    - The below options are only used when FlushSetting::periodically is set.
    This can be one of three choices:
    • timeBased - This option will launch a background thread, if the flush worker thread hasn't already been launched before, that will flush the contents of the buffer to disk once the specified time has elapsed.
    • logLevelBased - This option will launch a background thread, if the flush worker thread hasn't already been launched before, that will flush the contents of the buffer to disk once a message with the specified log level has been written to the buffer.
    • undef - this option is used and set only when FlushSetting::periodically is not set
  • A PeriodicSettings
    - The below options are only used when FlushSetting::periodically is set and PeriodicOptions::undef is not set.
    This can be one of two choices:
    • flushEvery - This option is the value you set, in milliseconds, if FlushSetting::periodically and PeriodicOptions::timeBased are both set.
    • flushOn - This option is the value you set, as a log level value, if FlushSetting::periodically and PeriodicOptions::logLevelBased are both set.


const std::unique_ptr<Flush_Policy>&Policy() const;
This function simply returns a const pointer to the policy currently in place.