summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/CosNotifyFilter.idl
blob: 1326fb193bd871c2e24931c1a5ca8a954d41b46f (plain)
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
/**
 * @file CosNotifyFilter.idl
 *
 * @brief Defines the CosNotifyFilter module
 *
 * $Id$
 *
 * This module is taken from the standard CORBA Notification Service
 * 1.0, as described in:
 *
 * http://www.omg.org/technology/documents/formal/notification_service.htm
 *
 * In particular the following two documents were used:
 * formal/2000-06-20
 * formal/01-03-03
 *
 * @author Pradeep Gore <pradeep@cs.wustl.edu>
 */

#ifndef _COS_NOTIFY_FILTER_IDL_
#define _COS_NOTIFY_FILTER_IDL_

#include <orb.idl>

#include "CosNotifyComm.idl"

#pragma prefix "omg.org"

/**
 * @namespace CosNotifyFilter
 *
 * @brief Defines the interfaces used in Event Filtering
 */
module CosNotifyFilter
{
  /// Constraints are assigned IDs by each Filter object, and can be
  /// modified using those IDs.
  typedef long ConstraintID;

  /**
   * @struct ConstraintExp
   *
   * @brief Defines a constraint expression.
   */
  struct ConstraintExp {
    /// The list of event types accepted
    CosNotification::EventTypeSeq event_types;
    /// A constraint (or filtering) expression
    string constraint_expr;
  };

  /// A sequence of constraint IDs
  typedef sequence<ConstraintID> ConstraintIDSeq;

  /// A sequence of constraint expressions
  typedef sequence<ConstraintExp> ConstraintExpSeq;

  /**
   * @struct ConstraintInfo
   *
   * @brief Helper data structure to modify a constraint expression.
   */
  struct ConstraintInfo {
    /// New constraint expression
    ConstraintExp constraint_expression;
    /// ID of the expression modified
    ConstraintID constraint_id;
  };

  /// Sequence of Constraint infos, modify multiple constraints.
  typedef sequence<ConstraintInfo> ConstraintInfoSeq;

  /**
   * @struct MappingConstraintPair
   *
   * @brief Helper structure used to modify a mapping constraint
   * expression.
   */
  struct MappingConstraintPair {
    /// Constraint expression
    ConstraintExp constraint_expression;
    /// Value to set in the property if the constraint expression
    /// matches
    any result_to_set;
  };

  /// Sequence of mapping constraint pairs
  typedef sequence<MappingConstraintPair> MappingConstraintPairSeq;

  /**
   * @struct MappingConstraintInfo
   *
   * @brief Helper structure used to represent a mapping constraint,
   * its property value and the ID assigned to it in a MappingFilter.
   */
  struct MappingConstraintInfo {
    ConstraintExp constraint_expression;
    ConstraintID constraint_id;
    any value;
  };
  /// A list of MappingConstraintInfo
  typedef sequence<MappingConstraintInfo> MappingConstraintInfoSeq;

  /// Each callback object receives a unique ID when it is attached to
  /// a Filter
  typedef long CallbackID;

  /// Batch management of callback objects in the Filter interface
  typedef sequence<CallbackID> CallbackIDSeq;

  /**
   * @exception UnsupportedFilterableData
   *
   * @brief Exception raised when an event with unsupported filtered
   * data is tested against a Filter.
   */
  exception UnsupportedFilterableData {};

  /**
   * @exception InvalidGrammar
   *
   * @brief Exception raised if the filtering expression is using an
   * invalid grammar.
   */
  exception InvalidGrammar {};

  /**
   * @exception InvalidConstraint
   *
   * @brief Exception raised if a constraint's grammar does not match
   *   the Filter grammar.
   *
   * The constraint that is deemed invalid is returned as part of the
   * exception.
   */
  exception InvalidConstraint {
    /// Constraint that caused the problem
    ConstraintExp constr;
  };

  /**
   * @exception DuplicateConstraintID
   *
   * @brief Exception raised if a duplicate ID is used while modifying
   * or removing multiple constraints.
   */
  exception DuplicateConstraintID {
    /// ID causing the problem
    ConstraintID id;
  };

  /**
   * @exception ConstraintNotFound
   *
   * @brief Exception raised if a constraint ID is not found while
   * modifying or removing multiple constraints.
   */
  exception ConstraintNotFound {
    /// ID causing the problem
    ConstraintID id;
  };

  /**
   * @exception CallbackNotFound
   *
   * @brief Exception raised if the application tries to remove a
   *        Filter callback that does not exists.
   */
  exception CallbackNotFound {};

  /**
   * @exception InvalidValue
   *
   * @brief Exception raised if a modification or addition of a
   * mapping constraint does not matches the mapping filter type.
   */
  exception InvalidValue {
    /// Constraint expression that cause the problem
    ConstraintExp constr;
    /// Value that caused the problem
    any value;
  };

