summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_Lifetime_Utils.i
blob: 535eda1f85d9cd049a5053f39943cc2ac15827f5 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// $Id$

ACE_INLINE
TAO_EC_Object_Deactivator::TAO_EC_Object_Deactivator (void)
  : poa_ ()
  , id_ ()
  , deactivate_ (0)
{
}

ACE_INLINE
TAO_EC_Object_Deactivator::TAO_EC_Object_Deactivator (
                                        PortableServer::POA_ptr poa,
                                        PortableServer::ObjectId const & id)
  : poa_ (PortableServer::POA::_duplicate (poa))
  , id_ (id)
  , deactivate_ (1)
{
}

ACE_INLINE void
TAO_EC_Object_Deactivator::deactivate (void)
{
  if (this->deactivate_ && !CORBA::is_nil (this->poa_.in ()))
  {
    ACE_DECLARE_NEW_CORBA_ENV;
    ACE_TRY
    {
      this->deactivate_ = 0;
      this->poa_->deactivate_object (id_ ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
    ACE_CATCHANY
    {
      // The deactivation can throw...
    }
    ACE_ENDTRY;
  }
}

ACE_INLINE
TAO_EC_Object_Deactivator::~TAO_EC_Object_Deactivator (void)
{
  this->deactivate ();
}

ACE_INLINE PortableServer::POA_var
TAO_EC_Object_Deactivator::poa (void) const
{
  return this->poa_;
}

ACE_INLINE void
TAO_EC_Object_Deactivator::allow_deactivation (void)
{
  this->deactivate_ = 1;
}

ACE_INLINE void
TAO_EC_Object_Deactivator::disallow_deactivation (void)
{
  this->deactivate_ = 0;
}

ACE_INLINE void
TAO_EC_Object_Deactivator::set_values (PortableServer::POA_ptr poa,
                                       PortableServer::ObjectId const & id)
{
  this->poa_ = PortableServer::POA::_duplicate (poa);
  this->id_ = id;
  this->deactivate_ = 1;
}

ACE_INLINE void
TAO_EC_Object_Deactivator::set_values (TAO_EC_Object_Deactivator & deactivator)
{
  if (this == &deactivator)
    return;

  this->poa_ = deactivator.poa_._retn ();
  this->id_ = deactivator.id_;
  this->deactivate_ = deactivator.deactivate_;
  deactivator.deactivate_ = 0;
}

// ****************************************************************

ACE_INLINE
TAO_EC_Deactivated_Object::TAO_EC_Deactivated_Object (void)
  : deactivator_ ()
{
}

ACE_INLINE
TAO_EC_Deactivated_Object::~TAO_EC_Deactivated_Object (void)
{
  // Prevent automatic deactivation in deactivator's destructor.
  this->deactivator_.disallow_deactivation ();
}

ACE_INLINE void
TAO_EC_Deactivated_Object::set_deactivator (
                              TAO_EC_Object_Deactivator & deactivator)
{
  this->deactivator_.set_values (deactivator);
}

// ****************************************************************

ACE_INLINE
TAO_EC_ORB_Holder::TAO_EC_ORB_Holder (void)
  : orb_ ()
{
}

ACE_INLINE
TAO_EC_ORB_Holder::~TAO_EC_ORB_Holder (void)
{
  if (!CORBA::is_nil (this->orb_.in ()))
  {
    ACE_DECLARE_NEW_CORBA_ENV;
    ACE_TRY
      {
        this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
        ACE_TRY_CHECK;
      }
    ACE_CATCHANY
      {
        // Ignore.
      }
    ACE_ENDTRY;
  }
}

ACE_INLINE void
TAO_EC_ORB_Holder::init (CORBA::ORB_var orb_var)
{
  this->orb_ = orb_var;
}

// ****************************************************************

ACE_INLINE
TAO_EC_Event_Channel_Holder::TAO_EC_Event_Channel_Holder (void)
  : ec_ ()
{
}

ACE_INLINE
TAO_EC_Event_Channel_Holder::~TAO_EC_Event_Channel_Holder (void)
{
  if (!CORBA::is_nil (this->ec_.in ()))
  {
    ACE_DECLARE_NEW_CORBA_ENV;
    ACE_TRY
      {
        this->ec_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
        ACE_TRY_CHECK;
      }
    ACE_CATCHANY
      {
        // Ignore.
      }
    ACE_ENDTRY;
  }
}

ACE_INLINE void
TAO_EC_Event_Channel_Holder::init (
                    RtecEventChannelAdmin::EventChannel_var ec_var)
{
  this->ec_ = ec_var;
}