GlobalBpiLib
1.0
|
#include "include/json.hpp"
#include <string>
#include <sstream>
#include <vector>
#include <csignal>
#include <chrono>
Go to the source code of this file.
Classes | |
class | BpiOutStream |
Custom bpi printer class. More... | |
class | DebugOutStream |
Custom debug printer class. More... | |
class | Configuration |
Interface between the application and a local stored json file. More... | |
class | Timer |
Simple timer with µs precision. More... | |
Macros | |
#define | STAMPLENGTH 6 |
#define | GEN_BUFFERSIZE 4096 |
#define | DLE "\x10" |
#define | ST_UDP 1 |
#define | ST_RAW 0 |
#define | SOCKETTYPE ST_RAW |
Functions | |
void | bpiSetName (std::string name) |
std::string | bpiGetName () |
bool | registerChild (int pid) |
bool | deregisterChild (int pid) |
std::vector< int > | getAllChilds () |
void | sigtermHandler (int signum) |
void | bpiSystemCall (std::string cmd, int(*printFct)(std::string)=nullptr, int(*printErrFct)(std::string)=nullptr) |
void | bpiSystemCall2 (std::string cmd, int(*printFct)(std::string)=nullptr, int(*printErrFct)(std::string)=nullptr, std::string cmdId="") |
std::string | bpiTimestamp () |
std::vector< std::string > | bpiSplitIntoItems (std::string str, char delimiter) |
std::string | bpiGetNamestamp (std::string name) |
std::string | bpiGetNamestampErr (std::string name) |
std::string | bpiConfirm (std::string command, std::string optional) |
bool | readInputFromStdin (std::string *s, int bufsize=BUFSIZ) |
int | readFromFileDescriptor (int fileDescriptor, std::string &data, int buffersize) |
int | writeToFileDescriptor (int fileDescriptor, std::string data) |
std::string | createCtrlMessage (int argc,...) |
std::string | createStatCtrlMessage (int argc,...) |
std::string | macToString (int len, char *mac) |
double | getCurrentCpuUsage () |
Provides a number of general functions and classes for different use cases, which should be needed in all implementations relating the BananaNetworkTower Project. This class needs obligatory the counterpart header LocalBpiLib.h, containing the following definitions
#define STAMPLENGTH 6 |
Length of Namestamps.
std::string bpiConfirm | ( | std::string | command, |
std::string | optional | ||
) |
Creates a confirmation for the specified command.
std::string bpiGetNamestamp | ( | std::string | name | ) |
Creates a namestamp depending on the specified parameter.
std::string bpiGetNamestampErr | ( | std::string | name | ) |
Creates a namestamp depending on the specified parameter.
void bpiSetName | ( | std::string | name | ) |
Overwrites the name placeholder string bpiName.
std::vector<std::string> bpiSplitIntoItems | ( | std::string | str, |
char | delimiter | ||
) |
Splits string into a vector of items.
void bpiSystemCall | ( | std::string | cmd, |
int(*)(std::string) | printFct, | ||
int(*)(std::string) | printErrFct | ||
) |
Performs a sequential system call. Optional pointer to printer functions may be specified as parameter.
Invokes a system call. The programm waits until the system call is finished and prints to stdout and stderr.
cmd | Command to be executed by the system |
printFct | Pointer to a printer function |
printErrFct | Pointer to an error printer function |
void bpiSystemCall2 | ( | std::string | cmd, |
int(*)(std::string) | printFct, | ||
int(*)(std::string) | printErrFct, | ||
std::string | cmdId | ||
) |
Performs a concurrent system call. Optional pointer to printer functions may be specified as parameter.
Invokes a system call. The call runs concurrently to the application and prints to stdout and stderr.
cmd | Command to be executed by the system |
printFct | Pointer to a printer function |
printErrFct | Pointer to an error printer function |
std::string bpiTimestamp | ( | ) |
Creates a timestamp.
std::string createCtrlMessage | ( | int | argc, |
... | |||
) |
Creates a control message.
Creates a control message, consisting of argc many char* strings , separated each by a semicolon. The result is enclosed by the control character DLE. A control message may not contain any line breaks.
argc | Number of arguments in the argumentvector |
std::string createStatCtrlMessage | ( | int | argc, |
... | |||
) |
Creates a control message.
Creates a control message, consisting of argc many char* strings , separated each by a semicolon. The result is enclosed by the control character DLE. A control message may not contain any line breaks.
argc | Number of arguments in the argumentvector |
bool deregisterChild | ( | int | pid | ) |
Deregisters a forked child by removing its pid from the vector childs.
std::vector<int> getAllChilds | ( | ) |
Returns the complete vector of all forked child processes.
int readFromFileDescriptor | ( | int | fileDescriptor, |
std::string & | data, | ||
int | buffersize | ||
) |
Reads data from a file descriptor.
bool registerChild | ( | int | pid | ) |
Registers a new forked child by appending its pid to the vector childs.
void sigtermHandler | ( | int | signum | ) |
A handler for the signal SIGTERM. All forked processes in childs will be killed first by sending SIGTERM to them.
int writeToFileDescriptor | ( | int | fileDescriptor, |
std::string | data | ||
) |
Writes data to a file descriptor.