summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Transport_Current/Current_Impl.cpp
blob: 1cb391fefefe3bed8f39461385ab047e4e001dc1 (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
105
106
// $Id$

#include "tao/Transport.h"
#include "tao/Transport_Selection_Guard.h"

#include "orbsvcs/Transport_Current/Current_Loader.h"
#include "orbsvcs/Transport_Current/Current_Impl.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  namespace Transport
  {

    /// ctor
    Current_Impl::Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id)
      : core_ (core)
      , tss_slot_id_ (tss_slot_id)
    {
    }

    /// dtor
    Current_Impl::~Current_Impl (void)
    {
    }

    /// Obtains the current transport. Throws a NoContext exception
    /// if, there was no "current" transport selected on the current
    /// thread.
    const TAO_Transport*
    Current_Impl::transport (ACE_ENV_SINGLE_ARG_DECL) const
      ACE_THROW_SPEC ((NoContext))
    {
      Transport_Selection_Guard* topguard =
        Transport_Selection_Guard::current (this->core_, this->tss_slot_id_);

      if (topguard == 0)
        ACE_THROW (NoContext());
      ACE_CHECK;

      return topguard->get ();
    }

    /// Obtains the current transport's stats
    const TAO::Transport::Stats*
    Current_Impl::transport_stats (ACE_ENV_SINGLE_ARG_DECL) const
      ACE_THROW_SPEC ((NoContext))
    {
      static const TAO::Transport::Stats dummy;

      const TAO_Transport* t =
        this->transport (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK;

      return (t==0 || t->stats () == 0) ? &dummy : t->stats ();
    }

    CORBA::Long Current_Impl::id (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((::CORBA::SystemException, NoContext))
    {
      const TAO_Transport* t =
        this->transport (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK;

      return (t==0) ? 0 : t->id ();
    }

    CounterT Current_Impl::bytes_sent (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((::CORBA::SystemException, NoContext))
    {
      return transport_stats ()->bytes_sent ();
    }

    CounterT Current_Impl::bytes_received (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((::CORBA::SystemException, NoContext))
    {
      return transport_stats ()->bytes_received ();
    }

    CounterT Current_Impl::messages_sent (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((::CORBA::SystemException, NoContext))
    {
      return transport_stats ()->messages_sent ();
    }

    CounterT Current_Impl::messages_received (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((::CORBA::SystemException, NoContext))
    {
      return transport_stats ()->messages_received ();
    }

    TimeBase::TimeT Current_Impl::open_since (ACE_ENV_SINGLE_ARG_DECL)
      ACE_THROW_SPEC ((::CORBA::SystemException, NoContext))
    {
      TimeBase::TimeT msecs = 0;
      transport_stats ()->opened_since ().msec (msecs);
      return msecs;
    }

  };

};

TAO_END_VERSIONED_NAMESPACE_DECL