Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::Kernel::UsageServiceImpl Class Reference

#include <UsageService.h>

Public Member Functions

void clear ()
 clear any buffers without sending any outstanding usage reports More...
 
void flush ()
 flushes any buffers and sends any outstanding usage reports More...
 
std::string getApplicationName () const
 Returns the application name that has invoked Mantid. More...
 
Types::Core::DateAndTime getStartTime ()
 Gets the start time of this mantid instance. More...
 
Types::Core::time_duration getUpTime ()
 gets the uptime of this mantid instance More...
 
bool isEnabled () const
 Returns true if usage reporting is enabled. More...
 
void registerFeatureUsage (const FeatureType &type, const std::string &name, const bool internal)
 Version that takes a string if just registering usage of a class. More...
 
void registerFeatureUsage (const FeatureType &type, const std::vector< std::string > &name, const bool internal)
 registerFeatureUsage registers the use of a feature in mantid. More...
 
void registerFeatureUsage (const FeatureType &type, std::initializer_list< std::string > name, const bool internal)
 Version that accepts an initializer list. More...
 
void registerStartup ()
 Registers the Startup of Mantid. More...
 
void setApplicationName (const std::string &name)
 Sets the application name that has invoked Mantid. More...
 
void setEnabled (const bool enabled)
 Sets whether the UsageReporter is enabled. More...
 
void setInterval (const uint32_t seconds=60)
 Sets the interval that the timer checks for tasks. More...
 
void shutdown ()
 

Protected Member Functions

virtual std::string generateFeatureUsageMessage ()
 generates the message body for a feature usage message More...
 
virtual std::string generateStartupMessage ()
 generates the message body for a startup message More...
 
virtual Kernel::InternetHelper::HTTPStatus sendReport (const std::string &message, const std::string &url)
 sends a report over the internet More...
 
 UsageServiceImpl ()
 Constructor. More...
 
virtual ~UsageServiceImpl ()=default
 Destructor. More...
 

Private Member Functions

::Json::Value generateFeatureHeader ()
 This puts together the system information for the json document. More...
 
UsageServiceImploperator= (const UsageServiceImpl &)
 Private, unimplemented copy assignment operator. More...
 
InternetHelper::HTTPStatus sendFeatureAsyncImpl (const std::string &message)
 Async method for sending feature messages. More...
 
void sendFeatureUsageReport (const bool synchronous)
 Send featureUsageReport. More...
 
InternetHelper::HTTPStatus sendStartupAsyncImpl (const std::string &message)
 Asynchronous execution. More...
 
void sendStartupReport ()
 Send startup Report. More...
 
void timerCallback (Poco::Timer &)
 A method to handle the timerCallbacks. More...
 
 UsageServiceImpl (const UsageServiceImpl &)
 Private, unimplemented copy constructor. More...
 

Private Attributes

std::string m_application
 
Poco::ActiveMethod< InternetHelper::HTTPStatus, std::string, UsageServiceImplm_featureActiveMethod
 Async method for sending feature notifications. More...
 
std::queue< FeatureUsagem_FeatureQueue
 
size_t m_FeatureQueueSizeThreshold
 
bool m_isEnabled
 
std::mutex m_mutex
 
Types::Core::DateAndTime m_startTime
 
Poco::ActiveMethod< InternetHelper::HTTPStatus, std::string, UsageServiceImplm_startupActiveMethod
 Async method for sending startup notifications. More...
 
Poco::Timer m_timer
 a timer More...
 
uint32_t m_timerTicks
 The number of timer ticks since the last reset. More...
 
uint32_t m_timerTicksTarget
 The number of timer ticks at which to reset. More...
 
std::string m_url
 Stores the base url of the usage system. More...
 

Friends

struct Mantid::Kernel::CreateUsingNew< UsageServiceImpl >
 

Detailed Description

Definition at line 58 of file UsageService.h.

Constructor & Destructor Documentation

◆ UsageServiceImpl() [1/2]

Mantid::Kernel::UsageServiceImpl::UsageServiceImpl ( )
protected

◆ ~UsageServiceImpl()

virtual Mantid::Kernel::UsageServiceImpl::~UsageServiceImpl ( )
protectedvirtualdefault

Destructor.

◆ UsageServiceImpl() [2/2]

Mantid::Kernel::UsageServiceImpl::UsageServiceImpl ( const UsageServiceImpl )
private

Private, unimplemented copy constructor.

Member Function Documentation

◆ clear()

void Mantid::Kernel::UsageServiceImpl::clear ( )

clear any buffers without sending any outstanding usage reports

Definition at line 160 of file UsageService.cpp.

References m_FeatureQueue.

◆ flush()

void Mantid::Kernel::UsageServiceImpl::flush ( )

flushes any buffers and sends any outstanding usage reports

Definition at line 165 of file UsageService.cpp.

References isEnabled(), and sendFeatureUsageReport().

Referenced by export_UsageService().

