LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
lsst::ctrl::events::Host Class Reference

This object represents the host that is being used to transmit events, giving quick access to often-used host information. More...

#include <Host.h>

Public Member Functions

unsigned int const getIPAddress ()
 get the IP address More...
 
std::string const & getHostName ()
 get the host name More...
 

Static Public Member Functions

static Host const & getHost ()
 get the Host object, which can access the host and ip address. More...
 

Static Protected Attributes

static HostthisHost = 0
 
static std::string _hostname
 
static unsigned int _IPAddr = 0
 

Detailed Description

This object represents the host that is being used to transmit events, giving quick access to often-used host information.

Definition at line 48 of file Host.h.

Member Function Documentation

Host const & lsst::ctrl::events::Host::getHost ( )
static

get the Host object, which can access the host and ip address.

Returns
The Host object

Definition at line 49 of file Host.cc.

49  {
50  if (thisHost == 0) {
51 
52  // create the _IPAddr here, rather than
53  // reconstructing it every time we create an
54  // identificationId
55 
56  long int host_len = sysconf(_SC_HOST_NAME_MAX)+1; // add one for the null
57 
58  std::vector<char> vec;
59  vec.resize(host_len);
60 
61  struct hostent *ent;
62  unsigned char a,b,c,d;
63 
64  if (gethostname(vec.data(), vec.size()) == 0) {
65  _hostname = std::string(vec.data());
66  } else {
67  std::string msg("call to gethostname() failed");
68  throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
69  }
70 
71  ent = (struct hostent *)gethostbyname(_hostname.c_str());
72  if (ent == NULL) {
73  std::string msg("call to gethostbyname() failed");
74  throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
75  }
76 
77  a = ent->h_addr_list[0][0] & 0xFF;
78  b = ent->h_addr_list[0][1] & 0xFF;
79  c = ent->h_addr_list[0][2] & 0xFF;
80  d = ent->h_addr_list[0][3] & 0xFF;
81 
82  _IPAddr = (a << 24) | (b << 16) | (c << 8) | d;
83 
84  // create the default EventSystem object
85  thisHost = new Host();
86  }
87  return *thisHost;
88 
89 }
static std::string _hostname
Definition: Host.h:72
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afw::table::Key< double > b
static Host * thisHost
Definition: Host.h:70
static unsigned int _IPAddr
Definition: Host.h:73
std::string const & lsst::ctrl::events::Host::getHostName ( )

get the host name

Returns
a std::string containing the name of the hsot

Definition at line 99 of file Host.cc.

99  {
100  return _hostname;
101 }
static std::string _hostname
Definition: Host.h:72
unsigned int const lsst::ctrl::events::Host::getIPAddress ( )

get the IP address

Returns
an integer representing the IP address

Definition at line 95 of file Host.cc.

95  {
96  return _IPAddr;
97 }
static unsigned int _IPAddr
Definition: Host.h:73

Member Data Documentation

std::string lsst::ctrl::events::Host::_hostname
staticprotected

Definition at line 72 of file Host.h.

unsigned int lsst::ctrl::events::Host::_IPAddr = 0
staticprotected

Definition at line 73 of file Host.h.

Host * lsst::ctrl::events::Host::thisHost = 0
staticprotected

Definition at line 70 of file Host.h.


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