SHOGUN  6.1.3
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
SGIO Class Reference

Detailed Description

Class SGIO, used to do input output operations throughout shogun.

Any debug or error or progress message is passed through the functions of this class to be in the end written to the screen. Note that messages don't have to be written to stdout or stderr, but can be redirected to a file.

Definition at line 218 of file SGIO.h.

Public Member Functions

 SGIO ()
 
 SGIO (const SGIO &orig)
 
virtual ~SGIO ()
 
void set_loglevel (EMessageType level)
 
EMessageType get_loglevel () const
 
bool loglevel_above (EMessageType type) const
 
bool get_show_progress () const
 
EMessageLocation get_location_info () const
 
bool get_syntax_highlight () const
 
void message (EMessageType prio, const char *function, const char *file, int32_t line, const char *fmt,...) const
 
void done ()
 
void not_implemented (const char *function, const char *file, int32_t line) const
 
void gpl_only (const char *function, const char *file, int32_t line) const
 
void deprecated (const char *function, const char *file, int32_t line) const
 
void buffered_message (EMessageType prio, const char *fmt,...) const
 
FILE * get_target () const
 
void set_target (FILE *target)
 
void set_target_to_stderr ()
 
void set_target_to_stdout ()
 
void enable_progress ()
 
void disable_progress ()
 
void set_location_info (EMessageLocation location)
 
void enable_syntax_highlighting ()
 
void disable_syntax_highlighting ()
 
int32_t ref ()
 
int32_t ref_count () const
 
int32_t unref ()
 
const char * get_name ()
 

Static Public Member Functions

static char * skip_spaces (char *str)
 
static char * skip_blanks (char *str)
 
static void set_dirname (const char *dirname)
 
static char * concat_filename (const char *filename)
 
static int filter (CONST_DIRENT_T *d)
 
static char * c_string_of_substring (substring s)
 
static void print_substring (substring s)
 
static float32_t float_of_substring (substring s)
 
static float64_t double_of_substring (substring s)
 
static int32_t int_of_substring (substring s)
 
static uint32_t ulong_of_substring (substring s)
 
static uint32_t ss_length (substring s)
 

Protected Member Functions

const char * get_msg_intro (EMessageType prio) const
 

Protected Attributes

FILE * target
 
bool show_progress
 
EMessageLocation location_info
 
bool syntax_highlight
 
EMessageType loglevel
 

Static Protected Attributes

static const EMessageType levels [NUM_LOG_LEVELS]
 
static const char * message_strings_highlighted [NUM_LOG_LEVELS]
 
static const char * message_strings [NUM_LOG_LEVELS]
 
static char file_buffer [FBUFSIZE]
 file name buffer More...
 
static char directory_name [FBUFSIZE]
 directory name buffer More...
 

Constructor & Destructor Documentation

◆ SGIO() [1/2]

SGIO ( )

default constructor

Definition at line 55 of file SGIO.cpp.

◆ SGIO() [2/2]

SGIO ( const SGIO orig)

copy constructor

Definition at line 62 of file SGIO.cpp.

◆ ~SGIO()

~SGIO ( )
virtual

destructor

Definition at line 309 of file SGIO.cpp.

Member Function Documentation

◆ buffered_message()

void buffered_message ( EMessageType  prio,
const char *  fmt,
  ... 
) const

print a buffered message

Parameters
priomessage priority
fmtformat string

Definition at line 138 of file SGIO.cpp.

◆ c_string_of_substring()

char * c_string_of_substring ( substring  s)
static

Return a C string from the substring

Parameters
ssubstring
Returns
new C string representation

Definition at line 225 of file SGIO.cpp.

◆ concat_filename()

char * concat_filename ( const char *  filename)
static

concatenate directory and filename ( non thread safe )

Parameters
filenamenew filename
Returns
concatenated directory and filename

Definition at line 279 of file SGIO.cpp.

◆ deprecated()

void deprecated ( const char *  function,
const char *  file,
int32_t  line 
) const

print warning message 'function deprecated'

Definition at line 309 of file SGIO.h.

