3
Server-side remote object factory definitions
5
Server code: factory.cpp
7
This header file contains all the class declarations of the remote
8
objects to support serialization of these objects for server-side
9
state management (simple save/load operations are implemented).
11
The remote object factory uses a lease-based system. Remote objects
12
are purged from the pool when the lease expires (see LEASETERM in
13
factory.cpp). Supports inheritance.
17
c++ -o factory factory.cpp stdsoap2.cpp soapC.cpp soapServer.cpp
19
Run (e.g. in the background)
21
where <port> is a available port number, e.g. 18085
23
Copyright (C) 2000-2002 Robert A. van Engelen. All Rights Reserved.
26
//gsoap ns service name: factory
27
//gsoap ns service style: rpc
28
//gsoap ns service encoding: encoded
29
//gsoap ns service namespace: http://websrv.cs.fsu.edu/~engelen/factory.wsdl
30
//gsoap ns service location: http://localhost:18085
32
//gsoap ns schema namespace: urn:factoryService
33
//gsoap t schema namespace: urn:factoryTypes
34
//gsoap h schema namespace: urn:factoryHandles
36
////////////////////////////////////////////////////////////////////////////////
38
// SOAP Header: used to exchange stateful object handles
40
////////////////////////////////////////////////////////////////////////////////
42
struct SOAP_ENV__Header
43
{ mustUnderstand unsigned int h__handle;
46
////////////////////////////////////////////////////////////////////////////////
48
// Server-side root class
50
////////////////////////////////////////////////////////////////////////////////
52
enum t__object // object types:
53
{ ROOT, // t__root object
54
ADDER, // t__adder object
55
COUNTER // t__counter object
58
enum t__status // remote object status:
60
FACTORY_INVALID, // invalid handle (wrong type of object or lease expired)
61
FACTORY_NOTFOUND, // lookup operation not successful
62
FACTORY_RETRY // cannot create new object: try later
67
enum t__object object; // object type
68
char *name; // object name for lookup operation (optional)
69
unsigned int handle; // internal handle
70
time_t lease; // lease expiration time
73
virtual void renew(); // to renew lease
76
////////////////////////////////////////////////////////////////////////////////
78
// Server-side adder class derived from root
80
////////////////////////////////////////////////////////////////////////////////
82
class t__adder: public t__root
84
double val; // current value of the adder
85
void set(double val); // to set the adder
86
double get(); // to get value of the adder
87
void add(double val); // to add a value to the adder
90
////////////////////////////////////////////////////////////////////////////////
92
// Server-side counter class derived from adder
94
////////////////////////////////////////////////////////////////////////////////
96
class t__counter: public t__adder
98
void inc(); // to increment the counter
101
////////////////////////////////////////////////////////////////////////////////
103
// Remote factory method interfaces
105
////////////////////////////////////////////////////////////////////////////////
107
//gsoap ns service method-header-part: create h__handle
108
int ns__create(enum t__object object, char *name, enum t__status &status);
110
//gsoap ns service method-header-part: lookup h__handle
111
int ns__lookup(enum t__object object, char *name, enum t__status &status);
113
//gsoap ns service method-header-part: rename h__handle
114
int ns__rename(char *name, enum t__status &status);
116
//gsoap ns service method-header-part: release h__handle
117
int ns__release(enum t__status &status);
119
////////////////////////////////////////////////////////////////////////////////
121
// Rewote adder method interfaces
123
////////////////////////////////////////////////////////////////////////////////
125
//gsoap ns service method-header-part: set h__handle
126
int ns__set(double val, enum t__status &status);
128
//gsoap ns service method-header-part: get h__handle
129
int ns__get(double &val);
131
//gsoap ns service method-header-part: add h__handle
132
int ns__add(double val, enum t__status &status);
134
////////////////////////////////////////////////////////////////////////////////
136
// Remote counter method interfaces
138
////////////////////////////////////////////////////////////////////////////////
140
//gsoap ns service method-header-part: inc h__handle
141
int ns__inc(enum t__status &status);