blob: 69dbd9d07084705e4b9aa0266d025d42a988b224 (
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
|
// $Id$
#include "Daemon_Impl.h"
#if !defined (__ACE_INLINE__)
# include "Daemon_Impl.inl"
#endif /* __ACE_INLINE__ */
CIAO::Daemon_Impl::~Daemon_Impl ()
{
for (Iterator i = this->table_.begin ();
i != this->table_.end ();
++i)
{
// Deallocate the id.
CORBA::string_free (ACE_const_cast (char *, (*i).ext_id_));
// Release the Object.
CORBA::release ((*i).int_id_);
}
this->table_.unbind_all ();
}
PortableServer::POA_ptr
CIAO::Daemon_Impl::_default_POA (void)
{
return PortableServer::POA::_duplicate (this->poa_.in ());
}
char *
CIAO::Daemon_Impl::name (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return CORBA::string_dup (this->name_.in ());
}
CORBA::Object_ptr
CIAO::Daemon_Impl::get_service (const char * svc_name
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
CIAO::NotFound))
{
CORBA::Object_ptr found = CORBA::Object::_nil ();
this->table_.find (svc_name, found);
if (CORBA::is_nil (found))
ACE_THROW_RETURN (CIAO::NotFound (), 0);
return CORBA::Object::_duplicate (found);
}
void
CIAO::Daemon_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
this->orb_->shutdown (0 ACE_ENV_SINGLE_ARG_PARAMETER);
}
int
CIAO::Daemon_Impl::bind (const char *id,
CORBA::Object_ptr obj)
{
// Make sure that the supplied Object reference is valid,
// i.e. not nil.
if (id == 0 || CORBA::is_nil (obj))
{
errno = EINVAL;
return -1;
};
CORBA::String_var name = CORBA::string_dup (id);
CORBA::Object_var object = CORBA::Object::_duplicate (obj);
int result = this->table_.bind (name.in (),
object.in ());
if (result == 0)
{
// Transfer ownership to the Object Table.
(void) name._retn ();
(void) object._retn ();
}
return result;
}
int
CIAO::Daemon_Impl::unbind (const char *id)
{
Table::ENTRY *entry = 0;
int result = this->table_.find (id, entry);
if (result == 0)
{
// Deallocate the external ID and obtain the ORB core pointer
// before unbinding the entry since the entry is deallocated
// during the call to unbind().
CORBA::string_free (ACE_const_cast (char *, entry->ext_id_));
CORBA::Object_ptr obj = entry->int_id_;
result = this->table_.unbind (entry);
if (result != 0)
return result;
CORBA::release (obj);
}
return result;
}
|