◆ disable_progress()

void disable_progress ( )

disable progress bar

Definition at line 368 of file SGIO.h.

◆ disable_syntax_highlighting()

void disable_syntax_highlighting ( )

disable syntax highlighting

Definition at line 400 of file SGIO.h.

◆ done()

void done ( )

print 'done' with priority INFO, but only if progress bar is enabled

Definition at line 153 of file SGIO.cpp.

◆ double_of_substring()

float64_t double_of_substring ( substring  s)
static

Return value of substring as double

Parameters
ssubstring
Returns
substring as double

Definition at line 250 of file SGIO.cpp.

◆ enable_progress()

void enable_progress ( )

enable progress bar

Definition at line 358 of file SGIO.h.

◆ enable_syntax_highlighting()

void enable_syntax_highlighting ( )

enable syntax highlighting

Definition at line 391 of file SGIO.h.

◆ filter()

int filter ( CONST_DIRENT_T d)
static

filter

Parameters
ddirectory entry
Returns
1 if d is a readable file

Definition at line 292 of file SGIO.cpp.

◆ float_of_substring()

float32_t float_of_substring ( substring  s)
static

Get value of substring as float (if possible)

Parameters
ssubstring
Returns
float32_t value of substring

Definition at line 240 of file SGIO.cpp.

◆ get_location_info()

EMessageLocation get_location_info ( ) const

show location where printing occurs

Definition at line 262 of file SGIO.h.

◆ get_loglevel()

EMessageType get_loglevel ( ) const

get loglevel

Returns
level of log messages

Definition at line 189 of file SGIO.cpp.

◆ get_msg_intro()

const char * get_msg_intro ( EMessageType  prio) const
protected

get message intro

Parameters
priomessage priority
Returns
message intro or NULL if message is not to be printed

Definition at line 204 of file SGIO.cpp.

◆ get_name()

const char* get_name ( )
Returns
object name

Definition at line 505 of file SGIO.h.

◆ get_show_progress()

bool get_show_progress ( ) const

get show_progress

Returns
if progress bar is shown

Definition at line 255 of file SGIO.h.

◆ get_syntax_highlight()

bool get_syntax_highlight ( ) const

get syntax highlight

Returns
if syntax highlighting is enabled

Definition at line 271 of file SGIO.h.

◆ get_target()

FILE* get_target ( ) const

get target

Returns
file descriptor for target

Definition at line 340 of file SGIO.h.

◆ gpl_only()

void gpl_only ( const char *  function,
const char *  file,
int32_t  line 
) const

print error message 'Only available with GPL parts.'

Definition at line 303 of file SGIO.h.

◆ int_of_substring()

int32_t int_of_substring ( substring  s)
static

Integer value of substring

Parameters
ssubstring
Returns
int value of substring

Definition at line 260 of file SGIO.cpp.

◆ loglevel_above()

bool loglevel_above ( EMessageType  type) const

loglevel above

Returns
whether loglevel is above specified level and thus the message should be printed

Definition at line 246 of file SGIO.h.

◆ message()

void message ( EMessageType  prio,
const char *  function,
const char *  file,
int32_t  line,
const char *  fmt,
  ... 
) const

print a message

optionally prefixed with file name and line number from (use -1 in line to disable this)

Parameters
priomessage priority
functionthe function name from where the message is called
filefile name from where the message is called
lineline number from where the message is called
fmtformat string

Definition at line 71 of file SGIO.cpp.

◆ not_implemented()

void not_implemented ( const char *  function,
const char *  file,
int32_t  line 
) const

print error message 'not implemented'

Definition at line 297 of file SGIO.h.

◆ print_substring()

void print_substring ( substring  s)
static

Print the substring

Parameters
ssubstring

Definition at line 233 of file SGIO.cpp.

◆ ref()

int32_t ref ( )

increase reference counter

Returns
reference count

Definition at line 314 of file SGIO.cpp.

◆ ref_count()

int32_t ref_count ( ) const

display reference counter

Returns
reference count

Definition at line 319 of file SGIO.cpp.

