OpendTect  6.6
serverservicebase.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 Timer;
16 
24 public:
25 
26  enum RegState { Unregistered, Requested, Confirmed, Unrequested };
27 
28  virtual ~ServiceServerMgr();
29 
30  bool isStandAloneApp() const;
31  bool canReceiveRequests() const;
32  /* Only a registered server can expect to receive
33  incoming requests */
34 
35  /* Use sendAction/sendRequest to ask another listening application
36  to do something on your behalf. By default action/requests are
37  send to the reporting application with the current service name.
38  You should always get a reponse to see if the message reached
39  its target application, and has been processed successfully.
40  */
41 
42  virtual uiRetVal sendAction(const char* act,
43  const Network::Authority* =nullptr,
44  const char* servicenm=nullptr) const;
45  /*<! This action will have no information on from
46  the sender. Ensure it can be applied without. */
47  virtual uiRetVal sendActionRequest(const char* reqkey,const char* act,
48  const OD::JSON::Object* morereq=nullptr,
49  const Network::Authority* =nullptr,
50  const char* servicenm=nullptr) const;
51  /*<! This will send an action-based request, as
52  the sender's service ID will be added. */
53  virtual uiRetVal sendRequest(const char* reqkey,const OD::JSON::Object&,
54  const Network::Authority* =nullptr,
55  const char* servicenm=nullptr) const;
56 
57 protected:
59  const char* servicenm);
60  /*<! Instantiates an application that will
61  have a local listening service as primary
62  server */
64  const char* servicenm,
65  bool assignport,
67  /*<! Instantiate an application that will
68  have a TCP/IP listening service as primary
69  server */
70 
71  bool isRegistered() const;
72 
73  bool isDependentApp() const;
74  /*<! returns false when the app is launched as
75  a stand-alone application.
76  Then it never communicates back. */
77 
78  virtual bool reportingAppIsAlive() const;
79  /*<! If the app was launched from another app,
80  check if this later is still alive */
81 
82  virtual void checkOnReportToApplication(bool startyn,
83  int eachms=5000);
84 
85  void doAppClosing(CallBacker*) override;
86 
87  const Network::Service* thisService() const { return thisservice_; }
88 
89  void setUnregistered() { registerstatus_ = Unregistered; }
90 
91 private:
92 
93  void init(Network::Service::ServType,bool local);
94 
96  //<! On startup, report to the main App (if any)
98  //<! On application closing, inform the main App
99  uiRetVal doRegister_(const char*,bool doreg);
100 
101  void doPyEnvChange(CallBacker*) override;
102  virtual void reportToCheckCB(CallBacker*);
103 
104  Network::Service* thisservice_ = nullptr;
105  Network::Authority* reportto_ = nullptr;
106  RegState registerstatus_ = Unregistered;
107 
108  Timer* reporttocheck_ = nullptr;
109 
110 };
ServiceServerMgr::checkOnReportToApplication
virtual void checkOnReportToApplication(bool startyn, int eachms=5000)
ServiceServerMgr
Definition: serverservicebase.h:23
ServiceServerMgr::ServiceServerMgr
ServiceServerMgr(Network::Service::ServType, const char *servicenm, bool assignport, Network::SpecAddr=Network::Any)
ServiceServerMgr::isRegistered
bool isRegistered() const
ServiceServerMgr::doAppClosing
void doAppClosing(CallBacker *) override
ServiceServerMgr::isStandAloneApp
bool isStandAloneApp() const
ServiceServerMgr::thisService
const Network::Service * thisService() const
Definition: serverservicebase.h:87
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
ServiceServerMgr::~ServiceServerMgr
virtual mODTextTranslationClass(ServiceServerMgr) public ~ServiceServerMgr()
Network
Definition: jobcommunic.h:22
Network::Authority
Definition: networkcommon.h:56
Network::Service
Definition: netservice.h:46
uiRetVal
Definition: uistringset.h:105
CallBacker
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
ServiceServerMgr::sendAction
virtual uiRetVal sendAction(const char *act, const Network::Authority *=nullptr, const char *servicenm=nullptr) const
ServiceServerMgr::doRegister_
uiRetVal doRegister_(const char *, bool doreg)
mODTextTranslationClass
#define mODTextTranslationClass(clss)
Definition: uistring.h:40
Timer
Timer class.
Definition: timer.h:25
ServiceServerMgr::isDependentApp
bool isDependentApp() const
ServiceServerMgr::canReceiveRequests
bool canReceiveRequests() const
ServiceServerMgr::sendRequest
virtual uiRetVal sendRequest(const char *reqkey, const OD::JSON::Object &, const Network::Authority *=nullptr, const char *servicenm=nullptr) const
ServiceServerMgr::ServiceServerMgr
ServiceServerMgr(Network::Service::ServType, const char *servicenm)
ServiceServerMgr::reportToCheckCB
virtual void reportToCheckCB(CallBacker *)
ServiceServerMgr::init
void init(Network::Service::ServType, bool local)
Network::SpecAddr
SpecAddr
Definition: networkcommon.h:33
ServiceMgrBase
Base class for OpendTect Service Manager and external services/apps.
Definition: servicemgrbase.h:29
Network::Any
@ Any
Definition: networkcommon.h:33
servicemgrbase.h
ServiceServerMgr::doRegister
uiRetVal doRegister()
ServiceServerMgr::sendActionRequest
virtual uiRetVal sendActionRequest(const char *reqkey, const char *act, const OD::JSON::Object *morereq=nullptr, const Network::Authority *=nullptr, const char *servicenm=nullptr) const
ServiceServerMgr::setUnregistered
void setUnregistered()
Definition: serverservicebase.h:89
ServiceServerMgr::reportingAppIsAlive
virtual bool reportingAppIsAlive() const
ServiceServerMgr::doDeRegister
uiRetVal doDeRegister()
ServiceServerMgr::doPyEnvChange
void doPyEnvChange(CallBacker *) override
OD::JSON::Object
ValueSet where the values and subsets have a key.
Definition: odjson.h:283
Network::Service::ServType
ServType
Definition: netservice.h:52

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