DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Host.hpp
Go to the documentation of this file.
1/*
2 * Host.h
3 * OksSystem
4 *
5 * Created by Matthias Wiesmann on 03.02.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
10#ifndef OKSSYSTEM_HOST
11#define OKSSYSTEM_HOST
12
13#include <netinet/in.h>
14#include <arpa/inet.h>
15
16#include <string>
17#include <vector>
18
19namespace OksSystem {
20
28 class Host {
29protected:
30 std::string m_name ;
31 mutable std::string m_full_name ;
32 Host() throw() ;
33public:
34 static struct sockaddr_in resolve(const std::string &name) throw() ;
35 static std::string resolve(struct sockaddr_in address) throw() ;
36 static std::string expand(const std::string &name) throw() ;
37 static std::string to_string(struct sockaddr_in ip_addr) ;
38 Host(const Host &other) ;
39 Host(const std::string &name);
40 Host(struct sockaddr_in ip_addr);
41 virtual ~Host() throw();
42 operator struct sockaddr_in() const throw();
43 bool equals(const Host &other) const throw() ;
44 struct sockaddr_in ip() const throw() ;
45 const std::string & name() const throw() ;
46 const std::string & full_name() const throw() ;
47 std::string ip_string() const throw() ;
48 } ; // Host
49
50
51 bool operator ==(const Host &a, const Host &b) throw();
52 bool operator !=(const Host &a, const Host &b) throw();
53
54
62 class LocalHost : public Host {
63
64protected:
66 std::string m_os_name ;
67 std::string m_release ;
68 std::string m_version ;
69 std::string m_machine ;
70 mutable std::string m_description ;
71public:
72 static const std::string & local_name() throw() ;
73 static const std::string & full_local_name() throw() ;
74 static const LocalHost* instance() throw() ;
75 LocalHost() throw() ;
76 ~LocalHost() throw();
77 const std::string & os_name() const throw() ;
78 const std::string & os_release() const throw() ;
79 const std::string & os_version() const throw() ;
80 const std::string & machine() const throw() ;
81 const std::string & description() const throw() ;
82
83 } ; // LocalHost
84
85 const char* getfullhost() throw() ;
86
87 bool operator ==(const LocalHost &a, const LocalHost &b) throw();
88 bool operator !=(const LocalHost &a, const LocalHost &b) throw();
89
90
91} // OksSystem
92
93
94std::ostream& operator<<(std::ostream& stream, const OksSystem::Host& host) ;
95
96#endif
Network host.
Definition Host.hpp:28
std::string ip_string() const
get ip in string mode
Definition Host.cpp:172
static struct sockaddr_in resolve(const std::string &name)
name to ip conversion
Definition Host.cpp:32
const std::string & name() const
get name
Definition Host.cpp:149
static std::string expand(const std::string &name)
expands to full name
Definition Host.cpp:69
struct sockaddr_in ip() const
get ip address
Definition Host.cpp:155
static std::string to_string(struct sockaddr_in ip_addr)
ip to string conversion
Definition Host.cpp:81
bool equals(const Host &other) const
equality method
Definition Host.cpp:137
const std::string & full_name() const
get fully qualified name
Definition Host.cpp:161
std::string m_name
name of the host
Definition Host.hpp:30
Host()
constructor for current host
Definition Host.cpp:92
std::string m_full_name
cached fully qualified host name
Definition Host.hpp:31
Network host - localhost.
Definition Host.hpp:62
std::string m_os_name
name of the operating system
Definition Host.hpp:66
std::string m_version
version of the operating system
Definition Host.hpp:68
static LocalHost * s_instance
singleton for local host
Definition Host.hpp:65
std::string m_machine
machine type
Definition Host.hpp:69
std::string m_release
release of the operating system
Definition Host.hpp:67
std::string m_description
machine description (cached)
Definition Host.hpp:70
const char * getfullhost()
get fully qualified host name
Definition Host.cpp:302