  /**
   * @interface Filter
   *
   * @brief Interface used to manipulate and evaluate filters.
   *
   * An event filter posseses multiple constraints, each constraint
   * applies to a limited range of event types, the filter is accepted
   * if it matches one or more constraint expressions that apply to
   * its event type.
   */
  interface Filter {
    /// Constraint grammar used in this filter
    /**
     * All filtering expressions in the filter should use this
     * grammar.
     */
    readonly attribute string constraint_grammar;

    /// Add constraints to a filter
    /**
     * Return the constraints and their IDs.
     *
     * @throws InvalidConstraint if one or more constraints contain
     *    invalid an invalid expression in the Filter constraint
     *    grammar.
     */
    ConstraintInfoSeq add_constraints (
                          in ConstraintExpSeq constraint_list)
      raises (InvalidConstraint);

    /// Modify and/or remove multiple constraints in the Filter
    /**
     * The operation can raise InvalidConstraint if one or more
     * constraints contain invalid expressions in the constraint
     * grammar.
     *
     * @param del_list List of constraint IDs to be removed
     * @param modify_list List of constrained modified
     *
     * @throws ConstraintNotFound If one or more of the ConstraintID
     * supplied are not found.
     */
    void modify_constraints (
             in ConstraintIDSeq del_list,
             in ConstraintInfoSeq modify_list)
      raises (InvalidConstraint, ConstraintNotFound);

    /// Obtain the one or more constraints given their IDs
    /**
     * @param id_list List of IDs queried
     *
     * @throws ConstraintNotFound if one or more of
     * the ConstraintID supplied are not found.
     */
    ConstraintInfoSeq get_constraints(
                          in ConstraintIDSeq id_list)
      raises (ConstraintNotFound);

    /// The all the constraints in the Filter
    ConstraintInfoSeq get_all_constraints();

    /// Remove all the constraints from the Filter
    void remove_all_constraints();

    /// Destroy the Filter
    void destroy();

    /// Match a regular event against the constraints in the filter
    /**
     * @param filterable_data The Notification Service event to be
     *   tested against the constraints in this Filter
     * @return TRUE if at least one constraint evaluates to TRUE for
     *   the event.
     * @throws UnsupportedFilterableData if the event contents do not
     *    match the filtering expression, for example, if the
     *    expression for a filterable field expects a string, but the
     *    actual value is a number.
     */
    boolean match ( in any filterable_data )
      raises (UnsupportedFilterableData);

    /// Match a structured event against the constraints in the filter
    /**
     * @param filterable_data The Notification Service event to be
     *   tested against the constraints in this Filter
     * @return TRUE if at least one constraint expression evaluates
     *   to TRUE for the event.
     * @throws UnsupportedFilterableData if the event contents do not
     *    match the filtering expression, for example, if the
     *    expression for a filterable field expects a string, but the
     *    actual value is a number.
     */
    boolean match_structured (
                in CosNotification::StructuredEvent filterable_data )
      raises (UnsupportedFilterableData);

    /// Match a typed event against the constraints in the filter
    /**
     * @param filterable_data The sequence of properties that make the
     *   filterable portion of the Typed event.
     * @return TRUE if at least one constraint expression evaluates
     *   to TRUE for the event.
     * @throws UnsupportedFilterableData if the event contents do not
     *    match the filtering expression, for example, if the
     *    expression for a filterable field expects a string, but the
     *    actual value is a number.
     */
    boolean match_typed (
                in CosNotification::PropertySeq filterable_data )
      raises (UnsupportedFilterableData);

    /// Add a callback interface to the filter
    /**
     * Filters can communicate changes in the list of event types they
     * potentially accept.
     *
     * @param callback the object interested about changes in the
     *   Filter event type list.
     * @return A unique ID attached to the callback interface.
     */
    CallbackID attach_callback (
                   in CosNotifyComm::NotifySubscribe callback);

    /// Remove a callback interface from the filter
    /**
     * @param callback The ID of the callback removed
     *
     * @throws CallbackNotFound if the callback id supplied is not
     *   found in the internal list of callbacks.
     */
    void detach_callback ( in CallbackID callback)
      raises ( CallbackNotFound );

    /// Return all the callback IDs in the Filter object
    CallbackIDSeq get_callbacks();
  };

  /**
   * @interface MappingFilter
   *
   * @brief Mapping filters can be used to change properties of an
   *   event as it traverses the Notification Service.
   */
  interface MappingFilter {
    /// Return the constraint grammar used in the mapping filter
    readonly attribute string constraint_grammar;

    /// Return the type code for the property affected by this mapping
    /// filter
    readonly attribute CORBA::TypeCode value_type;

    /// Return the default value set by this mapping filter
    /**
     * The default value is used if there are no mapping constraint
     * expressions matching the event.
     */
    readonly attribute any default_value;

