SPH
Functions
Platform.h File Reference

System functions. More...

#include "objects/wrappers/Expected.h"
#include "objects/wrappers/Outcome.h"
#include <stdio.h>

Go to the source code of this file.

Functions

Expected< PathgetExecutablePath ()
 Returns the absolute path to the currently running executable. More...
 
Outcome sendMail (const std::string &to, const std::string &from, const std::string &subject, const std::string &message)
 Sends a mail with given message. More...
 
Outcome showNotification (const std::string &title, const std::string &message)
 Shows a notification using 'notify-send' command. More...
 
Outcome sendPushNotification (const std::string &key, const std::string &title, const std::string &message)
 Sends a push notification to an Android device, using SimplePush API. More...
 
Expected< std::string > getGitCommit (const Path &pathToGitRoot, const Size prev=0)
 Returns git commit hash of the current or older commit as string. More...
 
Optional< FloatgetCpuUsage ()
 
bool isDebuggerPresent ()
 Returns true if the program is running with attached debugger. More...
 

Detailed Description

System functions.

Author
Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file Platform.h.

Function Documentation

◆ getCpuUsage()

Optional<Float> getCpuUsage ( )

Definition at line 144 of file Platform.cpp.

◆ getExecutablePath()

Expected<Path> getExecutablePath ( )

Returns the absolute path to the currently running executable.

Definition at line 15 of file Platform.cpp.

◆ getGitCommit()

Expected<std::string> getGitCommit ( const Path pathToGitRoot,
const Size  prev = 0 
)

Returns git commit hash of the current or older commit as string.

If the git repository is not found or command fails, returns error message

Parameters
pathToGitRootPath to where the source code is located
prevNumber of commits into the history. For 0, the current commit is returned.

Definition at line 63 of file Platform.cpp.

◆ isDebuggerPresent()

bool isDebuggerPresent ( )

Returns true if the program is running with attached debugger.

Definition at line 149 of file Platform.cpp.

◆ sendMail()

Outcome sendMail ( const std::string &  to,
const std::string &  from,
const std::string &  subject,
const std::string &  message 
)

Sends a mail with given message.

Definition at line 26 of file Platform.cpp.

◆ sendPushNotification()

Outcome sendPushNotification ( const std::string &  key,
const std::string &  title,
const std::string &  message 
)

Sends a push notification to an Android device, using SimplePush API.

Requires installed curl on the system.

Parameters
keySimplePush key of the Android device.
titleTitle of the notification.
messageNotification message.

Definition at line 53 of file Platform.cpp.

◆ showNotification()

Outcome showNotification ( const std::string &  title,
const std::string &  message 
)

Shows a notification using 'notify-send' command.

The function is non-blocking, the notification disappears on timeout or when user hides it.

Definition at line 44 of file Platform.cpp.