OmniEvents
Filter.cc
Go to the documentation of this file.
1 // Package : omniEvents
2 // Filter.cc 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 #include "Filter.h"
25 
26 #include <assert.h>
27 
28 #ifdef HAVE_OMNIORB4
29 # define STR_MATCH(s1,s2) omni::strMatch((s1),(s2))
30 #else
31 # define STR_MATCH(s1,s2) (0==::strcmp((s1),(s2)))
32 #endif
33 
34 namespace OmniEvents {
35 
36 bool FilterByRepositoryId::keep(const CORBA::Any& event) const
37 {
38  using namespace CORBA;
39  CORBA::TypeCode_var tc=event.type();
40  switch( tc->kind() )
41  {
42 #ifdef HAVE_OMNIORB4
43  case _np_tk_indirect: // Internal to omniORB. We should never get this.
44  assert(0);
45 #endif
46 
47  // TCs with Repository ID:
48  case tk_objref:
49  case tk_struct:
50  case tk_union:
51  case tk_enum:
52  case tk_alias:
53  case tk_except:
54  return STR_MATCH( _rid.in(), tc->id() );
55 
56  // Collections
57  case tk_sequence:
58  case tk_array:
59 
60  // Primitives
61  case tk_null:
62  case tk_void:
63  case tk_short:
64  case tk_long:
65  case tk_ushort:
66  case tk_ulong:
67  case tk_float:
68  case tk_double:
69  case tk_boolean:
70  case tk_char:
71  case tk_octet:
72  case tk_any:
73  case tk_TypeCode:
74  case tk_Principal:
75  case tk_string:
76 #ifdef HAS_LongLong
77  case tk_longlong:
78  case tk_ulonglong:
79 #endif
80 #ifdef HAS_LongDouble
81  case tk_longdouble:
82 #endif
83 #ifndef HAVE_OMNIORB3
84  case tk_wchar:
85  case tk_wstring:
86  case tk_fixed:
87 
88  // WTF? Not implemented in omniORB?
89  case tk_value:
90  case tk_value_box:
91  case tk_native:
92  case tk_abstract_interface:
93  case tk_local_interface:
94 #else
95  default:
96 #endif
97  break;
98  } // end case. Note: no default, so that missing options are flagged by GCC.
99  return false;
100 }
101 
102 }; // end namespace OmniEvents
#define STR_MATCH(s1, s2)
Definition: Filter.cc:31
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