OpendTect-6_4  6.4
hostdata.h
Go to the documentation of this file.
1 #ifndef hostdata_h
2 #define hostdata_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert Bril
9  Date: Apr 2002
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "networkmod.h"
16 
17 #include "bufstringset.h"
18 #include "filepath.h"
19 #include "manobjectset.h"
20 #include "od_iosfwd.h"
21 #include "odplatform.h"
22 #include "uistring.h"
23 
24 class HostDataList;
25 class IOPar;
26 class ShareData;
27 
28 #define mRetNoneIfEmpty( bs ) \
29  if ( bs.isEmpty() ) return "_none_"; \
30  return bs;
31 
37 {
38 public:
39  HostData(const char* nm);
40  HostData(const char* nm,const HostData& localhost,
41  const OD::Platform&);
42  HostData(const HostData&);
43  virtual ~HostData();
44 
45  enum PathType { Appl, Data };
46 
47  void setHostName(const char*);
48  const char* getHostName() const;
49  void setIPAddress(const char*);
50  const char* getIPAddress() const;
51 
52  int nrAliases() const
53  { return aliases_.size(); }
54  void setAlias(const char*);
55  const char* alias( int idx ) const
56  { return aliases_.get(idx); }
57  bool isKnownAs(const char*) const;
59  void addAlias(const char*);
61  BufferString getFullDispString() const;
62 
63  void setPlatform(const OD::Platform&);
64  const OD::Platform& getPlatform() const;
65  bool isWindows() const;
66  FilePath::Style pathStyle() const;
68  const FilePath& prefixFilePath(PathType) const;
69 
70  const FilePath& getDataRoot() const;
71  void setDataRoot(const FilePath&);
72 
73  FilePath convPath( PathType pt, const FilePath&,
74  const HostData* from = 0 ) const;
75  FilePath convPath( PathType pt, const char* fn,
76  const HostData* from = 0 ) const
77  { return convPath(pt, FilePath(fn), from ); }
78 
79  static const char* localHostName();
81 
82  void setLocalHost( const HostData& hd )
83  { localhd_ = &hd; }
84  const HostData& localHost() const
85  { return localhd_ ? *localhd_ : *this; }
86 
87  bool isOK(uiString& errmsg) const;
88 
89  void fillPar(IOPar&) const;
90  void usePar(const IOPar&);
91 
92 protected:
93  HostData(const char* nm,const OD::Platform&);
94 
101  const HostData* localhd_;
102 
103  friend class HostDataList;
104 
105  void init( const char* nm );
106 };
107 
108 
109 
117 public:
118  HostDataList(bool foredit);
119 
120  void setNiceLevel(int);
121  int niceLevel() const;
122  void setFirstPort(int);
123  int firstPort() const;
124  void setLoginCmd(const char*);
125  const char* loginCmd() const;
126  void setUnixDataRoot(const char*);
127  const char* unixDataRoot() const;
128  void setWinDataRoot(const char*);
129  const char* winDataRoot() const;
130 
131  bool refresh(bool foredit=false);
132 
133  HostData* find( const char* nm ) { return findHost(nm); }
134  const HostData* find( const char* nm ) const { return findHost(nm); }
135 
136  void fill(BufferStringSet&,bool inclocalhost=true) const;
137  void dump(od_ostream&) const;
138 
139  const char* getBatchHostsFilename() const;
140  bool writeHostFile(const char* fnm);
141  void fillFromNetwork(); // Unix only
142  bool isOK(uiStringSet&) const;
143 
144 protected:
145 
147  int nicelvl_;
153 
154  void handleLocal();
155  void initDataRoot();
156  bool readHostFile(const char*);
157  bool readOldHostFile(const char*);
158  HostData* findHost(const char*) const;
160 };
161 
162 #undef mRetNoneIfEmpty
163 
164 #endif
#define mExpClass(module)
Definition: commondefs.h:160
BufferString unx_data_pr_
Definition: hostdata.h:152
void fill(BufferStringSet &, bool inclocalhost=true) const
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
const HostData * find(const char *nm) const
Definition: hostdata.h:134
int nicelvl_
Definition: hostdata.h:147
int firstport_
Definition: hostdata.h:148
Definition: jobcommunic.h:24
const char * getBatchHostsFilename() const
const HostData & localHost() const
Definition: hostdata.h:84
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
Style
Definition: filepath.h:37
void initDataRoot()
const char * localHostName()
shortcut to GetLocalHostName()
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
bool init()
void setLocalHost(const HostData &hd)
Definition: hostdata.h:82
const char * winDataRoot() const
bool readOldHostFile(const char *)
void setFirstPort(int)
BufferString win_appl_pr_
Definition: hostdata.h:149
Definition: uistring.h:89
Set of BufferString objects.
Definition: bufstringset.h:28
void fillFromNetwork()
const char * loginCmd() const
List of host names in the system. The first entry will be the local host.
Definition: hostdata.h:115
FilePath data_pr_
Definition: hostdata.h:100
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
void setWinDataRoot(const char *)
BufferString logincmd_
Definition: hostdata.h:146
PathType
Definition: hostdata.h:45
const char * unixDataRoot() const
int firstPort() const
const HostData * localhd_
Definition: hostdata.h:101
HostData * findHost(const char *) const
bool writeHostFile(const char *fnm)
const char * alias(int idx) const
Definition: hostdata.h:55
BufferString batchhostsfnm_
Definition: hostdata.h:159
FilePath appl_pr_
Definition: hostdata.h:99
FilePath convPath(PathType pt, const char *fn, const HostData *from=0) const
Definition: hostdata.h:75
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
Definition: repos.h:25
File pathname tools.
Definition: filepath.h:34
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
mODTextTranslationClass(HostDataList) public void setNiceLevel(int)
Platform or Operating System.
Definition: odplatform.h:25
int nrAliases() const
Definition: hostdata.h:52
void handleLocal()
bool refresh(bool foredit=false)
void setUnixDataRoot(const char *)
bool isOK(uiStringSet &) const
int niceLevel() const
Definition: uistring.h:218
void dump(od_ostream &) const
BufferStringSet aliases_
Definition: hostdata.h:97
HostData * find(const char *nm)
Definition: hostdata.h:133
Host name and aliases.
Definition: hostdata.h:36
BufferString unx_appl_pr_
Definition: hostdata.h:150
BufferString win_data_pr_
Definition: hostdata.h:151
ObjectSet where the objects contained are owned by this set.
Definition: manobjectset.h:23
OD::Platform platform_
Definition: hostdata.h:98
void setLoginCmd(const char *)
BufferString hostname_
Definition: hostdata.h:95
bool readHostFile(const char *)
BufferString ipaddress_
Definition: hostdata.h:96

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019