ServiceProcedure.h
1 /*
2  Copyright (C) 2009-2026 by Marc Duerner
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  As a special exception, you may use this file as part of a free
10  software library without restriction. Specifically, if other files
11  instantiate templates or use macros or inline functions from this
12  file, or you compile this file and link it with other files to
13  produce an executable, this file does not by itself cause the
14  resulting executable to be covered by the GNU General Public
15  License. This exception does not however invalidate any other
16  reasons why the executable file might be covered by the GNU Library
17  General Public License.
18 
19  This library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public
25  License along with this library; if not, write to the:
26  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27  Boston, MA 02110-1301 USA
28 */
29 
30 #ifndef PT_REMOTING_SERVICEPROCEDURE_H
31 #define PT_REMOTING_SERVICEPROCEDURE_H
32 
33 #include <Pt/Remoting/Api.h>
34 #include <Pt/Remoting/Responder.h>
35 #include <Pt/System/EventLoop.h>
36 #include <Pt/Decomposer.h>
37 #include <Pt/Composer.h>
38 
39 namespace Pt {
40 
41 namespace Remoting {
42 
46 {
47  public:
51  {}
52 
55  void setReady()
56  { _responder->setReady(); }
57 
59  Composer** beginArgs()
60  { return onBeginArgs(); }
61 
63  void beginCall(System::EventLoop& loop)
64  { onBeginCall(loop); }
65 
67  Decomposer* endCall()
68  { return onEndCall(); }
69 
71  Decomposer* call()
72  { return onEndCall(); }
73 
74  protected:
78  : _responder( &r )
79  {}
80 
82  virtual Composer** onBeginArgs() = 0;
83 
85  virtual void onBeginCall(System::EventLoop& loop) = 0;
86 
88  virtual Decomposer* onEndCall() = 0;
89 
90  private:
91  Responder* _responder;
92 };
93 
94 
95 class ServiceProcedureDef
96 {
97  public:
98  virtual ~ServiceProcedureDef()
99  {}
100 
101  ServiceProcedure* createProcedure(Responder& r) const
102  { return this->onCreateProcedure(r); }
103 
104  protected:
105  ServiceProcedureDef()
106  {}
107 
108  virtual ServiceProcedure* onCreateProcedure(Responder& r) const = 0;
109 };
110 
111 } // namespace Remoting
112 
113 } // namespace Pt
114 
115 #include <Pt/Remoting/BasicProcedure.h>
116 #include <Pt/Remoting/ActiveProcedure.h>
117 
118 #endif // PT_REMOTING_SERVICEPROCEDURE_H
Core module.
Definition: Allocator.h:33
Manages the decomposition of types during serialization.
Definition: Decomposer.h:44
virtual ~ServiceProcedure()
Destructor.
Definition: ServiceProcedure.h:50
ServiceProcedure(Responder &r)
Constructor.
Definition: ServiceProcedure.h:77
Dispatches requests to a service procedure.
Definition: Responder.h:50
Service procedure.
Definition: ServiceProcedure.h:46
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:83
Composes types during serialization.
Definition: Composer.h:43
void setReady()
Indicates that the procedure has finished.
Definition: ServiceProcedure.h:55