TPIE

11a2c2d
tpie::sysinfo Struct Reference

Class providing system and platform info. More...

#include <tpie/sysinfo.h>

Public Member Functions

 sysinfo ()
 Default constructor. More...
 
std::string commit () const
 Git commit hash. More...
 
std::string refspec () const
 Git refspec. More...
 
std::string platform () const
 Platform description. More...
 
std::string hostname () const
 System hostname as reported by Boost ASIO. More...
 
std::string blocksize () const
 Block size used by tpie::ami::stream. More...
 
std::string localtime () const
 Local date and time in a human-readable format. More...
 
template<typename V >
std::string custominfo (std::string key, const V &value)
 Helper function to make a custom key-value line. More...
 
template<typename V >
void printinfo (std::string key, const V &value)
 Print custom info to std::cout. More...
 

Static Public Member Functions

static memory_size_type blocksize_bytes ()
 

Detailed Description

Class providing system and platform info.

Definition at line 48 of file sysinfo.h.

Constructor & Destructor Documentation

◆ sysinfo()

tpie::sysinfo::sysinfo ( )
inline

Default constructor.

Definition at line 52 of file sysinfo.h.

53  : m_platform(calc_platform())
54  , m_hostname(calc_hostname())
55  , m_blocksize(calc_blocksize())
56  {
57  // Does nothing.
58  }

Member Function Documentation

◆ blocksize()

std::string tpie::sysinfo::blocksize ( ) const
inline

Block size used by tpie::ami::stream.

Definition at line 87 of file sysinfo.h.

87 { return m_blocksize; }

Referenced by tpie::operator<<().

◆ commit()

std::string tpie::sysinfo::commit ( ) const
inline

Git commit hash.

See also
tpie::git_commit

Definition at line 64 of file sysinfo.h.

64 { return git_commit; }

References tpie::git_commit.

Referenced by tpie::operator<<().

◆ custominfo()

template<typename V >
std::string tpie::sysinfo::custominfo ( std::string  key,
const V &  value 
)
inline

Helper function to make a custom key-value line.

std::cout << i;
std::cout << i.custominfo("Verbosity", m_verbose ? "On" : "Off")
<< std::endl
<< i.custominfo("", "Starting test") << std::endl;

could print out

"Hostname: sanford"
"Platform: Linux 64-bit"
"Git branch: refs/heads/master"
"Git commit: 5f0bebba1f4b2b53f4bb4d5709d3d347bc469dc9"
"Local time: 2012-Mar-13 11:17:33"
"Block size: 2048 KiB"
"Verbosity: On"
" Starting test"
Parameters
keyText to display in left column. Should be at most 14 characters.
valueText to display in right column. Should be at most 63 characters.

Definition at line 123 of file sysinfo.h.

123  {
124  std::stringstream builder;
125  if (key != "") key += ':';
126  builder.flags(std::ios::left);
127  builder << std::setw(16) << key << value;
128  return builder.str();
129  }

Referenced by printinfo().

◆ hostname()

std::string tpie::sysinfo::hostname ( ) const
inline

System hostname as reported by Boost ASIO.

Definition at line 82 of file sysinfo.h.

82 { return m_hostname; }

Referenced by tpie::operator<<().

◆ localtime()

std::string tpie::sysinfo::localtime ( ) const
inline

Local date and time in a human-readable format.

Definition at line 92 of file sysinfo.h.

92  {
93  boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
94  return to_simple_string(now);
95  }

Referenced by tpie::operator<<().

◆ platform()

std::string tpie::sysinfo::platform ( ) const
inline

Platform description.

Currently "Windows" or "Linux" followed by "32-bit" or "64-bit" depending on the WIN32 compile-time define and sizeof(size_t).

Definition at line 77 of file sysinfo.h.

77 { return m_platform; }

Referenced by tpie::operator<<().

◆ printinfo()

template<typename V >
void tpie::sysinfo::printinfo ( std::string  key,
const V &  value 
)
inline

Print custom info to std::cout.

Definition at line 135 of file sysinfo.h.

135  {
136  std::cout << custominfo(key, value) << std::endl;
137  }

References custominfo().

◆ refspec()

std::string tpie::sysinfo::refspec ( ) const
inline

Git refspec.

See also
tpie::git_refspec

Definition at line 70 of file sysinfo.h.

70 { return git_refspec; }

References tpie::git_refspec.

Referenced by tpie::operator<<().


The documentation for this struct was generated from the following file:
tpie::git_refspec
const TPIE_EXPORT char * git_refspec
The Git refspec that TPIE was built from.
tpie::sysinfo::sysinfo
sysinfo()
Default constructor.
Definition: sysinfo.h:52
tpie::git_commit
const TPIE_EXPORT char * git_commit
The Git commit hash (40 hexadecimal characters) that TPIE was built from.
tpie::sysinfo::custominfo
std::string custominfo(std::string key, const V &value)
Helper function to make a custom key-value line.
Definition: sysinfo.h:123