1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
/* -*- C++ -*- */
//=============================================================================
/**
* @file Constraint_Nodes.h
*
* $Id$
*
* @author Seth Widoff <sbw1@cs.wustl.edu>
*/
//=============================================================================
#ifndef TAO_CONSTRAINT_NODES_H
#define TAO_CONSTRAINT_NODES_H
#include "ace/pre.h"
#include "Constraint_Tokens.h"
#include "tao/corba.h"
#include "orbsvcs/Trader/trading_export.h"
#if defined(_MSC_VER)
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif /* _MSC_VER >= 1200 */
#pragma warning (disable:4250)
#endif /* _MSC_VER */
class TAO_Constraint_Visitor;
typedef unsigned short TAO_Expression_Type;
/**
* @class TAO_Constraint
*
* @brief TAO_Constraint is the base class of all nodes on the
* constraint expression tree.
*
* An TAO_Constraint knows what type of operation or entity
* it represents, and which method on TAO_Constraint_Visitor
* correlates to its type. When the accept method is invoked, a
* subclass dispatches the method on an TAO_Constraint_Visitor
* correlating to its type.
*/
class TAO_Trading_Export TAO_Constraint
{
public:
/**
* Implementing the pattern of double dispatching, each subclass of
* TAO_Constraint will call back on an InterpreterVisitor the
* method to handle a node of its ExpressionType.
*/
virtual int accept (TAO_Constraint_Visitor* visitor) = 0;
/// Return the expression type represented by this node.
virtual TAO_Expression_Type expr_type (void) const = 0;
virtual ~TAO_Constraint (void) {}
};
/**
* @class TAO_Noop_Constraint
*
* @brief A node that represents an operation with no operands.
*/
class TAO_Trading_Export TAO_Noop_Constraint : public TAO_Constraint
{
public:
TAO_Noop_Constraint (TAO_Expression_Type type)
: type_ (type) {}
virtual int accept (TAO_Constraint_Visitor* visitor);
virtual TAO_Expression_Type expr_type (void) const
{ return this->type_; }
private:
TAO_Expression_Type type_;
};
/**
* @class TAO_Binary_Constraint
*
* @brief TAO_Binary_Constraint represents an operation with left
* and right operands.
*/
class TAO_Trading_Export TAO_Binary_Constraint : public TAO_Constraint
{
public:
TAO_Binary_Constraint (TAO_Expression_Type op_type,
TAO_Constraint* left,
TAO_Constraint* right);
virtual int accept (TAO_Constraint_Visitor* visitor);
virtual ~TAO_Binary_Constraint (void);
virtual TAO_Expression_Type expr_type (void) const
{ return this->op_; }
/// Return the left operand of the binary expression
TAO_Constraint* left_operand (void) const;
/// Return the right operand of the binary expression
TAO_Constraint* right_operand (void) const;
// Allow double dispatching without creating an inundation of
// classes by using a dispatch table of static method pointers to
// invoke the correct visitor method as efficiently as a virtual
// method invocation.
static int visit_or (TAO_Constraint_Visitor*, TAO_Binary_Constraint*);
static int visit_and (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_less_than (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_less_than_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_greater_than (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_greater_than_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_not_equal (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_add (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_sub (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_mult (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_div (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_twiddle (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
static int visit_in (TAO_Constraint_Visitor* , TAO_Binary_Constraint*);
private:
TAO_Binary_Constraint (const TAO_Binary_Constraint&);
TAO_Binary_Constraint& operator= (const TAO_Binary_Constraint&);
/// The operator type
TAO_Expression_Type op_;
/// The operands of the expression
TAO_Constraint* left_;
TAO_Constraint* right_;
};
/**
* @class TAO_Unary_Constraint
*
* @brief TAO_Unary_Constraint represents an operation with only
* one operand.
*/
class TAO_Trading_Export TAO_Unary_Constraint : public TAO_Constraint
{
public:
TAO_Unary_Constraint (TAO_Expression_Type op_type,
TAO_Constraint* operand);
virtual ~TAO_Unary_Constraint (void);
virtual int accept (TAO_Constraint_Visitor* visitor);
virtual TAO_Expression_Type expr_type (void) const
{ return this->op_; }
TAO_Constraint* operand (void);
private:
TAO_Unary_Constraint (const TAO_Unary_Constraint&);
TAO_Unary_Constraint& operator= (const TAO_Unary_Constraint&);
/// The operator type
TAO_Expression_Type op_;
/// The operand of the expression
TAO_Constraint* operand_;
};
/**
* @class TAO_Property_Constraint
*
* @brief TAO_Property_Constraint represents a property whose
* value is determined by the offer being evaluated.
*/
class TAO_Trading_Export TAO_Property_Constraint : public TAO_Constraint
{
public:
TAO_Property_Constraint (const char* name);
virtual ~TAO_Property_Constraint (void);
virtual int accept (TAO_Constraint_Visitor* visitor);
virtual TAO_Expression_Type expr_type (void) const
{ return TAO_IDENT; }
/// Returns the name of the property.
const char* name (void) const;
private:
TAO_Property_Constraint (const TAO_Property_Constraint&);
TAO_Property_Constraint& operator= (const TAO_Property_Constraint&);
/// The name of the property.
char* name_;
};
/**
* @class TAO_Literal_Constraint
*
* @brief TAO_Literal_Constraint represents a literal occuring in
* the constraint expression tree.
*/
class TAO_Trading_Export TAO_Literal_Constraint : public TAO_Constraint
{
public:
TAO_Literal_Constraint (void)
: type_ (TAO_UNKNOWN) {}
// = Constructors for each of the various types of literals.
TAO_Literal_Constraint (CORBA::Any* any);
TAO_Literal_Constraint (CORBA::ULong uinteger);
TAO_Literal_Constraint (CORBA::Long integer);
TAO_Literal_Constraint (CORBA::Boolean boolean);
TAO_Literal_Constraint (CORBA::Double doub);
TAO_Literal_Constraint (const char* str);
/// Copy constructor
TAO_Literal_Constraint (const TAO_Literal_Constraint& lit);
/// Destructor.
~TAO_Literal_Constraint(void);
/// Visitor accept methods.
virtual int accept (TAO_Constraint_Visitor* visitor);
virtual TAO_Expression_Type expr_type (void) const
{ return type_; }
/// Assignment operator.
void operator= (const TAO_Literal_Constraint& co);
// Conversion routines.
operator CORBA::Boolean (void) const;
operator CORBA::ULong (void) const;
operator CORBA::Long (void) const;
operator CORBA::Double (void) const;
operator const char* (void) const;
operator const CORBA::Any* (void) const;
// Return the type represented by this MysteryOperand.
// = Comparison operators.
friend int
operator< (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend int
operator<= (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend int
operator> (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend int
operator>= (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend int
operator== (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend int
operator!= (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend int
operator== (double left,
const TAO_Literal_Constraint& right);
friend int
operator== (const TAO_String_Manager& left,
const TAO_Literal_Constraint& right);
// = Arithmetic operators.
friend TAO_Literal_Constraint
operator+ (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend TAO_Literal_Constraint
operator- (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend TAO_Literal_Constraint
operator* (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend TAO_Literal_Constraint
operator/ (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
friend TAO_Literal_Constraint
operator- (const TAO_Literal_Constraint& operand);
/// Ensure both operands are of the same simple numeric type.
static TAO_Expression_Type
widest_type (const TAO_Literal_Constraint& left,
const TAO_Literal_Constraint& right);
/// Determine the comparable Expression Type from the CORBA type
static TAO_Expression_Type
comparable_type (CORBA::TypeCode_ptr type);
private:
/// Private copy method.
void copy (const TAO_Literal_Constraint& co);
union
{
char* str_;
CORBA::Any_ptr any_;
CORBA::ULong uinteger_;
CORBA::Long integer_;
CORBA::Boolean bool_;
CORBA::Double double_;
} op_;
// Union of the possible literal types.
/// The actual types of the TAO_Literal_Constraint.
TAO_Expression_Type type_;
};
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma warning(pop)
#endif /* _MSC_VER */
#include "ace/post.h"
#endif /* TAO_CONSTRAINT_NODES_H */
|