◆ generateFeatureHeader()

Json::Value Mantid::Kernel::UsageServiceImpl::generateFeatureHeader ( )
private

This puts together the system information for the json document.

Definition at line 232 of file UsageService.cpp.

References Mantid::Kernel::MantidVersion::versionShort().

Referenced by generateFeatureUsageMessage().

◆ generateFeatureUsageMessage()

std::string Mantid::Kernel::UsageServiceImpl::generateFeatureUsageMessage ( )
protectedvirtual

generates the message body for a feature usage message

Definition at line 273 of file UsageService.cpp.

References generateFeatureHeader(), m_FeatureQueue, and m_mutex.

Referenced by sendFeatureUsageReport().

◆ generateStartupMessage()

std::string Mantid::Kernel::UsageServiceImpl::generateStartupMessage ( )
protectedvirtual

generates the message body for a startup message

This puts together the system information for the json document.

Definition at line 244 of file UsageService.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance(), m_application, m_startTime, Mantid::Kernel::ChecksumHelper::md5FromString(), Mantid::Kernel::MantidVersion::revisionFull(), and Mantid::Kernel::MantidVersion::version().

Referenced by sendStartupReport().

◆ getApplicationName()

std::string Mantid::Kernel::UsageServiceImpl::getApplicationName ( ) const

Returns the application name that has invoked Mantid.

Definition at line 106 of file UsageService.cpp.

References m_application.

Referenced by export_UsageService(), and registerFeatureUsage().

◆ getStartTime()

Types::Core::DateAndTime Mantid::Kernel::UsageServiceImpl::getStartTime ( )
inline

Gets the start time of this mantid instance.

Definition at line 93 of file UsageService.h.

Referenced by export_UsageService().

◆ getUpTime()

Types::Core::time_duration Mantid::Kernel::UsageServiceImpl::getUpTime ( )

gets the uptime of this mantid instance

getUpTime returns the time for which the mantid instance has been running

Returns
time_duration The time for which mantid has been running.

Definition at line 174 of file UsageService.cpp.

References m_startTime.

Referenced by export_UsageService().

◆ isEnabled()

bool Mantid::Kernel::UsageServiceImpl::isEnabled ( ) const

Returns true if usage reporting is enabled.

Definition at line 147 of file UsageService.cpp.

References m_isEnabled.

Referenced by export_UsageService(), flush(), registerFeatureUsage(), and registerStartup().

◆ operator=()

UsageServiceImpl & Mantid::Kernel::UsageServiceImpl::operator= ( const UsageServiceImpl )
private

Private, unimplemented copy assignment operator.

◆ registerFeatureUsage() [1/3]

void Mantid::Kernel::UsageServiceImpl::registerFeatureUsage ( const FeatureType type,
const std::string &  name,
const bool  internal 
)

Version that takes a string if just registering usage of a class.

Definition at line 134 of file UsageService.cpp.

References getApplicationName(), isEnabled(), m_FeatureQueue, and m_mutex.

◆ registerFeatureUsage() [2/3]

void Mantid::Kernel::UsageServiceImpl::registerFeatureUsage ( const FeatureType type,
const std::vector< std::string > &  name,
const bool  internal 
)

registerFeatureUsage registers the use of a feature in mantid.

registerFeatureUsage

Provide three overloads: Version that takes vector of strings if want to register usage of a particular class/method combination

Definition at line 124 of file UsageService.cpp.

References getApplicationName(), isEnabled(), m_FeatureQueue, and m_mutex.

Referenced by registerFeatureUsage().

◆ registerFeatureUsage() [3/3]

void Mantid::Kernel::UsageServiceImpl::registerFeatureUsage ( const FeatureType type,
std::initializer_list< std::string >  name,
const bool  internal 
)

Version that accepts an initializer list.

This is required because {"abc","def"} is both a valid constructor for std::string and an initializer list so without this it's not clear which overload is being called

Definition at line 141 of file UsageService.cpp.

References registerFeatureUsage().

◆ registerStartup()

void Mantid::Kernel::UsageServiceImpl::registerStartup ( )

Registers the Startup of Mantid.

Definition at line 116 of file UsageService.cpp.

References isEnabled(), and sendStartupReport().

Referenced by export_UsageService().

◆ sendFeatureAsyncImpl()

InternetHelper::HTTPStatus Mantid::Kernel::UsageServiceImpl::sendFeatureAsyncImpl ( const std::string &  message)
private

Async method for sending feature messages.

Definition at line 321 of file UsageService.cpp.

References m_url, and sendReport().

Referenced by sendFeatureUsageReport().

◆ sendFeatureUsageReport()

void Mantid::Kernel::UsageServiceImpl::sendFeatureUsageReport ( const bool  synchronous = false)
private

◆ sendReport()

InternetHelper::HTTPStatus Mantid::Kernel::UsageServiceImpl::sendReport ( const std::string &  message,
const std::string &  url 
)
protectedvirtual

