OmniEvents
Filter.h
Go to the documentation of this file.
1// Package : omniEvents
2// Filter.h Created : 2004/04/30
3// Author : Alex Tingle
4//
5// Copyright (C) 2004 Alex Tingle.
6//
7// This file is part of the omniEvents application.
8//
9// omniEvents is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// omniEvents is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22//
23
24#ifndef OMNIEVENTS__FILTER_H
25#define OMNIEVENTS__FILTER_H
26
27#ifdef HAVE_CONFIG_H
28# include "config.h"
29#endif
30
31#include "Orb.h"
32
33#include <string.h>
34
35#ifdef HAVE_IOSTREAM
36# include <iostream>
37#else
38# include <iostream.h>
39#endif
40
41#ifdef HAVE_STD_IOSTREAM
42using namespace std;
43#endif
44
45
46namespace OmniEvents {
47
49class Filter
50{
51public:
53 virtual ~Filter(){}
54
58 virtual bool keep(const CORBA::Any& event) const =0;
59
60 virtual void output(ostream& os) const =0;
61};
62
67{
68public:
69 FilterByTCKind(CORBA::TCKind kind):_kind(kind){}
70 virtual ~FilterByTCKind(){}
71 bool keep(const CORBA::Any& event) const
72 {
73 CORBA::TypeCode_var tc=event.type();
74 return( tc->kind()==_kind );
75 }
76 void output(ostream& os) const { os<<"\n FilterKind="<<_kind; }
77private:
78 CORBA::TCKind _kind;
79};
80
85{
86public:
87 FilterByRepositoryId(const char* rid):_rid(rid){}
89 bool keep(const CORBA::Any& event) const;
90 void output(ostream& os) const { os<<"\n FilterId="<<_rid; }
91private:
92 CORBA::RepositoryId_var _rid;
93};
94
95}; // end namespace OmniEvents
96
97#endif // OMNIEVENTS__FILTER_H
Event filter interface.
Definition Filter.h:50
virtual ~Filter()
Definition Filter.h:53
virtual bool keep(const CORBA::Any &event) const =0
Returns TRUE if the event passes the filter and FALSE if the event should be discarded.
virtual void output(ostream &os) const =0
The most basic event filter allows only events of a certain CORBA TCKind to pass.
Definition Filter.h:67
bool keep(const CORBA::Any &event) const
Returns TRUE if the event passes the filter and FALSE if the event should be discarded.
Definition Filter.h:71
CORBA::TCKind _kind
Definition Filter.h:78
virtual ~FilterByTCKind()
Definition Filter.h:70
FilterByTCKind(CORBA::TCKind kind)
Definition Filter.h:69
void output(ostream &os) const
Definition Filter.h:76
Allows only events of a certain CORBA RepositoryId to pass.
Definition Filter.h:85
void output(ostream &os) const
Definition Filter.h:90
FilterByRepositoryId(const char *rid)
Definition Filter.h:87
CORBA::RepositoryId_var _rid
Definition Filter.h:92
bool keep(const CORBA::Any &event) const
Returns TRUE if the event passes the filter and FALSE if the event should be discarded.
Definition Filter.cc:36