Loading...
Searching...
No Matches
casacore::HostInfo Class Reference
casa package (libcasa_casa) » OS_module

More...

`#include <HostInfo.h>`

## Static Public Member Functions

static String | hostName ()
static Int | processID ()
static Double | secondsFrom1970 ()
static Bool | bigEndian ()
| Returns True for big endian machines (like SUN).
static Int | numCPUs (bool use_aipsrc=false)
| Returns 0 if unable to determine the number of CPUs.
static ptrdiff_t | memoryTotal (bool use_aipsrc=false)
| Get memory info (in KBytes).
static ptrdiff_t | memoryUsed ()
static ptrdiff_t | memoryFree ()
static ptrdiff_t | swapTotal ()
| Get swap space info (in KBytes).
static ptrdiff_t | swapUsed ()
static ptrdiff_t | swapFree ()
static ptrdiff_t | setMemoryTotal (ptrdiff_t memory)
| Allows to set custom resource values overriding the existing.apisrc setting and/or system defaults Expected unit are KiB for memory total and percentage (%) for memory fraction Returns the value previously stored.
static Int | setMemoryFraction (Int memfrac)
static Int | setNumCPUs (Int numCPUs)

## Private Member Functions

| HostInfo ()
| we don't want folks creating these...
const HostInfo & | operator= (const HostInfo &)

## Static Private Attributes

static HostMachineInfo * | info
static ptrdiff_t | resources_memory
static Int | resources_memfrac
static Int | resources_numCPUs

## Detailed Description

Miscellaneous information about this host and process.

### Intended use:

Public interface

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25

### Prerequisite

- None

### Synopsis

This class is meant to encapsulate miscellaneous information about the environment that the current process is running in.

At present, the class can be used to obtain the name of the host on which this process is running, the process id of this process, the amount of physical memory (total, used, & free) on this host, the amount of swap space (total, used, and free), the number of CPUs on this host, and a count of the number of seconds from January 1, 1970. Generally you should use the classes Time and MVTime if your primary interest is related to time and dates. If your interest is in timing, you would generally use class Timer, which can also report CPU times as well as "clock" times.

Determination of the number of CPUs, swap space, and physical memory is particularly OS dependent. In cases where this functionality has not yet been implemented, the memory and swap functions will return -1 and the CPU function will return 0.

### Example

cout << "I am process #" << HostInfo::processID() << " running on host " <<
HostInfo::hostName() << ", which has " << HostInfor::numCPUs() << " CPUs." << endl;
cout << "This host has " << HostInfo::memoryTotal() << "K of memory [ " <<
HostInfo::memoryUsed() << " used, " <<
HostInfo::memoryFree() << " free ]." << endl;
cout << "This host has " << HostInfo::swapTotal() << "K of swap space [ " <<
HostInfo::swapUsed() << " used, " <<
HostInfo::swapFree() << " free ]." << endl;
Double now = HostInfo::secondsFrom1970();
doSomething();
cout << "Function doSomething() took " <<
HostInfo::secondsFrom1970() - now << " seconds to execute." << endl;
casacore::HostInfo::processID
static Int processID()
casacore::HostInfo::swapFree
static ptrdiff_t swapFree()
casacore::HostInfo::swapTotal
static ptrdiff_t swapTotal()
Get swap space info (in KBytes).
casacore::HostInfo::secondsFrom1970
static Double secondsFrom1970()
casacore::HostInfo::memoryFree
static ptrdiff_t memoryFree()
casacore::HostInfo::swapUsed
static ptrdiff_t swapUsed()
casacore::HostInfo::memoryTotal
static ptrdiff_t memoryTotal(bool use_aipsrc=false)
Get memory info (in KBytes).
casacore::HostInfo::memoryUsed
static ptrdiff_t memoryUsed()
casacore::HostInfo::hostName
static String hostName()
casacore::Double
double Double
Definition aipstype.h:53

### Motivation

The ObjectID class uses a combination of hostname, process id, time, and a sequence number to ensure that ObjectID's are distinct. This class encapsulates the way the first three of those items are obtained.

### To Do

- OS version?

Definition at line 100 of file HostInfo.h.

## Constructor & Destructor Documentation

## HostInfo()

casacore::HostInfo::HostInfo | ( |  | ) |

private

we don't want folks creating these...

Referenced by operator=().

## Member Function Documentation

## bigEndian()

Bool casacore::HostInfo::bigEndian | ( |  | ) |

inline static

Returns True for big endian machines (like SUN).

Returns False for little endian machines (like PC).

Definition at line 154 of file HostInfo.h.

References casacore::False, and casacore::True.

## hostName()

String casacore::HostInfo::hostName | ( |  | ) |

static

## memoryFree()

ptrdiff_t casacore::HostInfo::memoryFree | ( |  | ) |

static

## memoryTotal()

ptrdiff_t casacore::HostInfo::memoryTotal | ( | bool | use_aipsrc = false | ) |

static

Get memory info (in KBytes).

Returns -1 if unable to determine memory info.

## memoryUsed()

ptrdiff_t casacore::HostInfo::memoryUsed | ( |  | ) |

static

## numCPUs()

Int casacore::HostInfo::numCPUs | ( | bool | use_aipsrc = false | ) |

static

Returns 0 if unable to determine the number of CPUs.

Referenced by setNumCPUs().

## operator=()

const HostInfo & casacore::HostInfo::operator= | ( | const HostInfo & |  | ) |

private

References HostInfo().

## processID()

Int casacore::HostInfo::processID | ( |  | ) |

static

## secondsFrom1970()

Double casacore::HostInfo::secondsFrom1970 | ( |  | ) |

static

## setMemoryFraction()

Int casacore::HostInfo::setMemoryFraction | ( | Int | memfrac | ) |

static

## setMemoryTotal()

ptrdiff_t casacore::HostInfo::setMemoryTotal | ( | ptrdiff_t | memory | ) |

static

Allows to set custom resource values overriding the existing.apisrc setting and/or system defaults Expected unit are KiB for memory total and percentage (%) for memory fraction Returns the value previously stored.

## setNumCPUs()

Int casacore::HostInfo::setNumCPUs | ( | Int | numCPUs | ) |

static

References numCPUs().

## swapFree()

ptrdiff_t casacore::HostInfo::swapFree | ( |  | ) |

static

## swapTotal()

ptrdiff_t casacore::HostInfo::swapTotal | ( |  | ) |

static

Get swap space info (in KBytes).

Returns -1 if unable to determine swap info.

## swapUsed()

ptrdiff_t casacore::HostInfo::swapUsed | ( |  | ) |

static

## Member Data Documentation

## info

HostMachineInfo* casacore::HostInfo::info

static private

Definition at line 147 of file HostInfo.h.

## resources_memfrac

Int casacore::HostInfo::resources_memfrac

static private

Definition at line 149 of file HostInfo.h.

## resources_memory

ptrdiff_t casacore::HostInfo::resources_memory

static private

Definition at line 148 of file HostInfo.h.

## resources_numCPUs

Int casacore::HostInfo::resources_numCPUs

static private

Definition at line 150 of file HostInfo.h.

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

- casa/OS/HostInfo.h