#include <Framework_Component.h>
Collaboration diagram for ACE_Framework_Repository:
Public Types | |
enum | { DEFAULT_SIZE = ACE_DEFAULT_FRAMEWORK_REPOSITORY_SIZE } |
Public Member Functions | |
~ACE_Framework_Repository (void) | |
int | open (int size=DEFAULT_SIZE) |
Initialize the repository. | |
int | close (void) |
int | register_component (ACE_Framework_Component *fc) |
int | remove_component (const ACE_TCHAR *name) |
int | remove_dll_components (const ACE_TCHAR *dll_name) |
Remove all components associated with a particular dll. | |
int | current_size (void) const |
Return the current size of the repository. | |
int | total_size (void) const |
Return the total size of the repository. | |
void | dump (void) const |
Dump the state of an object. | |
Static Public Member Functions | |
ACE_Framework_Repository * | instance (int size=ACE_Framework_Repository::DEFAULT_SIZE) |
Get pointer to a process-wide ACE_Framework_Repository. | |
void | close_singleton (void) |
Delete the dynamically allocated Singleton. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Member Functions | |
ACE_Framework_Repository (int size=ACE_Framework_Repository::DEFAULT_SIZE) | |
Initialize the repository. | |
Private Member Functions | |
int | remove_dll_components_i (const ACE_TCHAR *dll_name) |
Actually removes the dll components, must be called with locks held. | |
void | compact (void) |
ACE_Framework_Repository (const ACE_Framework_Repository &) | |
Disallow copying and assignment. | |
ACE_Framework_Repository & | operator= (const ACE_Framework_Repository &) |
Private Attributes | |
ACE_Framework_Component ** | component_vector_ |
Contains all the framework components. | |
int | current_size_ |
Current number of components. | |
int | total_size_ |
Maximum number of components. | |
Static Private Attributes | |
ACE_Framework_Repository * | repository_ = 0 |
Pointer to a process-wide ACE_Framework_Repository. | |
sig_atomic_t | shutting_down_ = 0 |
Friends | |
class | ACE_Framework_Component |
This class contains a vector of ACE_Framework_Component *'s. On destruction, framework components are destroyed in the reverse order that they were added originally.
Definition at line 101 of file Framework_Component.h.
|
Definition at line 107 of file Framework_Component.h.
00108 { 00109 DEFAULT_SIZE = ACE_DEFAULT_FRAMEWORK_REPOSITORY_SIZE 00110 }; |
|
Close down the repository and free up dynamically allocated resources. Definition at line 37 of file Framework_Component.cpp. References ACE_TRACE, and close().
|
|
Initialize the repository.
Definition at line 269 of file Framework_Component.cpp. References ACE_ERROR, ACE_TEXT, ACE_TRACE, LM_ERROR, and open().
00270 : current_size_ (0) 00271 { 00272 ACE_TRACE ("ACE_Framework_Repository::ACE_Framework_Repository"); 00273 00274 if (this->open (size) == -1) 00275 ACE_ERROR ((LM_ERROR, 00276 ACE_TEXT ("%p\n"), 00277 ACE_TEXT ("ACE_Framework_Repository"))); 00278 } |
|
Disallow copying and assignment.
|
|
Close down the repository and free up dynamically allocated resources, also called by dtor. Definition at line 60 of file Framework_Component.cpp. References ACE_GUARD_RETURN, ACE_TRACE, ACE_DLL_Manager::close_singleton(), component_vector_, and shutting_down_. Referenced by ~ACE_Framework_Repository().
00061 { 00062 ACE_TRACE ("ACE_Framework_Repository::close"); 00063 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); 00064 00065 this->shutting_down_ = 1; 00066 00067 if (this->component_vector_ != 0) 00068 { 00069 // Delete components in reverse order. 00070 for (int i = this->current_size_ - 1; i >= 0; i--) 00071 if (this->component_vector_[i]) 00072 { 00073 ACE_Framework_Component *s = 00074 const_cast<ACE_Framework_Component *> ( 00075 this->component_vector_[i]); 00076 00077 this->component_vector_[i] = 0; 00078 delete s; 00079 } 00080 00081 delete [] this->component_vector_; 00082 this->component_vector_ = 0; 00083 this->current_size_ = 0; 00084 } 00085 00086 ACE_DLL_Manager::close_singleton (); 00087 return 0; 00088 } |
|
Delete the dynamically allocated Singleton.
Definition at line 116 of file Framework_Component.cpp. References ACE_GUARD, ACE_TRACE, and repository_. Referenced by ACE_Object_Manager::fini().
00117 { 00118 ACE_TRACE ("ACE_Framework_Repository::close_singleton"); 00119 00120 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00121 *ACE_Static_Object_Lock::instance ())); 00122 00123 delete ACE_Framework_Repository::repository_; 00124 ACE_Framework_Repository::repository_ = 0; 00125 } |
|
Compact component_vector_ after components have been removed__maintains order. Definition at line 215 of file Framework_Component.cpp. References ACE_TRACE, and component_vector_. Referenced by remove_component(), and remove_dll_components_i().
00216 { 00217 ACE_TRACE ("ACE_Framework_Repository::compact"); 00218 00219 int i; 00220 int start_hole; 00221 int end_hole; 00222 00223 do 00224 { 00225 start_hole = this->current_size_; 00226 end_hole = this->current_size_; 00227 00228 // Find hole 00229 for (i = 0; i < this->current_size_; ++i) 00230 { 00231 if (this->component_vector_[i] == 0) 00232 { 00233 if (start_hole == this->current_size_) 00234 { 00235 start_hole = i; 00236 end_hole = i; 00237 } 00238 else 00239 end_hole = i; 00240 } 00241 else if (end_hole != this->current_size_) 00242 break; 00243 } 00244 00245 if (start_hole != this->current_size_) 00246 { 00247 // move the contents and reset current_size_ 00248 while (end_hole + 1 < this->current_size_) 00249 { 00250 this->component_vector_[start_hole++] = 00251 this->component_vector_[++end_hole]; 00252 } 00253 // Since start_hole is now one past the last 00254 // active slot. 00255 this->current_size_ = start_hole; 00256 } 00257 00258 } while (start_hole != this->current_size_); 00259 } |
|
Return the current size of the repository.
Definition at line 24 of file Framework_Component.inl. References ACE_GUARD_RETURN, and ACE_TRACE.
00025 { 00026 ACE_TRACE ("ACE_Framework_Repository::current_size"); 00027 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->lock_, -1)); 00028 return this->current_size_; 00029 } |
|
Dump the state of an object.
Definition at line 262 of file Framework_Component.cpp. References ACE_TRACE.
00263 { 00264 #if defined (ACE_HAS_DUMP) 00265 ACE_TRACE ("ACE_Framework_Repository::dump"); 00266 #endif /* ACE_HAS_DUMP */ 00267 } |
|
Get pointer to a process-wide ACE_Framework_Repository.
Definition at line 91 of file Framework_Component.cpp. References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, repository_, ACE_Object_Manager::shutting_down(), and ACE_Object_Manager::starting_up(). Referenced by ACE_DLL_Handle::close(), and ACE_DLL_Singleton_T< TYPE, ACE_LOCK >::instance().
00092 { 00093 ACE_TRACE ("ACE_Framework_Repository::instance"); 00094 00095 if (ACE_Framework_Repository::repository_ == 0) 00096 { 00097 // Perform Double-Checked Locking Optimization. 00098 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 00099 *ACE_Static_Object_Lock::instance (), 0)); 00100 if (ACE_Framework_Repository::repository_ == 0) 00101 { 00102 if (ACE_Object_Manager::starting_up () || 00103 !ACE_Object_Manager::shutting_down ()) 00104 { 00105 ACE_NEW_RETURN (ACE_Framework_Repository::repository_, 00106 ACE_Framework_Repository (size), 00107 0); 00108 } 00109 } 00110 } 00111 00112 return ACE_Framework_Repository::repository_; 00113 } |
|
Initialize the repository.
Definition at line 44 of file Framework_Component.cpp. References ACE_NEW_RETURN, ACE_TRACE, and component_vector_. Referenced by ACE_Framework_Repository().
00045 { 00046 ACE_TRACE ("ACE_Framework_Repository::open"); 00047 00048 ACE_Framework_Component **temp = 0; 00049 00050 ACE_NEW_RETURN (temp, 00051 ACE_Framework_Component *[size], 00052 -1); 00053 00054 this->component_vector_ = temp; 00055 this->total_size_ = size; 00056 return 0; 00057 } |
|
|
|
Insert a new component. Returns -1 when the repository is full and 0 on success. Definition at line 128 of file Framework_Component.cpp. References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_TEXT, ACE_TRACE, component_vector_, LM_ERROR, and ACE_Framework_Component::this_. Referenced by ACE_DLL_Singleton_T< TYPE, ACE_LOCK >::instance().
00129 { 00130 ACE_TRACE ("ACE_Framework_Repository::register_component"); 00131 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); 00132 int i; 00133 00134 // Check to see if it's already registered 00135 for (i = 0; i < this->current_size_; i++) 00136 if (this->component_vector_[i] && 00137 fc->this_ == this->component_vector_[i]->this_) 00138 { 00139 ACE_ERROR_RETURN ((LM_ERROR, 00140 ACE_TEXT ("AFR::register_component: error, ") 00141 ACE_TEXT ("compenent already registered\n")), 00142 -1); 00143 } 00144 00145 if (i < this->total_size_) 00146 { 00147 this->component_vector_[i] = fc; 00148 this->current_size_++; 00149 return 0; 00150 } 00151 00152 return -1; 00153 } |
|
Remove a component. Returns -1 on error or if component not found and 0 on success. Definition at line 156 of file Framework_Component.cpp. References ACE_GUARD_RETURN, ACE_TCHAR, ACE_TRACE, compact(), component_vector_, and ACE_OS::strcmp().
00157 { 00158 ACE_TRACE ("ACE_Framework_Repository::remove_component"); 00159 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); 00160 int i; 00161 00162 for (i = 0; i < this->current_size_; i++) 00163 if (this->component_vector_[i] && 00164 ACE_OS::strcmp (this->component_vector_[i]->name_, name) == 0) 00165 { 00166 delete this->component_vector_[i]; 00167 this->component_vector_[i] = 0; 00168 this->compact (); 00169 return 0; 00170 } 00171 00172 return -1; 00173 } |
|
Remove all components associated with a particular dll.
Definition at line 176 of file Framework_Component.cpp. References ACE_GUARD_RETURN, ACE_TCHAR, ACE_TRACE, remove_dll_components_i(), and shutting_down_. Referenced by ACE_DLL_Handle::close().
00177 { 00178 ACE_TRACE ("ACE_Framework_Repository::remove_dll_components"); 00179 00180 if (this->shutting_down_) 00181 return this->remove_dll_components_i (dll_name); 00182 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); 00183 00184 return this->remove_dll_components_i (dll_name); 00185 } |
|
Actually removes the dll components, must be called with locks held.
Definition at line 188 of file Framework_Component.cpp. References ACE_DEBUG, ACE_TCHAR, ACE_TEXT, ACE_TRACE, compact(), component_vector_, ACE::debug(), LM_DEBUG, and ACE_OS::strcmp(). Referenced by remove_dll_components().
00189 { 00190 ACE_TRACE ("ACE_Framework_Repository::remove_dll_components_i"); 00191 00192 int i; 00193 int retval = -1; 00194 00195 for (i = 0; i < this->current_size_; i++) 00196 if (this->component_vector_[i] && 00197 ACE_OS::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0) 00198 { 00199 if (ACE::debug ()) 00200 ACE_DEBUG ((LM_DEBUG, 00201 ACE_TEXT ("AFR::remove_dll_components_i (%s) ") 00202 ACE_TEXT ("component \"%s\"\n"), 00203 dll_name, this->component_vector_[i]->name_)); 00204 delete this->component_vector_[i]; 00205 this->component_vector_[i] = 0; 00206 ++retval; 00207 } 00208 00209 this->compact (); 00210 00211 return retval == -1 ? -1 : 0; 00212 } |
|
Return the total size of the repository.
Definition at line 32 of file Framework_Component.inl. References ACE_GUARD_RETURN, and ACE_TRACE.
00033 { 00034 ACE_TRACE ("ACE_Framework_Repository::total_size"); 00035 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->lock_, -1)); 00036 return this->total_size_; 00037 } |
|
Definition at line 105 of file Framework_Component.h. |
|
Declare the dynamic allocation hooks.
Definition at line 153 of file Framework_Component.h. |
|
Contains all the framework components.
Definition at line 176 of file Framework_Component.h. Referenced by close(), compact(), open(), register_component(), remove_component(), and remove_dll_components_i(). |
|
Current number of components.
Definition at line 179 of file Framework_Component.h. |
|
Pointer to a process-wide ACE_Framework_Repository.
Definition at line 35 of file Framework_Component.cpp. Referenced by close_singleton(), and instance(). |
|
Flag set when repository is the process of shutting down. This is necessary to keep from self-deadlocking since some of the components might make calls back to the repository to unload their components, e.g., ACE_DLL_Manager. Definition at line 32 of file Framework_Component.cpp. Referenced by close(), and remove_dll_components(). |
|
Maximum number of components.
Definition at line 182 of file Framework_Component.h. |