summaryrefslogtreecommitdiff
path: root/TAO/tao/Cache_Entries_T.inl
blob: ee32589c8db3be9f85fdde554ade6df8f2bc8fdd (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// -*- C++ -*-
//
// $Id$

#include "tao/debug.h"
#include "ace/Log_Msg.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  template <typename TRANSPORT_TYPE> ACE_INLINE
  Cache_IntId_T<TRANSPORT_TYPE>::Cache_IntId_T (void)
    : transport_ (0),
      recycle_state_ (ENTRY_UNKNOWN),
      is_connected_ (false)
  {
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE
  Cache_IntId_T<TRANSPORT_TYPE>::Cache_IntId_T (const Cache_IntId_T &rhs)
    : transport_ (0),
      recycle_state_ (ENTRY_UNKNOWN),
      is_connected_ (false)
  {
    *this = rhs;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE bool
  Cache_IntId_T<TRANSPORT_TYPE>::operator== (const Cache_IntId_T &rhs) const
  {
    return (this->transport_ == rhs.transport_);
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE bool
  Cache_IntId_T<TRANSPORT_TYPE>::operator!= (const Cache_IntId_T &rhs) const
  {
    return (this->transport_ != rhs.transport_);
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE
  typename Cache_IntId_T<TRANSPORT_TYPE>::transport_type *
  Cache_IntId_T<TRANSPORT_TYPE>::transport (void)
  {
    return this->transport_;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE
  const typename Cache_IntId_T<TRANSPORT_TYPE>::transport_type *
  Cache_IntId_T<TRANSPORT_TYPE>::transport (void) const
  {
    return this->transport_;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE
  bool
  Cache_IntId_T<TRANSPORT_TYPE>::is_connected (void) const
  {
    return this->is_connected_;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE
  void
  Cache_IntId_T<TRANSPORT_TYPE>::is_connected (bool connected)
  {
    this->is_connected_ = connected;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE Cache_Entries_State
  Cache_IntId_T<TRANSPORT_TYPE>::recycle_state (void) const
  {
    return this->recycle_state_;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE
  typename Cache_IntId_T<TRANSPORT_TYPE>::transport_type *
  Cache_IntId_T<TRANSPORT_TYPE>::relinquish_transport (void)
  {
    // Yield ownership of the TAO_Transport object.
    transport_type *val = this->transport_;
    this->transport_ = 0;
    return val;
  }

  template <typename TRANSPORT_TYPE> ACE_INLINE const char *
  Cache_IntId_T<TRANSPORT_TYPE>::state_name (Cache_Entries_State st)
  {
#define TAO_CACHE_INTID_ENTRY(X) case X: return #X
    switch (st)
      {
        TAO_CACHE_INTID_ENTRY (ENTRY_IDLE_AND_PURGABLE);
        TAO_CACHE_INTID_ENTRY (ENTRY_PURGABLE_BUT_NOT_IDLE);
        TAO_CACHE_INTID_ENTRY (ENTRY_BUSY);
        TAO_CACHE_INTID_ENTRY (ENTRY_CLOSED);
        TAO_CACHE_INTID_ENTRY (ENTRY_CONNECTING);
        TAO_CACHE_INTID_ENTRY (ENTRY_UNKNOWN);
      }
    return "***Unknown enum value, update Cache_IntId_T::state_name()";
#undef TAO_CACHE_INTID_ENTRY
  }

  /*******************************************************/
  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::Cache_ExtId_T (void)
    : transport_property_ (0),
      is_delete_ (false),
      index_ (0)
  {
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::Cache_ExtId_T (
    typename Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::transport_descriptor_type *prop)
    : transport_property_ (prop),
      is_delete_ (false),
      index_ (0)
  {

  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::~Cache_ExtId_T (void)
  {
    if (this->is_delete_)
      delete this->transport_property_;
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE> &
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::operator= (const Cache_ExtId_T &rhs)
  {
    if (this != &rhs)
      {
        // Do a deep copy
        this->transport_property_ =
          rhs.transport_property_->duplicate ();

        if (this->transport_property_ == 0)
          {
            this->is_delete_ = false;
            this->index_ = 0;
          }
        else
          {
            this->is_delete_ = true;
            this->index_ = rhs.index_;
          }
      }
    return *this;
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::Cache_ExtId_T (const Cache_ExtId_T &rhs)
    : transport_property_ (0),
      is_delete_ (false),
      index_ (0)
  {
    *this = rhs;
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE bool
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::operator== (const Cache_ExtId_T &rhs) const
  {
    return (this->transport_property_->is_equivalent (rhs.transport_property_) &&
            this->index_ == rhs.index_);
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE bool
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::operator!= (const Cache_ExtId_T &rhs) const
  {
    if (this->transport_property_->is_equivalent (rhs.transport_property_) &&
        this->index_ == rhs.index_)
      return false;

    return true;
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE u_long
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::hash (void) const
  {
    return (this->transport_property_->hash () + this->index_);
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE void
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::duplicate (void)
  {
    transport_descriptor_type *prop = 0;

    // Make a deep copy
    prop = this->transport_property_->duplicate ();

    if (prop == 0)
      return;

    // Release memory if there was some allocated in the first place
    if (this->is_delete_)
      delete this->transport_property_;

    this->is_delete_ = true;
    this->transport_property_ = prop;
  }


  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE CORBA::ULong
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::index (void) const
  {
    return this->index_;
  }


  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE void
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::index (CORBA::ULong index)
  {
    this->index_ = index;
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE void
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::incr_index (void)
  {
    ++this->index_;
  }

  template <typename TRANSPORT_DESCRIPTOR_TYPE> ACE_INLINE
  typename Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::transport_descriptor_type *
  Cache_ExtId_T<TRANSPORT_DESCRIPTOR_TYPE>::property (void) const
  {
    return this->transport_property_;
  }
}

TAO_END_VERSIONED_NAMESPACE_DECL