summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Object.cpp
blob: 58794b6bc6d608a68d1353ee3c123aadb84cd640 (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
// $Id$

#include "Object.h"
#include "Properties.h"
#include "Factory.h"
#include "POA_Helper.h"
#include "Worker_Task.h"
#include "QoSAdmin.h"
#include "tao/debug.h"

#if ! defined (__ACE_INLINE__)
#include "Object.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID(RT_Notify, TAO_NS_Object, "$Id$")

TAO_NS_Object::TAO_NS_Object (void)
  :event_manager_ (0), qos_admin_ (0), id_ (0), poa_ (0), worker_task_ (0), delete_worker_task_ (0)
{
  if (TAO_debug_level > 1 )
    ACE_DEBUG ((LM_DEBUG,"object:%x  created\n", this ));
}

TAO_NS_Object::~TAO_NS_Object ()
{
  if (TAO_debug_level > 1 )
    ACE_DEBUG ((LM_DEBUG,"object:%x  destroyed\n", this ));

  this->shutdown_worker_task ();

  delete qos_admin_;
}

void
TAO_NS_Object::init (TAO_NS_POA_Helper* poa, TAO_NS_Worker_Task* worker_task ACE_ENV_ARG_DECL)
{
  poa_ = poa;
  worker_task_ = worker_task;

  TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory ();
  factory->create (this->qos_admin_ ACE_ENV_ARG_PARAMETER);
}

CORBA::Object_ptr
TAO_NS_Object::activate (ACE_ENV_SINGLE_ARG_DECL)
{
  return poa_->activate (this->servant (), id_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_NS_Object::deactivate (ACE_ENV_SINGLE_ARG_DECL)
{
  poa_->deactivate (id_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_DECL)
{
  this->deactivate (ACE_ENV_SINGLE_ARG_PARAMETER);
}

CORBA::Object_ptr
TAO_NS_Object::ref (ACE_ENV_SINGLE_ARG_DECL)
{
  return poa_->id_to_reference (id_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_NS_Object::shutdown_worker_task (void)
{
  /// Only do this if we are the owner.
  if (delete_worker_task_ == 1)
    {
      this->worker_task_->shutdown ();
      delete this->worker_task_;
    }
}

void
TAO_NS_Object::worker_task_own (TAO_NS_Worker_Task* worker_task)
{
  this->worker_task (worker_task);

  /// claim ownership.
  delete_worker_task_ = 1;
}

void
TAO_NS_Object::worker_task (TAO_NS_Worker_Task* worker_task)
{
  /// shutdown the current worker.
  this->shutdown_worker_task ();

  this->worker_task_ = worker_task;

  delete_worker_task_ = 0;
}