~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/orbsvcs/tests/Notify/Discarding/Notify_Sequence_Push_Consumer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Notify_Sequence_Push_Consumer.cpp,v 1.9 2003/10/30 20:59:10 bala Exp
2
 
 
3
 
#include "Notify_Sequence_Push_Consumer.h"
4
 
#include "orbsvcs/TimeBaseC.h"
5
 
#include "common.h"
6
 
#include "tao/debug.h"
7
 
 
8
 
Notify_Sequence_Push_Consumer::Notify_Sequence_Push_Consumer (
9
 
                                            const char* name,
10
 
                                            CORBA::Short policy,
11
 
                                            unsigned int low,
12
 
                                            unsigned int high,
13
 
                                            CORBA::Boolean& done)
14
 
 : name_ (name),
15
 
   discard_policy_ (policy),
16
 
   low_ (low),
17
 
   high_ (high),
18
 
   count_ (0),
19
 
   done_ (done)
20
 
{
21
 
}
22
 
 
23
 
 
24
 
void
25
 
Notify_Sequence_Push_Consumer::_connect (
26
 
                CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin
27
 
                ACE_ENV_ARG_DECL)
28
 
  ACE_THROW_SPEC ((CORBA::SystemException))
29
 
{
30
 
  CosNotifyComm::SequencePushConsumer_var objref =
31
 
    this->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
32
 
  ACE_CHECK;
33
 
 
34
 
  CosNotifyChannelAdmin::ProxySupplier_var proxysupplier =
35
 
    consumer_admin->obtain_notification_push_supplier (
36
 
      CosNotifyChannelAdmin::SEQUENCE_EVENT,
37
 
      proxy_id_
38
 
      ACE_ENV_ARG_PARAMETER);
39
 
  ACE_CHECK;
40
 
 
41
 
  this->proxy_ =
42
 
    CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow (
43
 
      proxysupplier.in () ACE_ENV_ARG_PARAMETER);
44
 
  ACE_CHECK;
45
 
 
46
 
  CosNotification::QoSProperties properties (4);
47
 
  properties.length (4);
48
 
  properties[0].name = CORBA::string_dup (CosNotification::MaximumBatchSize);
49
 
  properties[0].value <<= (CORBA::Long)5;
50
 
  properties[1].name = CORBA::string_dup (CosNotification::PacingInterval);
51
 
  properties[1].value <<= (TimeBase::TimeT)3;
52
 
  properties[2].name = CORBA::string_dup (CosNotification::DiscardPolicy);
53
 
  properties[2].value <<= this->discard_policy_;
54
 
  properties[3].name = CORBA::string_dup (CosNotification::MaxEventsPerConsumer);
55
 
  properties[3].value <<= (CORBA::Long)2;
56
 
 
57
 
  this->proxy_->set_qos (properties);
58
 
  this->proxy_->connect_sequence_push_consumer (objref.in ()
59
 
                                                ACE_ENV_ARG_PARAMETER);
60
 
  ACE_CHECK;
61
 
 
62
 
  // give ownership to POA
63
 
  this->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
64
 
  ACE_CHECK;
65
 
}
66
 
 
67
 
 
68
 
void
69
 
Notify_Sequence_Push_Consumer::push_structured_events (
70
 
                          const CosNotification::EventBatch& events
71
 
                          ACE_ENV_ARG_DECL_NOT_USED /*ACE_ENV_SINGLE_ARG_PARAMETER*/)
72
 
  ACE_THROW_SPEC ((CORBA::SystemException))
73
 
{
74
 
  CORBA::ULong length = events.length ();
75
 
 
76
 
  if (TAO_debug_level)
77
 
    ACE_DEBUG ((LM_DEBUG, "Received %u events:\n", length));
78
 
 
79
 
  for (CORBA::ULong e = 0; e < length; e++)
80
 
    {
81
 
      CORBA::ULong hlength = events[e].header.variable_header.length ();
82
 
      for (CORBA::ULong hi = 0; hi < hlength; hi++)
83
 
        {
84
 
          if (TAO_debug_level)
85
 
            ACE_DEBUG ((LM_DEBUG,
86
 
                        "%s = %s\n",
87
 
                        (const char*)events[e].header.variable_header[hi].name,
88
 
                        Any_String (events[e].header.variable_header[hi].value)));
89
 
        }
90
 
 
91
 
      CORBA::ULong flength = events[e].filterable_data.length ();
92
 
      for (CORBA::ULong i = 0; i < flength; i++)
93
 
        {
94
 
          if (TAO_debug_level)
95
 
            ACE_DEBUG ((LM_DEBUG,
96
 
                        "%s = %s\n",
97
 
                        (const char*)events[e].filterable_data[i].name,
98
 
                        Any_String (events[e].filterable_data[i].value)));
99
 
        }
100
 
    }
101
 
  if (TAO_debug_level)
102
 
    ACE_DEBUG ((LM_DEBUG,
103
 
                "-------------------------\n"));
104
 
  this->count_++;
105
 
 
106
 
  if (this->count_ > this->high_)
107
 
    {
108
 
      this->done_ = 2;
109
 
      ACE_ERROR ((LM_ERROR,
110
 
                  ACE_TEXT ("Sequence Consumer (%P|%t): ERROR: too "
111
 
                            "many events received.\n")));
112
 
    }
113
 
  else if (this->count_ == this->low_)
114
 
    {
115
 
      this->done_ = 1;
116
 
    }
117
 
  else
118
 
    {
119
 
      ACE_OS::sleep (1);
120
 
    }
121
 
}