summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_And_Filter.cpp
blob: 10d6b5aa22d3d62ee6f4f1cf87e3efd73225af23 (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
#include "orbsvcs/Event/EC_And_Filter.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_EC_And_Filter::TAO_EC_And_Filter (TAO_EC_Filter* children[],
                                      size_t n)
  :  children_ (children),
     n_ (n)
{
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin ();
       i != end;
       ++i)
    {
      this->adopt_child (*i);
    }
}

TAO_EC_And_Filter::~TAO_EC_And_Filter ()
{
  TAO_EC_Filter** end = this->children_ + this->n_;
  for (TAO_EC_Filter** i = this->children_;
       i != end;
       ++i)
    {
      delete *i;
      *i = 0;
    }
  delete[] this->children_;
  this->children_ = 0;
  this->n_ = 0;
}

TAO_EC_Filter::ChildrenIterator
TAO_EC_And_Filter::begin () const
{
  return this->children_;
}

TAO_EC_Filter::ChildrenIterator
TAO_EC_And_Filter::end () const
{
  return this->children_ + this->n_;
}

int
TAO_EC_And_Filter::size () const
{
  return static_cast<CORBA::ULong> (this->n_);
}

int
TAO_EC_And_Filter::filter (const RtecEventComm::EventSet& event,
                           TAO_EC_QOS_Info& qos_info)
{
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin (); i != end; ++i)
    {
      int n = (*i)->filter (event, qos_info);
      if (n == 0)
        return 0;
    }

  // All children accepted the event, push up...
  if (this->parent () != 0)
    {
      this->parent ()->push (event, qos_info);
    }

  return 1;
}

int
TAO_EC_And_Filter::filter_nocopy (RtecEventComm::EventSet& event,
                                  TAO_EC_QOS_Info& qos_info)
{
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin (); i != end; ++i)
    {
      int n = (*i)->filter_nocopy (event, qos_info);
      if (n == 0)
        return 0;
    }

  // All children accepted the event, push up...
  if (this->parent () != 0)
    {
      this->parent ()->push (event, qos_info);
    }

  return 1;
}

void
TAO_EC_And_Filter::push (const RtecEventComm::EventSet&,
                         TAO_EC_QOS_Info&)
{
}

void
TAO_EC_And_Filter::push_nocopy (RtecEventComm::EventSet&,
                                TAO_EC_QOS_Info&)
{
}

void
TAO_EC_And_Filter::clear ()
{
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin ();
       i != end;
       ++i)
    {
      (*i)->clear ();
    }
}

CORBA::ULong
TAO_EC_And_Filter::max_event_size () const
{
  CORBA::ULong n = 0;
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin ();
       i != end;
       ++i)
    {
      CORBA::ULong c = (*i)->max_event_size ();
      if (n < c)
        n = c;
    }
  return n;
}

int
TAO_EC_And_Filter::can_match (
      const RtecEventComm::EventHeader& header) const
{
  ChildrenIterator end = this->end ();
  for (ChildrenIterator i = this->begin ();
       i != end;
       ++i)
    {
      if ((*i)->can_match (header) == 0)
        return 0;
    }
  return 1;
}

int
TAO_EC_And_Filter::add_dependencies (
      const RtecEventComm::EventHeader&,
      const TAO_EC_QOS_Info&)
{
  return 0;
}

TAO_END_VERSIONED_NAMESPACE_DECL