TPIE

2362a60
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 47 of file sysinfo.h.

Constructor & Destructor Documentation

tpie::sysinfo::sysinfo ( )
inline

Default constructor.

Definition at line 51 of file sysinfo.h.

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

Member Function Documentation

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

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

Definition at line 86 of file sysinfo.h.

Referenced by tpie::operator<<().

86 { return m_blocksize; }
std::string tpie::sysinfo::commit ( ) const
inline

Git commit hash.

See also
tpie::git_commit

Definition at line 63 of file sysinfo.h.

References tpie::git_commit.

Referenced by tpie::operator<<().

63 { return git_commit; }
const char * git_commit
The Git commit hash (40 hexadecimal characters) that TPIE was built from.
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 122 of file sysinfo.h.

Referenced by printinfo().

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

System hostname as reported by Boost ASIO.

Definition at line 81 of file sysinfo.h.

Referenced by tpie::operator<<().

81 { return m_hostname; }
std::string tpie::sysinfo::localtime ( ) const
inline

Local date and time in a human-readable format.

Definition at line 91 of file sysinfo.h.

Referenced by tpie::operator<<().

91  {
92  boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
93  return to_simple_string(now);
94  }
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 76 of file sysinfo.h.

Referenced by tpie::operator<<().

76 { return m_platform; }
template<typename V >
void tpie::sysinfo::printinfo ( std::string  key,
const V &  value 
)
inline

Print custom info to std::cout.

Definition at line 134 of file sysinfo.h.

References custominfo().

134  {
135  std::cout << custominfo(key, value) << std::endl;
136  }
std::string custominfo(std::string key, const V &value)
Helper function to make a custom key-value line.
Definition: sysinfo.h:122
std::string tpie::sysinfo::refspec ( ) const
inline

Git refspec.

See also
tpie::git_refspec

Definition at line 69 of file sysinfo.h.

References tpie::git_refspec.

Referenced by tpie::operator<<().

69 { return git_refspec; }
const char * git_refspec
The Git refspec that TPIE was built from.

The documentation for this struct was generated from the following file: