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
|
// Framework_Component.cpp
// $Id$
#include "ace/Framework_Component.h"
#if !defined (__ACE_INLINE__)
#include "ace/Framework_Component.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Object_Manager.h"
#include "ace/Log_Msg.h"
ACE_RCSID(ace, Framework_Component, "$Id$")
ACE_Framework_Component::~ACE_Framework_Component (void)
{
ACE_TRACE ("ACE_Framework_Component::~ACE_Framework_Component");
}
/***************************************************************/
ACE_ALLOC_HOOK_DEFINE(ACE_Framework_Repository)
// Pointer to the Singleton instance.
ACE_Framework_Repository *ACE_Framework_Repository::repository_ = 0;
ACE_Framework_Repository::~ACE_Framework_Repository (void)
{
ACE_TRACE ("ACE_Framework_Repository::~ACE_Framework_Repository");
this->close ();
}
int
ACE_Framework_Repository::open (int size)
{
ACE_TRACE ("ACE_Framework_Repository::open");
ACE_Framework_Component **temp;
ACE_NEW_RETURN (temp,
ACE_Framework_Component *[size],
-1);
this->component_vector_ = ACE_const_cast (const ACE_Framework_Component **,
temp);
this->total_size_ = size;
return 0;
}
int
ACE_Framework_Repository::close (void)
{
ACE_TRACE ("ACE_Framework_Repository::close");
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
if (this->component_vector_ != 0)
{
// Delete components in reverse order.
for (int i = this->current_size_ - 1; i >= 0; i--)
{
ACE_Framework_Component *s = ACE_const_cast (ACE_Framework_Component *,
this->component_vector_[i]);
--this->current_size_;
delete s;
}
delete [] this->component_vector_;
this->component_vector_ = 0;
this->current_size_ = 0;
}
return 0;
}
ACE_Framework_Repository *
ACE_Framework_Repository::instance (int size)
{
ACE_TRACE ("ACE_Framework_Repository::instance");
if (ACE_Framework_Repository::repository_ == 0)
{
// Perform Double-Checked Locking Optimization.
ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance (), 0));
if (ACE_Framework_Repository::repository_ == 0)
{
if (ACE_Object_Manager::starting_up () ||
!ACE_Object_Manager::shutting_down ())
{
ACE_NEW_RETURN (ACE_Framework_Repository::repository_,
ACE_Framework_Repository (size),
0);
}
}
}
return ACE_Framework_Repository::repository_;
}
void
ACE_Framework_Repository::close_singleton (void)
{
ACE_TRACE ("ACE_Framework_Repository::close_singleton");
ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance ()));
delete ACE_Framework_Repository::repository_;
ACE_Framework_Repository::repository_ = 0;
}
int
ACE_Framework_Repository::register_component (const ACE_Framework_Component *fc)
{
ACE_TRACE ("ACE_Framework_Repository::register_component");
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
int i;
// Check to see if it's already registered
for (i = 0; i < this->current_size_; i++)
if (fc->this_ == this->component_vector_[i]->this_)
{
// Delete it since it's already here and component adapter was newed.
delete fc;
return 0;
}
if (i < this->total_size_)
{
this->component_vector_[i] = fc;
this->current_size_++;
return 0;
}
return -1;
}
void
ACE_Framework_Repository::dump (void) const
{
ACE_TRACE ("ACE_Framework_Repository::dump");
}
ACE_Framework_Repository::ACE_Framework_Repository (int size)
: current_size_ (0)
{
ACE_TRACE ("ACE_Framework_Repository::ctor");
if (this->open (size) == -1)
ACE_ERROR ((LM_ERROR,
ACE_LIB_TEXT ("%p\n"),
ACE_LIB_TEXT ("ACE_Framework_Repository")));
}
|