summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Notify/Structured_Filter/Notify_Push_Consumer.cpp
blob: bfea3820bb26805e6b552ec21c45f8322c82d682 (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
/* -*- C++ -*- */
// $Id$

#include "Notify_Push_Consumer.h"

CORBA::Short Notify_Push_Consumer::event_count = 0;

Notify_Push_Consumer::Notify_Push_Consumer (const char* name)
 : name_ (name)
{
}


CORBA::Short
Notify_Push_Consumer::get_count ()
{
  return event_count;
}



static const char*
Any_String (const CORBA::Any& any)
{
  static char out[256] = "";
  CORBA::Short s;
  CORBA::UShort us;
  CORBA::Long l;
  CORBA::ULong ul;
  CORBA::ULongLong ull;
  const char* str;

  if (any >>= s)
    {
      ACE_OS::sprintf (out, "%d", s);
    }
  else if (any >>= us)
    {
      ACE_OS::sprintf (out, "%u", us);
    }
  else if (any >>= l)
    {
      ACE_OS::sprintf (out, "%d", l);
    }
  else if (any >>= ul)
    {
      ACE_OS::sprintf (out, "%u", ul);
    }
  else if (any >>= str)
    {
      ACE_OS_String::strcpy (out, str);
    }
  else if (any >>= ull)
    {
#if defined (ACE_LACKS_LONGLONG_T)
      ACE_OS_String::strcpy (out, ull.as_string (out));
#else
      // @@@@ (JP) Need to cast to signed int64 to cast to
      // double on Win32, but this hack may not fly on 
      // other platforms.
      double temp = (double) (CORBA::LongLong) ull;
      ACE_OS::sprintf (out, "%.0f", temp);
#endif /* ACE_LACKS_LONGLONG_T */
    }
  else
    {
      ACE_OS_String::strcpy (out, "Unsupported Any Type");
    }

  return out;
}


void
Notify_Push_Consumer::push_structured_event (
    const CosNotification::StructuredEvent& event
    TAO_ENV_ARG_NOT_USED
  )
    ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_DEBUG ((LM_DEBUG,
              "%s %d (sent recv) %s %s\n",
              Any_String (event.filterable_data[1].value),
              event_count,
              (const char*)event.filterable_data[0].name,
              Any_String (event.filterable_data[0].value)));

  event_count ++;
}