DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
OksSystem::LocalHost Class Reference

Network host - localhost. More...

#include <Host.hpp>

Inheritance diagram for OksSystem::LocalHost:
[legend]
Collaboration diagram for OksSystem::LocalHost:
[legend]

Public Member Functions

 LocalHost () throw ()
 ~LocalHost () throw ()
const std::string & os_name () const throw ()
 name of the operating system
const std::string & os_release () const throw ()
 release of the operating system
const std::string & os_version () const throw ()
 version of the operating system
const std::string & machine () const throw ()
 version of the operating system
const std::string & description () const throw ()
 machine type *‍/
Public Member Functions inherited from OksSystem::Host
 Host (const Host &other)
 copy constructor
 Host (const std::string &name)
 constructor from name
 Host (struct sockaddr_in ip_addr)
 constructor from ip address
virtual ~Host () throw ()
 destructor
 operator struct sockaddr_in () const throw ()
 cast to ip address
bool equals (const Host &other) const throw ()
 equality method
struct sockaddr_in ip () const throw ()
 get ip address
const std::string & name () const throw ()
 get name
const std::string & full_name () const throw ()
 get fully qualified name
std::string ip_string () const throw ()
 get ip in string mode

Static Public Member Functions

static const std::string & local_name () throw ()
 localhostname
static const std::string & full_local_name () throw ()
 fully qualified local host name
static const LocalHostinstance () throw ()
 pointer to the singleton local host
Static Public Member Functions inherited from OksSystem::Host
static struct sockaddr_in resolve (const std::string &name) throw ()
 name to ip conversion
static std::string resolve (struct sockaddr_in address) throw ()
 ip to name conversion
static std::string expand (const std::string &name) throw ()
 expands to full name
static std::string to_string (struct sockaddr_in ip_addr)
 ip to string conversion

Protected Attributes

std::string m_os_name
 name of the operating system
std::string m_release
 release of the operating system
std::string m_version
 version of the operating system
std::string m_machine
 machine type
std::string m_description
 machine description (cached)
Protected Attributes inherited from OksSystem::Host
std::string m_name
 name of the host
std::string m_full_name
 cached fully qualified host name

Static Protected Attributes

static LocalHosts_instance = 0
 singleton for local host

Additional Inherited Members

Protected Member Functions inherited from OksSystem::Host
 Host () throw ()
 constructor for current host

Detailed Description

Network host - localhost.

This class represents the local host It has some additional fields with additional information about the host

Version
1.1
Author
Matthias Wiesmann

Definition at line 67 of file Host.hpp.

Constructor & Destructor Documentation

◆ LocalHost()

OksSystem::LocalHost::LocalHost ( )
throw ( )

Constructor You should not construct new instances, use instance to get the singleton instance.

Definition at line 238 of file Host.cpp.

238 : Host() {
239 struct utsname u_name_data;
240 const int status = ::uname(&u_name_data);
241 if (status==0) {
242 m_name = u_name_data.nodename;
243 m_os_name = u_name_data.sysname;
244 m_release = u_name_data.release;
245 m_version = u_name_data.version;
246 m_machine = u_name_data.machine;
247 } else {
248 char buffer[NI_MAXHOST];
249 const int host_status = gethostname(buffer,sizeof(buffer));
250 if (host_status==0) {
251 m_name = buffer;
252 } else { // both uname and gethostname screwed
253 m_name.clear();
254 } // check for host_name
255 } // uname failed.
256} // LocalHost
std::string m_name
name of the host
Definition Host.hpp:35
Host()
constructor for current host
Definition Host.cpp:97
std::string m_os_name
name of the operating system
Definition Host.hpp:71
std::string m_version
version of the operating system
Definition Host.hpp:73
std::string m_machine
machine type
Definition Host.hpp:74
std::string m_release
release of the operating system
Definition Host.hpp:72

◆ ~LocalHost()

OksSystem::LocalHost::~LocalHost ( )
throw ( )

Definition at line 258 of file Host.cpp.

258 {
259 // delete s_instance;
260}

