summaryrefslogtreecommitdiff
path: root/TAO/tao/PI/PICurrent_Copy_Callback.cpp
blob: 9332b9c986adc957e9a85445000de14e8a1c857e (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
#include "tao/PI/PICurrent_Copy_Callback.h"

#if TAO_HAS_INTERCEPTORS == 1

#include "tao/PI/PICurrent_Impl.h"

ACE_RCSID (tao,
           PICurrent_Copy_Callback,
           "$Id$")


TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO::PICurrent_Copy_Callback::PICurrent_Copy_Callback (void)
  : src_ (0),
    dst_ (0)
{
}

TAO::PICurrent_Copy_Callback::~PICurrent_Copy_Callback (void)
{
  // Disable copy callbacks through this callback object in the source
  // PICurrent_Impl object to prevent the source PICurrent_Impl from
  // potentially calling back on a destructed copy callback object.
  if (this->src_ != 0)
    this->src_->copy_callback (0);
}

void
TAO::PICurrent_Copy_Callback::execute (void)
{
  if (this->src_ != 0 && this->dst_ != 0
      && this->src_ != this->dst_)
    {
      // Only do a copy when the destination still refers to the table
      // of the src
      if (this->dst_->lc_slot_table () != 0)
        {
          const PICurrent_Impl::Table & s = this->src_->current_slot_table ();

          // Disable use of the logically copied slot table before
          // performing the deep copy.
          this->dst_->lc_slot_table (0);

          PICurrent_Impl::Table & d = this->dst_->slot_table ();

          d = s;
        }

      // Prevent subsequent deep copies, effectively disabling this
      // callback.
      this->src_->copy_callback (0);
      this->src_->destruction_callback (0);
    }
}

void
TAO::PICurrent_Copy_Callback::src_and_dst (PICurrent_Impl * src,
                                           PICurrent_Impl * dst)
{
  this->src_ = src;
  this->dst_ = dst;
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif  /* TAO_HAS_INTERCEPTORS == 1 */