summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Bug_2925_Regression/Hello_Impl.cpp
blob: 9c94701468d07e373e366da92e4a21b1324871dc (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
//
// $Id$
//

#include "Hello_Impl.h"

Hello_Impl::Hello_Impl (CORBA::ORB_ptr orb, MessageLog* logger)
  : orb_ (CORBA::ORB::_duplicate (orb))
  , logger_ (logger)
{
}

void
Hello_Impl::say_hello (CORBA::Short count)
{
  this->logger_->register_message_recv (count);

  ACE_DEBUG ((LM_DEBUG,
              "%02d<<; ",
              count));
}

void
Hello_Impl::shutdown ()
{
  try
    {
      this->orb_->shutdown (0);
    }
  catch (const CORBA::Exception& ex)
    {
      //FUZZ: disable check_for_lack_ACE_OS
      ex._tao_print_exception ("Exception caught in shutdown ():");
      //FUZZ: enable check_for_lack_ACE_OS
    }
}

MessageLog::MessageLog (int num)
  : expected_ (num)
{
  this->rcvd_ = new int[this->expected_];

  int i;
  for (i = 0; i < this->expected_; i++)
    {
      this->rcvd_[i] = 0;
    }
}

MessageLog::~MessageLog ()
{
  delete [] this->rcvd_;
}

void
MessageLog::register_message_recv (int message_num)
{
  if (0 <= message_num && message_num < this->expected_)
    {
      this->rcvd_[message_num]++;
    }
}

int
MessageLog::report_statistics ()
{
  int i, count = 0;
  for (i = 0; i < this->expected_; i++)
    {
      count += this->rcvd_[i];

      if (this->rcvd_[i] == 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "\nLOST message <<< %d >>>",
                      i));
        }
    }

  return count;
}