VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
glocal.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file glocal.h
19 ///
20 
21 #ifndef G_GNET_LOCAL_H
22 #define G_GNET_LOCAL_H
23 
24 #include "gdef.h"
25 #include "gnet.h"
26 #include "gaddress.h"
27 #include "glocation.h"
28 #include "gexception.h"
29 
30 namespace GNet
31 {
32  class Local ;
33 }
34 
35 /// \class GNet::Local
36 /// A static class for getting information about the local machine's network
37 /// name and address.
38 ///
40 {
41 public:
42  static std::string hostname() ;
43  ///< Returns the local hostname.
44 
45  static std::string canonicalName() ;
46  ///< Returns the canonical network name assiciated with hostname().
47 
48  static void canonicalName( const std::string & override ) ;
49  ///< Sets the canonicalName() override.
50 
51  static std::string name() ;
52  ///< Returns canonicalName(), or hostname() if canonicalName()
53  ///< is the empty string.
54 
55  static bool isLocal( const Address & , std::string & reason ) ;
56  ///< Returns true if the given address appears to be associated
57  ///< with the local host, or a helpful error message if not.
58 
59 private:
60  Local() ;
61  static std::string resolvedHostname() ;
62 
63 private:
64  static std::string m_name_override ;
65  static bool m_name_override_set ;
66 } ;
67 
68 #endif
static std::string canonicalName()
Returns the canonical network name assiciated with hostname().
Definition: glocal.cpp:52
static std::string hostname()
Returns the local hostname.
Definition: glocal.cpp:32
The GNet::Address class encapsulates a TCP/UDP transport address.
Definition: gaddress.h:55
static std::string name()
Returns canonicalName(), or hostname() if canonicalName() is the empty string.
Definition: glocal.cpp:63
A static class for getting information about the local machine's network name and address...
Definition: glocal.h:39
static bool isLocal(const Address &, std::string &reason)
Returns true if the given address appears to be associated with the local host, or a helpful error me...
Definition: glocal.cpp:68