◆ sendStartupAsyncImpl()

InternetHelper::HTTPStatus Mantid::Kernel::UsageServiceImpl::sendStartupAsyncImpl ( const std::string &  message)
private

Asynchronous execution.

Async method for sending startup messages

Definition at line 315 of file UsageService.cpp.

References m_url, and sendReport().

◆ sendStartupReport()

void Mantid::Kernel::UsageServiceImpl::sendStartupReport ( )
private

◆ setApplicationName()

void Mantid::Kernel::UsageServiceImpl::setApplicationName ( const std::string &  name)

Sets the application name that has invoked Mantid.

Definition at line 104 of file UsageService.cpp.

References m_application.

Referenced by export_UsageService().

◆ setEnabled()

void Mantid::Kernel::UsageServiceImpl::setEnabled ( const bool  enabled)

Sets whether the UsageReporter is enabled.

Definition at line 149 of file UsageService.cpp.

References m_isEnabled, m_timer, and timerCallback().

Referenced by export_UsageService(), and shutdown().

◆ setInterval()

void Mantid::Kernel::UsageServiceImpl::setInterval ( const uint32_t  seconds = 60)

Sets the interval that the timer checks for tasks.

Definition at line 108 of file UsageService.cpp.

References m_timer, and m_timerTicksTarget.

Referenced by UsageServiceImpl().

◆ shutdown()

void Mantid::Kernel::UsageServiceImpl::shutdown ( )

◆ timerCallback()

void Mantid::Kernel::UsageServiceImpl::timerCallback ( Poco::Timer &  )
private

A method to handle the timerCallbacks.

Definition at line 215 of file UsageService.cpp.

References m_FeatureQueue, m_FeatureQueueSizeThreshold, m_timerTicks, m_timerTicksTarget, sendFeatureUsageReport(), and sendStartupReport().

Referenced by setEnabled().

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< UsageServiceImpl >

Definition at line 105 of file UsageService.h.

Member Data Documentation

◆ m_application

std::string Mantid::Kernel::UsageServiceImpl::m_application
private

Definition at line 140 of file UsageService.h.

Referenced by generateStartupMessage(), getApplicationName(), and setApplicationName().

◆ m_featureActiveMethod

Poco::ActiveMethod<InternetHelper::HTTPStatus, std::string, UsageServiceImpl> Mantid::Kernel::UsageServiceImpl::m_featureActiveMethod
private

Async method for sending feature notifications.

Definition at line 146 of file UsageService.h.

Referenced by sendFeatureUsageReport().

◆ m_FeatureQueue

std::queue<FeatureUsage> Mantid::Kernel::UsageServiceImpl::m_FeatureQueue
private

◆ m_FeatureQueueSizeThreshold

size_t Mantid::Kernel::UsageServiceImpl::m_FeatureQueueSizeThreshold
private

Definition at line 137 of file UsageService.h.

Referenced by timerCallback().

◆ m_isEnabled

bool Mantid::Kernel::UsageServiceImpl::m_isEnabled
private

Definition at line 138 of file UsageService.h.

Referenced by isEnabled(), and setEnabled().

◆ m_mutex

std::mutex Mantid::Kernel::UsageServiceImpl::m_mutex
mutableprivate

Definition at line 139 of file UsageService.h.

Referenced by generateFeatureUsageMessage(), and registerFeatureUsage().

◆ m_startTime

Types::Core::DateAndTime Mantid::Kernel::UsageServiceImpl::m_startTime
private

Definition at line 141 of file UsageService.h.

Referenced by generateStartupMessage(), and getUpTime().

◆ m_startupActiveMethod

Poco::ActiveMethod<InternetHelper::HTTPStatus, std::string, UsageServiceImpl> Mantid::Kernel::UsageServiceImpl::m_startupActiveMethod
private

Async method for sending startup notifications.

Definition at line 144 of file UsageService.h.

Referenced by sendStartupReport().

◆ m_timer

Poco::Timer Mantid::Kernel::UsageServiceImpl::m_timer
private

a timer

Definition at line 129 of file UsageService.h.

Referenced by setEnabled(), and setInterval().

◆ m_timerTicks

uint32_t Mantid::Kernel::UsageServiceImpl::m_timerTicks
private

The number of timer ticks since the last reset.

Definition at line 132 of file UsageService.h.

Referenced by timerCallback().

◆ m_timerTicksTarget

uint32_t Mantid::Kernel::UsageServiceImpl::m_timerTicksTarget
private

The number of timer ticks at which to reset.

Definition at line 134 of file UsageService.h.

Referenced by setInterval(), and timerCallback().

◆ m_url

std::string Mantid::Kernel::UsageServiceImpl::m_url
private

Stores the base url of the usage system.

Definition at line 149 of file UsageService.h.

Referenced by sendFeatureAsyncImpl(), sendStartupAsyncImpl(), and UsageServiceImpl().


The documentation for this class was generated from the following files: