Contains all framework components used by an application. More...
#include <Framework_Component.h>

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 | |
| static ACE_Framework_Repository * | instance (int size=ACE_Framework_Repository::DEFAULT_SIZE) |
| Get pointer to a process-wide ACE_Framework_Repository. | |
| static 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. | |
| ACE_Thread_Mutex | lock_ |
| Synchronization variable for the MT_SAFE Repository. | |
Static Private Attributes | |
| static ACE_Framework_Repository * | repository_ = 0 |
| Pointer to a process-wide ACE_Framework_Repository. | |
| static sig_atomic_t | shutting_down_ = 0 |
Friends | |
| class | ACE_Framework_Component |
Contains all framework components used by an application.
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.
| anonymous enum |
Definition at line 107 of file Framework_Component.h.
00108 { 00109 DEFAULT_SIZE = ACE_DEFAULT_FRAMEWORK_REPOSITORY_SIZE 00110 };
| ACE_Framework_Repository::~ACE_Framework_Repository | ( | void | ) |
Close down the repository and free up dynamically allocated resources.
Definition at line 37 of file Framework_Component.cpp.
| ACE_Framework_Repository::ACE_Framework_Repository | ( | int | size = ACE_Framework_Repository::DEFAULT_SIZE |
) | [protected] |
Initialize the repository.
Definition at line 268 of file Framework_Component.cpp.
| ACE_Framework_Repository::ACE_Framework_Repository | ( | const ACE_Framework_Repository & | ) | [private] |
Disallow copying and assignment.
| int ACE_Framework_Repository::close | ( | void | ) |
Close down the repository and free up dynamically allocated resources, also called by dtor.
Definition at line 60 of file Framework_Component.cpp.
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 }
| void ACE_Framework_Repository::close_singleton | ( | void | ) | [static] |
Delete the dynamically allocated Singleton.
Definition at line 116 of file Framework_Component.cpp.
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 }
| void ACE_Framework_Repository::compact | ( | void | ) | [private] |
Compact component_vector_ after components have been removed__maintains order.
Definition at line 214 of file Framework_Component.cpp.
00215 { 00216 ACE_TRACE ("ACE_Framework_Repository::compact"); 00217 00218 int i; 00219 int start_hole; 00220 int end_hole; 00221 00222 do 00223 { 00224 start_hole = this->current_size_; 00225 end_hole = this->current_size_; 00226 00227 // Find hole 00228 for (i = 0; i < this->current_size_; ++i) 00229 { 00230 if (this->component_vector_[i] == 0) 00231 { 00232 if (start_hole == this->current_size_) 00233 { 00234 start_hole = i; 00235 end_hole = i; 00236 } 00237 else 00238 end_hole = i; 00239 } 00240 else if (end_hole != this->current_size_) 00241 break; 00242 } 00243 00244 if (start_hole != this->current_size_) 00245 { 00246 // move the contents and reset current_size_ 00247 while (end_hole + 1 < this->current_size_) 00248 { 00249 this->component_vector_[start_hole++] = 00250 this->component_vector_[++end_hole]; 00251 } 00252 // Since start_hole is now one past the last 00253 // active slot. 00254 this->current_size_ = start_hole; 00255 } 00256 00257 } while (start_hole != this->current_size_); 00258 }
| int ACE_Framework_Repository::current_size | ( | void | ) | const |
Return the current size of the repository.
Definition at line 24 of file Framework_Component.inl.
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 }
| void ACE_Framework_Repository::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 261 of file Framework_Component.cpp.
00262 { 00263 #if defined (ACE_HAS_DUMP) 00264 ACE_TRACE ("ACE_Framework_Repository::dump"); 00265 #endif /* ACE_HAS_DUMP */ 00266 }
| ACE_Framework_Repository * ACE_Framework_Repository::instance | ( | int | size = ACE_Framework_Repository::DEFAULT_SIZE |
) | [static] |
Get pointer to a process-wide ACE_Framework_Repository.
Definition at line 91 of file Framework_Component.cpp.
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 }
| int ACE_Framework_Repository::open | ( | int | size = DEFAULT_SIZE |
) |
Initialize the repository.
Definition at line 44 of file Framework_Component.cpp.
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 }
| ACE_Framework_Repository& ACE_Framework_Repository::operator= | ( | const ACE_Framework_Repository & | ) | [private] |
| int ACE_Framework_Repository::register_component | ( | ACE_Framework_Component * | fc | ) |
Insert a new component. Returns -1 when the repository is full and 0 on success.
Definition at line 128 of file Framework_Component.cpp.
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 "AFR::register_component: error, compenent already registered\n"), 00141 -1); 00142 } 00143 00144 if (i < this->total_size_) 00145 { 00146 this->component_vector_[i] = fc; 00147 ++this->current_size_; 00148 return 0; 00149 } 00150 00151 return -1; 00152 }
| int ACE_Framework_Repository::remove_component | ( | const ACE_TCHAR * | name | ) |
Remove a component. Returns -1 on error or if component not found and 0 on success.
Definition at line 155 of file Framework_Component.cpp.
00156 { 00157 ACE_TRACE ("ACE_Framework_Repository::remove_component"); 00158 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); 00159 int i; 00160 00161 for (i = 0; i < this->current_size_; i++) 00162 if (this->component_vector_[i] && 00163 ACE_OS::strcmp (this->component_vector_[i]->name_, name) == 0) 00164 { 00165 delete this->component_vector_[i]; 00166 this->component_vector_[i] = 0; 00167 this->compact (); 00168 return 0; 00169 } 00170 00171 return -1; 00172 }
| int ACE_Framework_Repository::remove_dll_components | ( | const ACE_TCHAR * | dll_name | ) |
Remove all components associated with a particular dll.
Definition at line 175 of file Framework_Component.cpp.
00176 { 00177 ACE_TRACE ("ACE_Framework_Repository::remove_dll_components"); 00178 00179 if (this->shutting_down_) 00180 return this->remove_dll_components_i (dll_name); 00181 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); 00182 00183 return this->remove_dll_components_i (dll_name); 00184 }
| int ACE_Framework_Repository::remove_dll_components_i | ( | const ACE_TCHAR * | dll_name | ) | [private] |
Actually removes the dll components, must be called with locks held.
Definition at line 187 of file Framework_Component.cpp.
00188 { 00189 ACE_TRACE ("ACE_Framework_Repository::remove_dll_components_i"); 00190 00191 int i; 00192 int retval = -1; 00193 00194 for (i = 0; i < this->current_size_; i++) 00195 if (this->component_vector_[i] && 00196 ACE_OS::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0) 00197 { 00198 if (ACE::debug ()) 00199 ACE_DEBUG ((LM_DEBUG, 00200 ACE_TEXT ("AFR::remove_dll_components_i (%s) ") 00201 ACE_TEXT ("component \"%s\"\n"), 00202 dll_name, this->component_vector_[i]->name_)); 00203 delete this->component_vector_[i]; 00204 this->component_vector_[i] = 0; 00205 ++retval; 00206 } 00207 00208 this->compact (); 00209 00210 return retval == -1 ? -1 : 0; 00211 }
| int ACE_Framework_Repository::total_size | ( | void | ) | const |
Return the total size of the repository.
Definition at line 32 of file Framework_Component.inl.
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 }
friend class ACE_Framework_Component [friend] |
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.
int ACE_Framework_Repository::current_size_ [private] |
Current number of components.
Definition at line 179 of file Framework_Component.h.
Synchronization variable for the MT_SAFE Repository.
Definition at line 195 of file Framework_Component.h.
ACE_Framework_Repository * ACE_Framework_Repository::repository_ = 0 [static, private] |
Pointer to a process-wide ACE_Framework_Repository.
Definition at line 185 of file Framework_Component.h.
sig_atomic_t ACE_Framework_Repository::shutting_down_ = 0 [static, private] |
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 191 of file Framework_Component.h.
int ACE_Framework_Repository::total_size_ [private] |
Maximum number of components.
Definition at line 182 of file Framework_Component.h.
1.6.1