OpendTect  6.6
clientservicebase.h
Go to the documentation of this file.
1 #pragma once
2 /*+
3 * ________________________________________________________________________
4 *
5 * (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
6 * Author: A. Huck
7 * Date: Oct 2020
8 * RCS: $Id$
9 * ________________________________________________________________________
10 *
11 * -*/
12 
13 #include "servicemgrbase.h"
14 
15 class uiServiceClientMgr;
16 
17 
26 public:
27 
28  virtual ~ServiceClientMgr();
29 
30  bool isPresent(const Network::Service::ID) const;
31  bool isAlive(const Network::Service::ID) const;
35 
38 
39  /* Require an action or request to be done by an external application
40  started by od_main. The return value indicates if the action was
41  send, received and processed successfully by this application */
43  const char*) const;
45  const OD::JSON::Object& ) const;
46 
48  const char* desc=nullptr,
49  od_ostream* = nullptr) const;
50 
52 
53 protected:
54  ServiceClientMgr(const char* servicenm);
55  ServiceClientMgr(const char* servicenm,
56  bool assignport,
58 
60 
66  /* Implement an action/request send from an external application, that
67  must be handled by od_main. Can be used to transfer signals
68  emitted by the external application, to make od_main aware of it */
69 
70  bool canParseAction(const char*,uiRetVal&) override;
72  uiRetVal&) override;
73 
74  uiRetVal doHandleAction(const char* action) override;
76 
79 
80  void doAppClosing(CallBacker*) override;
81  void closeApp() override;
82 
83  virtual bool canClaimService(const Network::Service&) const = 0;
84  /*<! When a service is registered, you may want to claim
85  it for your own manager */
86 
87  uiRetVal sendAction(const Network::Service&,const char*) const;
89  const OD::JSON::Object& ) const;
90 
92 
93 private:
94 
95  void init(bool local);
96 
102  //<! Remove all unreachable services
103 };
104 
105 
116 public:
117 
118  virtual ~BatchServiceClientMgr();
119 
121  bool isOK() const;
122 
124  //<!You may store the ID
126  //<!Forget this ID
127 
133 
134  static const char* sKeyStoreInfo() { return "batch-info"; }
135  static const char* sKeyDoWork() { return "batch-dowork"; }
136  static const char* sKeyPaused() { return "batch-paused"; }
137  static const char* sKeyResumed() { return "batch-resumed"; }
138  static const char* sKeyKilled() { return "batch-killed"; }
139  static const char* sKeyFinished() { return "batch-finished"; }
140 
141  static const char* sKeyBatchRequest() { return "batch-request"; }
142 
143 private:
145  bool canParseAction(const char*,uiRetVal&) override;
147  uiRetVal&) override;
148 
149  uiRetVal doHandleAction(const char* action) override;
151 
152  bool canClaimService(const Network::Service&) const override;
153 
158 
159  friend class uiServiceClientMgr;
160 };
BatchServiceClientMgr::batchStarted
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchStarted
Definition: clientservicebase.h:123
BatchServiceClientMgr::BatchServiceClientMgr
BatchServiceClientMgr()
BatchServiceClientMgr::getMgr
static mODTextTranslationClass(BatchServiceClientMgr) public BatchServiceClientMgr & getMgr()
ServiceClientMgr::ServiceClientMgr
ServiceClientMgr(const char *servicenm, bool assignport, Network::SpecAddr=Network::Any)
ServiceClientMgr::removeService
bool removeService(const Network::Service::ID)
ServiceClientMgr::sendAction
uiRetVal sendAction(const Network::Service::ID, const char *) const
BatchServiceClientMgr::batchResumed
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchResumed
Definition: clientservicebase.h:130
Network::Service::ID
ProcID ID
Definition: netservice.h:49
ServiceClientMgr::stopService
bool stopService(const Network::Service::ID)
ServiceClientMgr::ServiceClientMgr
ServiceClientMgr(const char *servicenm)
BatchServiceClientMgr::doHandleRequest
uiRetVal doHandleRequest(const OD::JSON::Object &) override
ServiceClientMgr::canParseAction
bool canParseAction(const char *, uiRetVal &) override
BatchServiceClientMgr::sKeyResumed
static const char * sKeyResumed()
Definition: clientservicebase.h:137
BatchServiceClientMgr::canParseRequest
bool canParseRequest(const OD::JSON::Object &, uiRetVal &) override
ObjectSet< Network::Service >
ServiceClientMgr
Definition: clientservicebase.h:25
ServiceClientMgr::addApplicationAuthority
static bool addApplicationAuthority(OS::MachineCommand &)
ServiceClientMgr::init
void init(bool local)
ServiceClientMgr::~ServiceClientMgr
virtual ~ServiceClientMgr()
BatchServiceClientMgr::batchServiceAdded
void batchServiceAdded(CallBacker *)
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
ServiceClientMgr::doHandleRequest
uiRetVal doHandleRequest(const OD::JSON::Object &) override
ServiceClientMgr::serviceName
BufferString serviceName(const Network::Service::ID) const
BatchServiceClientMgr::batchHasStarted
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchHasStarted
Definition: clientservicebase.h:128
ServiceClientMgr::getService
const Network::Service * getService(const Network::Service::ID) const
Network::Service::SubID
Batch::ID SubID
Definition: netservice.h:50
BatchServiceClientMgr::batchFinished
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchFinished
Definition: clientservicebase.h:132
Network
Definition: jobcommunic.h:22
BatchServiceClientMgr::isOK
bool isOK() const
BatchServiceClientMgr::sKeyStoreInfo
static const char * sKeyStoreInfo()
Definition: clientservicebase.h:134
Network::Service
Definition: netservice.h:46
uiRetVal
Definition: uistringset.h:105
ServiceClientMgr::closeApp
void closeApp() override
ServiceClientMgr::mODTextTranslationClass
mODTextTranslationClass(ServiceClientMgr)
CallBacker
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
mODTextTranslationClass
#define mODTextTranslationClass(clss)
Definition: uistring.h:40
BatchServiceClientMgr::doAppClosing
void doAppClosing(CallBacker *)
BatchServiceClientMgr
Definition: clientservicebase.h:115
BatchServiceClientMgr::batchServiceRemoved
void batchServiceRemoved(CallBacker *)
BatchServiceClientMgr::batchKilled
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchKilled
Definition: clientservicebase.h:131
ServiceClientMgr::doAppClosing
void doAppClosing(CallBacker *) override
BatchServiceClientMgr::sKeyDoWork
static const char * sKeyDoWork()
Definition: clientservicebase.h:135
ServiceClientMgr::serviceRemoved
CNotifier< ServiceClientMgr, Network::Service::ID > serviceRemoved
Definition: clientservicebase.h:37
ServiceClientMgr::sendRequest
uiRetVal sendRequest(const Network::Service::ID, const char *, const OD::JSON::Object &) const
ServiceClientMgr::getService
Network::Service * getService(const Network::Service::ID)
Network::SpecAddr
SpecAddr
Definition: networkcommon.h:33
BatchServiceClientMgr::sKeyBatchRequest
static const char * sKeyBatchRequest()
Definition: clientservicebase.h:141
ServiceClientMgr::cleanupServices
void cleanupServices()
ServiceMgrBase
Base class for OpendTect Service Manager and external services/apps.
Definition: servicemgrbase.h:29
Network::Any
@ Any
Definition: networkcommon.h:33
ServiceClientMgr::doHandleAction
uiRetVal doHandleAction(const char *action) override
servicemgrbase.h
ServiceClientMgr::services_
ObjectSet< Network::Service > services_
Definition: clientservicebase.h:91
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
BatchServiceClientMgr::sKeyFinished
static const char * sKeyFinished()
Definition: clientservicebase.h:139
BatchServiceClientMgr::batchEnded
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchEnded
Definition: clientservicebase.h:125
ServiceClientMgr::sendRequest
uiRetVal sendRequest(const Network::Service &, const char *, const OD::JSON::Object &) const
BatchServiceClientMgr::canParseAction
bool canParseAction(const char *, uiRetVal &) override
ServiceClientMgr::isAlive
bool isAlive(const Network::Service::ID) const
ServiceClientMgr::serviceToBeRemoved
CNotifier< ServiceClientMgr, Network::Service * > serviceToBeRemoved
Definition: clientservicebase.h:62
BatchServiceClientMgr::canClaimService
bool canClaimService(const Network::Service &) const override
OS::MachineCommand
Encapsulates an actual command to execute + the machine to run it on.
Definition: oscommand.h:94
ServiceClientMgr::printInfo
void printInfo(const Network::Service::ID, const char *desc=nullptr, od_ostream *=nullptr) const
ServiceClientMgr::addService
uiRetVal addService(const OD::JSON::Object &)
uiServiceClientMgr
Definition: uiserviceclientmgr.h:50
ServiceClientMgr::removeService
uiRetVal removeService(const OD::JSON::Object &)
ServiceClientMgr::isPresent
bool isPresent(const Network::Service::ID) const
ServiceClientMgr::serviceAdded
CNotifier< ServiceClientMgr, Network::Service::ID > serviceAdded
Definition: clientservicebase.h:36
ServiceClientMgr::checkService
bool checkService(const Network::Service::ID) const
ServiceClientMgr::serviceSubID
Network::Service::SubID serviceSubID(const Network::Service::ID) const
ServiceClientMgr::canClaimService
virtual bool canClaimService(const Network::Service &) const =0
ServiceClientMgr::canParseRequest
bool canParseRequest(const OD::JSON::Object &, uiRetVal &) override
ServiceClientMgr::sendAction
uiRetVal sendAction(const Network::Service &, const char *) const
ServiceClientMgr::addService
void addService(Network::Service &)
ServiceClientMgr::serviceToBeAdded
CNotifier< ServiceClientMgr, Network::Service * > serviceToBeAdded
Definition: clientservicebase.h:61
BatchServiceClientMgr::sKeyKilled
static const char * sKeyKilled()
Definition: clientservicebase.h:138
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
BatchServiceClientMgr::sKeyPaused
static const char * sKeyPaused()
Definition: clientservicebase.h:136
CNotifier< ServiceClientMgr, Network::Service::ID >
BatchServiceClientMgr::doHandleAction
uiRetVal doHandleAction(const char *action) override
BatchServiceClientMgr::batchPaused
CNotifier< BatchServiceClientMgr, Network::Service::ID > batchPaused
Definition: clientservicebase.h:129
OD::JSON::Object
ValueSet where the values and subsets have a key.
Definition: odjson.h:283
BatchServiceClientMgr::batchServiceToBeAdded
void batchServiceToBeAdded(CallBacker *)

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