~vcs-imports/simias/trunk

« back to all changes in this revision

Viewing changes to simias/tools/gsoap/gsoap-linux-2.7/samples/factory/factory.h

  • Committer: kalidasbala
  • Date: 2007-08-25 12:48:51 UTC
  • Revision ID: vcs-imports@canonical.com-20070825124851-vlfvzun3732ld196
Latest gsoap code update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*      factory.h
 
2
 
 
3
        Server-side remote object factory definitions
 
4
 
 
5
        Server code: factory.cpp
 
6
 
 
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).
 
10
 
 
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.
 
14
 
 
15
        Compile:
 
16
        soapcpp2 factory.h
 
17
        c++ -o factory factory.cpp stdsoap2.cpp soapC.cpp soapServer.cpp
 
18
 
 
19
        Run (e.g. in the background)
 
20
        factory <port>
 
21
        where <port> is a available port number, e.g. 18085
 
22
 
 
23
        Copyright (C) 2000-2002 Robert A. van Engelen. All Rights Reserved.
 
24
*/
 
25
 
 
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
 
31
 
 
32
//gsoap ns schema namespace: urn:factoryService
 
33
//gsoap t schema namespace: urn:factoryTypes
 
34
//gsoap h schema namespace: urn:factoryHandles
 
35
 
 
36
////////////////////////////////////////////////////////////////////////////////
 
37
//
 
38
//  SOAP Header: used to exchange stateful object handles
 
39
//
 
40
////////////////////////////////////////////////////////////////////////////////
 
41
 
 
42
struct SOAP_ENV__Header
 
43
{ mustUnderstand unsigned int h__handle;
 
44
};
 
45
 
 
46
////////////////////////////////////////////////////////////////////////////////
 
47
//
 
48
//  Server-side root class
 
49
//
 
50
////////////////////////////////////////////////////////////////////////////////
 
51
 
 
52
enum t__object                          // object types:
 
53
{ ROOT,                                 // t__root object
 
54
  ADDER,                                // t__adder object
 
55
  COUNTER                               // t__counter object
 
56
};
 
57
 
 
58
enum t__status                          // remote object status:
 
59
{ FACTORY_OK,                                   // ok
 
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
 
63
};
 
64
 
 
65
class t__root
 
66
{ public:
 
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
 
71
  t__root();
 
72
  virtual ~t__root();
 
73
  virtual void renew();                 // to renew lease
 
74
};
 
75
 
 
76
////////////////////////////////////////////////////////////////////////////////
 
77
//
 
78
//  Server-side adder class derived from root
 
79
//
 
80
////////////////////////////////////////////////////////////////////////////////
 
81
 
 
82
class t__adder: public t__root
 
83
{ public:
 
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
 
88
};
 
89
 
 
90
////////////////////////////////////////////////////////////////////////////////
 
91
//
 
92
//  Server-side counter class derived from adder
 
93
//
 
94
////////////////////////////////////////////////////////////////////////////////
 
95
 
 
96
class t__counter: public t__adder
 
97
{ public:
 
98
  void inc();                           // to increment the counter
 
99
};
 
100
 
 
101
////////////////////////////////////////////////////////////////////////////////
 
102
//
 
103
//  Remote factory method interfaces
 
104
//
 
105
////////////////////////////////////////////////////////////////////////////////
 
106
 
 
107
//gsoap ns service method-header-part: create h__handle
 
108
int ns__create(enum t__object object, char *name, enum t__status &status);
 
109
 
 
110
//gsoap ns service method-header-part: lookup h__handle
 
111
int ns__lookup(enum t__object object, char *name, enum t__status &status);
 
112
 
 
113
//gsoap ns service method-header-part: rename h__handle
 
114
int ns__rename(char *name, enum t__status &status);
 
115
 
 
116
//gsoap ns service method-header-part: release h__handle
 
117
int ns__release(enum t__status &status);
 
118
 
 
119
////////////////////////////////////////////////////////////////////////////////
 
120
//
 
121
//  Rewote adder method interfaces
 
122
//
 
123
////////////////////////////////////////////////////////////////////////////////
 
124
 
 
125
//gsoap ns service method-header-part: set h__handle
 
126
int ns__set(double val, enum t__status &status);
 
127
 
 
128
//gsoap ns service method-header-part: get h__handle
 
129
int ns__get(double &val);
 
130
 
 
131
//gsoap ns service method-header-part: add h__handle
 
132
int ns__add(double val, enum t__status &status);
 
133
 
 
134
////////////////////////////////////////////////////////////////////////////////
 
135
//
 
136
//  Remote counter method interfaces
 
137
//
 
138
////////////////////////////////////////////////////////////////////////////////
 
139
 
 
140
//gsoap ns service method-header-part: inc h__handle
 
141
int ns__inc(enum t__status &status);
 
142