OpendTect  6.6
netservice.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4  _________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Wayne Mogg
8  Date: November 2019
9  RCS: $Id$
10  ________________________________________________________________________
11 
12  -*/
13 
14 #include "networkmod.h"
15 
16 #include "batchjobdispatch.h"
17 #include "enums.h"
18 #include "namedobj.h"
19 #include "networkcommon.h"
20 
21 class od_ostream;
22 class FilePath;
23 
24 namespace OD {
25  namespace JSON {
26  class Object;
27  };
28 };
29 
30 namespace OS {
31  class CommandLauncher;
32 };
33 
34 
35 /*\brief
36  Encapsulates information of an external application/service
37 
38 
39 */
40 namespace Network
41 {
42 
43 typedef int ProcID;
44 
47 public:
48 
49  typedef ProcID ID;
50  typedef Batch::ID SubID;
51 
52  enum ServType { ODGui, ODBatchGui, ODBatch, ODTest, Python, Other };
54 
55  Service(PortNr_Type,const char* hostnm=nullptr);
56  Service(const Authority&);
58  Service(const Service&) = delete;
60 
61  Service& operator =(const Service&) = delete;
62  bool operator ==(const Service&) const;
63  bool operator !=(const Service&) const;
64 
65  bool isOK() const;
66  bool isEmpty() const;
67  bool isPortValid() const;
68  bool isAlive() const;
69  bool isBatch() const;
70 
71  ID getID() const;
72  SubID getSubID() const { return subid_; }
73  ProcID PID() const { return pid_; }
74  BufferString url() const;
75  Authority getAuthority() const { return auth_; }
77  PortNr_Type port() const;
78  ServType type() const { return type_; }
80  uiRetVal message() const { return msg_; }
81  void fillJSON(OD::JSON::Object&) const;
82 
84  void setHostName(const char*);
85  void setLogFile(const char*);
87  void setPID(ProcID);
88  void setType( ServType typ ) { type_ = typ; }
90  void stop(bool removelog=true);
91  void setEmpty();
92  void setViewOnly( bool yn=true ) { viewonly_ = yn; }
93 
95  static ID getID(const OD::JSON::Object&);
96 
97  static const char* sKeyServiceName() { return "servicename"; }
98  static const char* sKeyServiceType() { return "servicetype"; }
99  static const char* sKeyPID() { return "pid"; }
100  static const char* sKeySubID();
101  static const char* sKeyLogFile() { return "logfile"; }
102 
103  void printInfo(const char* ky=nullptr,
104  od_ostream* =nullptr) const;
105 
106 private:
107 
108  void init();
109 
111  ProcID pid_ = 0;
113  FilePath* logfp_ = nullptr;
114  bool viewonly_ = false;
116 
117  mutable uiRetVal msg_;
118 
119 };
120 
121 };
Batch::JobDispatcher::getInvalid
static ID getInvalid()
Definition: batchjobdispatch.h:80
NamedObject
object with a name.
Definition: namedobj.h:42
Network::Service::Service
Service(const Service &)=delete
Network::Service::Service
Service(PortNr_Type, const char *hostnm=nullptr)
Network::Service::ID
ProcID ID
Definition: netservice.h:49
Network::Service::getSubID
SubID getSubID() const
Definition: netservice.h:72
Network::Service::msg_
uiRetVal msg_
Definition: netservice.h:117
Network::Service::Service
Service(const OD::JSON::Object &)
Network::Service::setPID
void setPID(ProcID)
Network::Service::setEmpty
void setEmpty()
OD
OpendTect.
Definition: commontypes.h:28
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
FilePath
File pathname tools.
Definition: filepath.h:34
namedobj.h
Network::Service::SubID
Batch::ID SubID
Definition: netservice.h:50
ODInst::Other
@ Other
Definition: odinst.h:44
Network
Definition: jobcommunic.h:22
Network::Authority
Definition: networkcommon.h:56
Network::Service
Definition: netservice.h:46
Network::Service::sKeySubID
static const char * sKeySubID()
uiRetVal
Definition: uistringset.h:105
operator==
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:81
Network::Service::isBatch
bool isBatch() const
Network::Service::setLogFile
void setLogFile(const char *)
Network::Service::isPortValid
bool isPortValid() const
Network::Service::mDeclareEnumUtils
mDeclareEnumUtils(ServType)
Network::Service::setViewOnly
void setViewOnly(bool yn=true)
Definition: netservice.h:92
Network::Service::getAuthority
Authority getAuthority() const
Definition: netservice.h:75
Network::Service::url
BufferString url() const
Network::Service::getServiceName
static BufferString getServiceName(const OD::JSON::Object &)
sKey::Object
FixedString Object()
Definition: keystrs.h:112
Network::Service::getID
ID getID() const
Network::Service::useJSON
uiRetVal useJSON(const OD::JSON::Object &)
operator!=
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:90
Network::Service::sKeyPID
static const char * sKeyPID()
Definition: netservice.h:99
Network::Service::auth_
Authority auth_
Definition: netservice.h:110
Network::Service::init
void init()
Network::Service::mODTextTranslationClass
mODTextTranslationClass(Service)
Network::Service::setPID
void setPID(const OS::CommandLauncher &)
batchjobdispatch.h
OS
Definition: od_stream.h:23
Network::Service::logFnm
BufferString logFnm() const
Network::Service::type
ServType type() const
Definition: netservice.h:78
Network::Service::getID
static ID getID(const OD::JSON::Object &)
Network::Service::setPort
void setPort(PortNr_Type)
Network::Service::setType
void setType(ServType typ)
Definition: netservice.h:88
Network::Service::PID
ProcID PID() const
Definition: netservice.h:73
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
networkcommon.h
Network::ProcID
int ProcID
Definition: netservice.h:43
Network::Service::setHostName
void setHostName(const char *)
Network::Service::Service
Service(const Authority &)
Network::Service::address
BufferString address() const
Network::Service::sKeyServiceType
static const char * sKeyServiceType()
Definition: netservice.h:98
enums.h
Network::Service::printInfo
void printInfo(const char *ky=nullptr, od_ostream *=nullptr) const
Network::Service::sKeyLogFile
static const char * sKeyLogFile()
Definition: netservice.h:101
Network::Service::port
PortNr_Type port() const
Network::Service::type_
ServType type_
Definition: netservice.h:115
Batch::ID
int ID
Definition: batchjobdispatch.h:24
Network::Service::fillJSON
void fillJSON(OD::JSON::Object &) const
Network::Service::sKeyServiceName
static const char * sKeyServiceName()
Definition: netservice.h:97
Network::Service::isAlive
bool isAlive() const
Network::Service::message
uiRetVal message() const
Definition: netservice.h:80
Network::Service::stop
void stop(bool removelog=true)
od_ostream
OD class for stream write common access to the user log file, or std::cout in other than od_main.
Definition: od_ostream.h:26
Network::Service::isEmpty
bool isEmpty() const
Network::Service::~Service
~Service()
PortNr_Type
unsigned short PortNr_Type
Definition: commontypes.h:37
sKey::Python
FixedString Python()
Definition: keystrs.h:124
Network::Service::isOK
bool isOK() const
OD::JSON::Object
ValueSet where the values and subsets have a key.
Definition: odjson.h:283
OS::CommandLauncher
Launches machine commands.
Definition: oscommand.h:216
Network::Service::ServType
ServType
Definition: netservice.h:52

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