summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Notify/lib/Periodic_Consumer.h
blob: 2b48c1847dac85ecef1abd968f3c99ef657098ff (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
/* -*- C++ -*- */
/**
 *  @file NS_Periodic_Consumer.h
 *
 *  $Id$
 *
 *  @author Pradeep Gore <pradeep@oomworks.com>
 *
 *
 */

#ifndef TAO_NS_PERIODIC_CONSUMER_H
#define TAO_NS_PERIODIC_CONSUMER_H
#include "ace/pre.h"

#include "notify_test_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "Notify_StructuredPushConsumer.h"
#include "Task_Stats.h"

class TAO_NS_Task_Callback;
class ACE_Barrier;
class ACE_Arg_Shifter;

/**
 * @class TAO_NS_Periodic_Consumer
 *
 * @brief Receives Structured events periodically.
 *
 */
class TAO_NOTIFY_TEST_Export TAO_NS_Periodic_Consumer : public TAO_Notify_StructuredPushConsumer
{
public:
  /// Constuctor
  TAO_NS_Periodic_Consumer (void);

  /// Destructor
  ~TAO_NS_Periodic_Consumer ();

  /// set the helper callback
  void task_callback(TAO_NS_Task_Callback* client);

  /// Init the state of this object.
  int init_state (ACE_Arg_Shifter& arg_shifter);

  /// Connect.
  void connect (CosNotifyChannelAdmin::StructuredProxyPushSupplier_ptr proxy, CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL);

  /// connect
  void connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin ACE_ENV_ARG_DECL);

  /// Subscription change.
  void subscription_change (CosNotification::EventTypeSeq &added, CosNotification::EventTypeSeq& removed ACE_ENV_ARG_DECL);

  /// dump stats
  void dump_stats (ACE_TCHAR* msg);

    /// Get the name of the proxy
  const char* proxy_name (void);

protected:

  virtual void push_structured_event (
        const CosNotification::StructuredEvent & notification
        ACE_ENV_ARG_DECL
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException,
        CosEventComm::Disconnected
       ));

  /// = Data members.

  /// The name of the proxy we connect to.
  ACE_CString proxy_name_;

  /// count of events received.
  int count_;

  /// max events expected.
  /// Sometimes max count may not be the number of events that the supplier will send.
  /// A filter might not allow some events to through. we can tell the consumer what to expect.
  int max_count_;

  /// Stats house keeping
  Task_Stats stats_;

  /// Client
  TAO_NS_Task_Callback* client_;
};

#include "ace/post.h"
#endif /* TAO_NS_PERIODIC_CONSUMER_H */