summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Notify/lib/Supplier_T.cpp
blob: 3641ca65f32dcf6041ecb0d6e519c8d6b9642e9f (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
// $Id$
#ifndef TAO_Notify_Tests_Supplier_T_CPP
#define TAO_Notify_Tests_Supplier_T_CPP

#include "Supplier_T.h"

ACE_RCSID(Notify, TAO_Notify_Tests_Supplier_T, "$Id$")

template <class Supplier_Traits>
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::TAO_Notify_Tests_Supplier_T (void)
{
}

template <class Supplier_Traits>
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::~TAO_Notify_Tests_Supplier_T ()
{
}

template <class Supplier_Traits> ACE_TYPENAME TAO_Notify_Tests_Supplier_T<Supplier_Traits>::Proxy_Traits_PTR
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::get_proxy_consumer (void)
{
  return this->get_proxy ();
}

template <class Supplier_Traits> ACE_TYPENAME TAO_Notify_Tests_Supplier_T<Supplier_Traits>::Proxy_Traits_PTR
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::obtain_proxy (ACE_TYPENAME TAO_Notify_Tests_Supplier_T<Supplier_Traits>::Admin_Traits_PTR admin_ptr ACE_ENV_ARG_DECL)
{
  Supplier_Traits traits;

  CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
    admin_ptr->obtain_notification_push_consumer (traits.type_
                                                  , this->proxy_id_
                                                  ACE_ENV_ARG_PARAMETER
                                                  );

  ACE_CHECK_RETURN (Proxy_Traits_INTERFACE::_nil ());

  ACE_ASSERT (!CORBA::is_nil (proxy_consumer.in ()));

  return Proxy_Traits_INTERFACE::_narrow (proxy_consumer.in ()
  ACE_ENV_ARG_PARAMETER);
}

template <class Supplier_Traits> ACE_TYPENAME TAO_Notify_Tests_Supplier_T<Supplier_Traits>::Proxy_Traits_PTR
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::obtain_proxy (ACE_TYPENAME TAO_Notify_Tests_Supplier_T<Supplier_Traits>::Admin_Ext_Traits_PTR admin_ptr
                                             , CosNotification::QoSProperties& qos
                                             ACE_ENV_ARG_DECL)
{
  Supplier_Traits traits;

  // create the proxy consumer
  CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer =
    admin_ptr->obtain_notification_push_consumer_with_qos (traits.type_
                                                           , this->proxy_id_
                                                           , qos
                                                           ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (Proxy_Traits_INTERFACE::_nil ());

  ACE_ASSERT (!CORBA::is_nil (proxy_consumer.in ()));

  return Proxy_Traits_INTERFACE::_narrow (proxy_consumer.in ()
                                           ACE_ENV_ARG_PARAMETER);
}

template <class Supplier_Traits> void
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::offer_change (CosNotification::EventTypeSeq &added, CosNotification::EventTypeSeq& removed ACE_ENV_ARG_DECL)
{
  // Let the user see what we're subscribed for,
  ACE_DEBUG ((LM_DEBUG, "(%P, %t) Calling Supplier offer change: \n"));

  CORBA::ULong i = 0;

  for (; i < added.length (); ++i)
    {
      ACE_DEBUG ((LM_DEBUG, "+(%s,%s), ", added[i].domain_name.in (), added[i].type_name.in ()));
    }
  for (i = 0; i < removed.length (); ++i)
    {
      ACE_DEBUG ((LM_DEBUG, "-(%s,%s), ", removed[i].domain_name.in (), removed[i].type_name.in ()));
    }

  ACE_DEBUG ((LM_DEBUG, "\n"));

  /// subscribe
  ACE_TYPENAME Proxy_Traits::PTR proxy_consumer = this->get_proxy ();

  proxy_consumer->offer_change (added, removed ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
}

template <class Supplier_Traits> void
TAO_Notify_Tests_Supplier_T<Supplier_Traits>::subscription_change (
                                                         const CosNotification::EventTypeSeq & /*added*/,
                                                         const CosNotification::EventTypeSeq & /*removed*/
        ACE_ENV_ARG_DECL_NOT_USED
        )
  ACE_THROW_SPEC ((
                   CORBA::SystemException,
                   CosNotifyComm::InvalidEventType
                   ))
{
  // No op.
}
#endif /* TAO_Notify_Tests_Supplier_T_CPP */