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

#if TAO_HAS_INTERCEPTORS == 1

#include "PICurrent_Impl.h"

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


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);
}

int
TAO::PICurrent_Copy_Callback::execute (void)
{
  if (this->src_ != 0 && this->dst_ != 0
      && this->src_ != this->dst_)
    {
      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);
    }

  return 0;
}

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

#endif  /* TAO_HAS_INTERCEPTORS == 1 */