    /// Add multiple mapping constraints to the filter
    /**
     * @param pair_list List of constraint expressions and the
     *   corresponding property value
     *
     * @return The list of constraint expressions, their values, and
     *   the IDs assigned to them in this Filter.
     *
     * @throws InvalidConstraint if one or more constraint expressions
     *   do not match the constraint grammar of this mapping filter
     * @throws InvalidValue if the value in one or more mapping
     *   constraint pairs does not match the type code for this
     *   mapping filter.
     */
    MappingConstraintInfoSeq add_mapping_constraints (
                                in MappingConstraintPairSeq pair_list)
        raises (InvalidConstraint, InvalidValue);

    /// Modify and/or remove mapping constraints in the filter
    /**
     * @param del_list list of constraint IDs that should be removed
     * @param modify_list list of constraints that would be modified
     *
     * @throws InvalidConstraint if one or more constraint expressions
     *   do not match the constraint grammar of this mapping filter
     * @throws InvalidValue if the value in one or more mapping
     *   constraint pairs does not match the type code for this
     *   mapping filter.
     * @throws ConstraintNotFound if one or more mapping constraint
     *   IDs are not found in the filter
     */
    void modify_mapping_constraints (
             in ConstraintIDSeq del_list,
             in MappingConstraintInfoSeq modify_list)
      raises (InvalidConstraint, InvalidValue, ConstraintNotFound);

    /// Retrieve multiple mapping constraints from the filter
    /**
     * @param id_list the list of mapping constraint IDs requested
     * @return The list of constraint expressions, their values and
     *   IDs.
     * @throws ConstraintNotFound if one or more mapping constraint
     *   IDs are not found in the filter
     */
    MappingConstraintInfoSeq get_mapping_constraints (
                                 in ConstraintIDSeq id_list)
      raises (ConstraintNotFound);

    /// Get all the mapping constraints from the Filter
    MappingConstraintInfoSeq get_all_mapping_constraints();

    /// Remove all the mapping constraints in the Filter
    void remove_all_mapping_constraints();

    /// Destroy the mapping filter
    void destroy();

    /// Test an event against the mapping constraints
      boolean match ( in any filterable_data,
                      out any result_to_set )
        raises (UnsupportedFilterableData);

      boolean match_structured (
                  in CosNotification::StructuredEvent filterable_data,
                  out any result_to_set)
        raises (UnsupportedFilterableData);

      boolean match_typed (
                  in CosNotification::PropertySeq filterable_data,
                  out any result_to_set)
        raises (UnsupportedFilterableData);
  };

  /**
   * @interface FilterFactory
   *
   * @brief Create Filter and MappingFilter objects
   */
  interface FilterFactory {
    /// Create a new Filter object
    /**
     * @param constraint_grammar The name of the grammar used for this
     *   filter
     * @throws InvalidGrammar The grammar name provided is invalid or
     *   unsupported
     */
    Filter create_filter (in string constraint_grammar)
                        raises (InvalidGrammar);

    /// Create a new MappingFilter object
    /**
     * @param constraint_grammar The name of the grammar used for this
     *   filter
     * @param default_value The default property value used if no
     *   mapping constraint matches
     * @throws InvalidGrammar The grammar name provided is invalid or
     *   unsupported
     */
    MappingFilter create_mapping_filter (
                       in string constraint_grammar,
                       in any default_value)
      raises(InvalidGrammar);
  };

  /// Each filter is assigned a unique ID
  typedef long FilterID;

  /// List of filter IDs
  typedef sequence<FilterID> FilterIDSeq;

  /**
   * @exception FilterNotFound
   *
   * @brief Exception raised if a filter ID is not found.
   */
  exception FilterNotFound {};

  /**
   * @interface FilterAdmin
   *
   * @brief Interface used to modify the Filters attached to a
   *   Notification Service component
   */
  interface FilterAdmin {
    /// Add a filter
    /**
     * @param new_filter Filter to be added
     * @return The ID assigned to the new filter
     */
    FilterID add_filter ( in Filter new_filter );

    /// Remove a filter
    /**
     * @param filter ID of the filter to be removed
     * @throws FilterNotFound if the filter ID is not found in this
     *   FilterAdmin
     */
    void remove_filter ( in FilterID filter )
      raises ( FilterNotFound );

    /// Get a filter
    /**
     * @param filter ID of the filter returned
     * @return The filter
     * @throws FilterNotFound if the filter ID is not found in this
     *   FilterAdmin
     */
    Filter get_filter ( in FilterID filter )
      raises ( FilterNotFound );

    /// Get the IDs of all the filters
    /**
     * @return The list of all filter IDs in this component
     */
    FilterIDSeq get_all_filters();

    /// Remove all the filters from this component
    void remove_all_filters();
  };
};

#pragma prefix ""

#endif /* _COS_NOTIFY_FILTER_IDL_ */