Member Function Documentation

◆ description()

const std::string & OksSystem::LocalHost::description ( ) const
throw ( )

machine type *‍/

This method builds a description of the localhost This contains all the of the information handled by this class.

Returns
description text

Definition at line 291 of file Host.cpp.

291 {
292 if (m_description.empty()) {
293 std::ostringstream stream;
294 stream << m_os_name << " " << m_release << "/" << m_machine;
295 m_description = stream.str();
296 }
297 return m_description;
298} // description
std::string m_description
machine description (cached)
Definition Host.hpp:75

◆ full_local_name()

const std::string & OksSystem::LocalHost::full_local_name ( )
throw ( )
static

fully qualified local host name

Short-cut method - gives the fully qualified local hostname

Returns
fully qualified hostname
See also
OksSystem::LocalHost::full_name()

Definition at line 216 of file Host.cpp.

216 {
217 return instance()->full_name();
218} // fulllocalhostname
const std::string & full_name() const
get fully qualified name
Definition Host.cpp:166
static const LocalHost * instance()
pointer to the singleton local host
Definition Host.cpp:226

◆ instance()

const OksSystem::LocalHost * OksSystem::LocalHost::instance ( )
throw ( )
static

pointer to the singleton local host

This method returns a pointer to the singleton instance. There is no need to ever create any instance of LocalHost

Returns
pointer to singleton instance
Note
utility methods like full_local_name use this instance class

Definition at line 226 of file Host.cpp.

226 {
227 if (0==s_instance) {
228 s_instance = new LocalHost();
229 } //
230 return s_instance;
231} // instance
static LocalHost * s_instance
singleton for local host
Definition Host.hpp:70

◆ local_name()

const std::string & OksSystem::LocalHost::local_name ( )
throw ( )
static

localhostname

Short-cut method - gives the local hostname This name is not guaranteed to be a fully qualified name.

Returns
hostname
See also
OksSystem::LocalHost::name()

Definition at line 207 of file Host.cpp.

207 {
208 return instance()->name();
209} // localhostname
const std::string & name() const
get name
Definition Host.cpp:154

◆ machine()

const std::string & OksSystem::LocalHost::machine ( ) const
throw ( )

version of the operating system

Returns
machine name

Definition at line 282 of file Host.cpp.

282 {
283 return m_machine;
284} // machine

◆ os_name()

const std::string & OksSystem::LocalHost::os_name ( ) const
throw ( )

name of the operating system

Returns
Operating OksSystem name

Definition at line 264 of file Host.cpp.

264 {
265 return m_os_name;
266} // os_name

◆ os_release()

const std::string & OksSystem::LocalHost::os_release ( ) const
throw ( )

release of the operating system

Returns
Operating OksSystem release

Definition at line 270 of file Host.cpp.

270 {
271 return m_release;
272} // os_release

◆ os_version()

const std::string & OksSystem::LocalHost::os_version ( ) const
throw ( )

version of the operating system

Returns
Operating OksSystem version

Definition at line 276 of file Host.cpp.

276 {
277 return m_version;
278} // os_version

Member Data Documentation

◆ m_description

std::string OksSystem::LocalHost::m_description
mutableprotected

machine description (cached)

Definition at line 75 of file Host.hpp.

◆ m_machine

std::string OksSystem::LocalHost::m_machine
protected

machine type

Definition at line 74 of file Host.hpp.

◆ m_os_name

std::string OksSystem::LocalHost::m_os_name
protected

name of the operating system

Definition at line 71 of file Host.hpp.

◆ m_release

std::string OksSystem::LocalHost::m_release
protected

release of the operating system

Definition at line 72 of file Host.hpp.

◆ m_version

std::string OksSystem::LocalHost::m_version
protected

version of the operating system

Definition at line 73 of file Host.hpp.

◆ s_instance

OksSystem::LocalHost * OksSystem::LocalHost::s_instance = 0
staticprotected

singleton for local host

LocalHost singleton.

Instance of local host

Definition at line 70 of file Host.hpp.


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