◆ set_dirname()

static void set_dirname ( const char *  dirname)
static

set directory name

Parameters
dirnamenew directory name

Definition at line 412 of file SGIO.h.

◆ set_location_info()

void set_location_info ( EMessageLocation  location)

enable displaying of file and line when printing messages etc

Parameters
locationlocation info (none, function, ...)

Definition at line 382 of file SGIO.h.

◆ set_loglevel()

void set_loglevel ( EMessageType  level)

set loglevel

Parameters
levellevel of log messages

Definition at line 194 of file SGIO.cpp.

◆ set_target()

void set_target ( FILE *  target)

set target

Parameters
targetfile descriptor for target

Definition at line 199 of file SGIO.cpp.

◆ set_target_to_stderr()

void set_target_to_stderr ( )

set target to stderr

Definition at line 352 of file SGIO.h.

◆ set_target_to_stdout()

void set_target_to_stdout ( )

set target to stdout

Definition at line 355 of file SGIO.h.

◆ skip_blanks()

char * skip_blanks ( char *  str)
static

skip leading spaces + tabs

Parameters
strstring in which to look for blanks
Returns
string after after skipping leading blanks

Definition at line 175 of file SGIO.cpp.

◆ skip_spaces()

char * skip_spaces ( char *  str)
static

skip leading spaces

Parameters
strstring in which to look for spaces
Returns
string after after skipping leading spaces

Definition at line 161 of file SGIO.cpp.

◆ ss_length()

uint32_t ss_length ( substring  s)
static

Length of substring

Parameters
ssubstring
Returns
length of substring

Definition at line 274 of file SGIO.cpp.

◆ ulong_of_substring()

uint32_t ulong_of_substring ( substring  s)
static

Unsigned long value of substring

Parameters
ssubstring
Returns
unsigned long value of substring

Definition at line 269 of file SGIO.cpp.

◆ unref()

int32_t unref ( )

decrement reference counter and deallocate object if refcount is zero before or after decrementing it

Returns
reference count

Definition at line 324 of file SGIO.cpp.

Member Data Documentation

◆ directory_name

char directory_name
staticprotected

directory name buffer

directory name (for filter function)

Definition at line 539 of file SGIO.h.

◆ file_buffer

char file_buffer
staticprotected

file name buffer

file buffer

Definition at line 537 of file SGIO.h.

◆ levels

const EMessageType levels
staticprotected
Initial value:

available log levels

Definition at line 530 of file SGIO.h.

◆ location_info

EMessageLocation location_info
protected

if each print function should append filename and linenumber of where the print occurs etc

Definition at line 523 of file SGIO.h.

◆ loglevel

EMessageType loglevel
protected

log level

Definition at line 528 of file SGIO.h.

◆ message_strings

const char * message_strings
staticprotected
Initial value:
={"[GCDEBUG] \0", "[DEBUG] \0", "[INFO] \0",
"[NOTICE] \0", "[WARN] \0", "[ERROR] \0",
"[CRITICAL] \0", "[ALERT] \0", "[EMERGENCY] \0", "\0"}

message strings

Definition at line 534 of file SGIO.h.

◆ message_strings_highlighted

const char * message_strings_highlighted
staticprotected
Initial value:
={"[GCDEBUG] \0", "[DEBUG] \0", "[INFO] \0",
"[NOTICE] \0", "\033[1;34m[WARN]\033[0m \0", "\033[1;31m[ERROR]\033[0m \0",
"[CRITICAL] \0", "[ALERT] \0", "[EMERGENCY] \0", "\0"}

message strings syntax highlighted

Definition at line 532 of file SGIO.h.

◆ show_progress

bool show_progress
protected

if progress bar shall be shown

Definition at line 520 of file SGIO.h.

◆ syntax_highlight

bool syntax_highlight
protected

whether syntax highlighting is enabled

Definition at line 525 of file SGIO.h.

◆ target

FILE* target
protected

target file

Definition at line 518 of file SGIO.h.


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

SHOGUN Machine Learning Toolbox - Documentation