Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Framework_Repository Class Reference

Contains all framework components used by an application. More...

#include <Framework_Component.h>

Collaboration diagram for ACE_Framework_Repository:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { DEFAULT_SIZE = ACE_DEFAULT_FRAMEWORK_REPOSITORY_SIZE }

Public Methods

 ~ACE_Framework_Repository (void)
 Close down the repository and free up dynamically allocated resources. More...

int open (int size=DEFAULT_SIZE)
 Initialize the repository. More...

int close (void)
 Close down the repository and free up dynamically allocated resources, also called by dtor. More...

int register_component (ACE_Framework_Component *fc)
 Insert a new component. Returns -1 when the repository is full and 0 on success. More...

int remove_component (const ACE_TCHAR *name)
 Remove a component. Returns -1 on error or if component not found and 0 on success. More...

int remove_dll_components (const ACE_TCHAR *dll_name)
 Remove all components associated with a particular dll. More...

int current_size (void) const
 Return the current size of the repository. More...

int total_size (void) const
 Return the total size of the repository. More...

void dump (void) const
 Dump the state of an object. More...


Static Public Methods

ACE_Framework_Repository * instance (int size=ACE_Framework_Repository::DEFAULT_SIZE)
 Get pointer to a process-wide <ACE_Framework_Repository>. More...

void close_singleton (void)
 Delete the dynamically allocated Singleton. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Methods

 ACE_Framework_Repository (int size=ACE_Framework_Repository::DEFAULT_SIZE)
 Initialize the repository. More...

int remove_dll_components_i (const ACE_TCHAR *dll_name)
 Actually removes the dll components, must be called with locks held. More...

void compact (void)
 Compact component_vector_ after components have been removed__maintains order. More...

 ACE_Framework_Repository (const ACE_Framework_Repository &)
 Don't allow these to be called. More...

ACE_Framework_Repository & operator= (const ACE_Framework_Repository &)

Private Attributes

ACE_Framework_Component ** component_vector_
 Contains all the framework components. More...

int current_size_
 Current number of components. More...

int total_size_
 Maximum number of components. More...


Static Private Attributes

ACE_Framework_Repository * repository_ = 0
 Pointer to a process-wide ACE_Framework_Repository. More...

sig_atomic_t shutting_down_ = 0
 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. More...


Friends

class ACE_Framework_Component

Detailed Description

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 90 of file Framework_Component.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
DEFAULT_SIZE 

Definition at line 96 of file Framework_Component.h.


Constructor & Destructor Documentation

ACE_Framework_Repository::~ACE_Framework_Repository void   
 

Close down the repository and free up dynamically allocated resources.

Definition at line 34 of file Framework_Component.cpp.

References ACE_TRACE, and close.

00035 {
00036   ACE_TRACE ("ACE_Framework_Repository::~ACE_Framework_Repository");
00037   this->close ();
00038 }

ACE_Framework_Repository::ACE_Framework_Repository int    size = ACE_Framework_Repository::DEFAULT_SIZE [private]
 

Initialize the repository.

Definition at line 264 of file Framework_Component.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and open.

00265   : current_size_ (0)
00266 {
00267   ACE_TRACE ("ACE_Framework_Repository::ACE_Framework_Repository");
00268 
00269   if (this->open (size) == -1)
00270     ACE_ERROR ((LM_ERROR,
00271                 ACE_LIB_TEXT ("%p\n"),
00272                 ACE_LIB_TEXT ("ACE_Framework_Repository")));
00273 }

ACE_Framework_Repository::ACE_Framework_Repository const ACE_Framework_Repository &    [private]
 

Don't allow these to be called.


Member Function Documentation

int ACE_Framework_Repository::close void   
 

Close down the repository and free up dynamically allocated resources, also called by dtor.

Definition at line 57 of file Framework_Component.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_TRACE, ACE_DLL_Manager::close_singleton, component_vector_, current_size_, and shutting_down_.

Referenced by ~ACE_Framework_Repository.

00058 {
00059   ACE_TRACE ("ACE_Framework_Repository::close");
00060   ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
00061 
00062   this->shutting_down_ = 1;
00063 
00064   if (this->component_vector_ != 0)
00065     {
00066       // Delete components in reverse order.
00067       for (int i = this->current_size_ - 1; i >= 0; i--)
00068         if (this->component_vector_[i])
00069           {
00070             ACE_Framework_Component *s =
00071               ACE_const_cast (ACE_Framework_Component *,
00072                               this->component_vector_[i]);
00073 
00074             this->component_vector_[i] = 0;
00075             delete s;
00076           }
00077 
00078       delete [] this->component_vector_;
00079       this->component_vector_ = 0;
00080       this->current_size_ = 0;
00081     }
00082 
00083   ACE_DLL_Manager::close_singleton ();
00084   return 0;
00085 }

void ACE_Framework_Repository::close_singleton void    [static]
 

Delete the dynamically allocated Singleton.

Definition at line 113 of file Framework_Component.cpp.

References ACE_GUARD, ACE_MT, ACE_TRACE, ACE_Static_Object_Lock::instance, and repository_.

Referenced by ACE_Object_Manager::fini.

00114 {
00115   ACE_TRACE ("ACE_Framework_Repository::close_singleton");
00116 
00117   ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00118                      *ACE_Static_Object_Lock::instance ()));
00119 
00120   delete ACE_Framework_Repository::repository_;
00121   ACE_Framework_Repository::repository_ = 0;
00122 }

void ACE_Framework_Repository::compact void    [private]
 

Compact component_vector_ after components have been removed__maintains order.

Definition at line 212 of file Framework_Component.cpp.

References ACE_TRACE, component_vector_, and current_size_.

Referenced by remove_component, and remove_dll_components_i.

00213 {
00214   ACE_TRACE ("ACE_Framework_Repository::compact");
00215 
00216   int i;
00217   int start_hole;
00218   int end_hole;
00219 
00220   do
00221     {
00222       start_hole = this->current_size_;
00223       end_hole = this->current_size_;
00224 
00225       // Find hole
00226       for (i = 0; i < this->current_size_; ++i)
00227         {
00228           if (this->component_vector_[i] == 0)
00229             {
00230               if (start_hole == this->current_size_)
00231                 {
00232                   start_hole = i;
00233                   end_hole = i;
00234                 }
00235               else
00236                 end_hole = i;
00237             }
00238           else if (end_hole != this->current_size_)
00239             break;
00240         }
00241 
00242       if (start_hole != this->current_size_)
00243         {
00244           // move the contents and reset current_size_
00245           while (end_hole + 1 < this->current_size_)
00246             {
00247               this->component_vector_[start_hole++] =
00248                 this->component_vector_[++end_hole];
00249             }
00250           // Since start_hole is now one past the last
00251           // active slot.
00252           this->current_size_ = start_hole;
00253         }
00254 
00255     } while (start_hole != this->current_size_);
00256 }

ACE_INLINE int ACE_Framework_Repository::current_size void    const
 

Return the current size of the repository.

Definition at line 22 of file Framework_Component.inl.

References ACE_GUARD_RETURN, ACE_MT, ACE_TRACE, and current_size_.

00023 {
00024   ACE_TRACE ("ACE_Framework_Repository::current_size");
00025   ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->lock_, -1));
00026   return this->current_size_;
00027 }

void ACE_Framework_Repository::dump void    const
 

Dump the state of an object.

Definition at line 259 of file Framework_Component.cpp.

References ACE_TRACE.

00260 {
00261   ACE_TRACE ("ACE_Framework_Repository::dump");
00262 }

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 88 of file Framework_Component.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_NEW_RETURN, ACE_TRACE, ACE_Static_Object_Lock::instance, repository_, ACE_Object_Manager::shutting_down, and ACE_Object_Manager::starting_up.

Referenced by ACE_DLL_Handle::close, and ACE_DLL_Singleton_T::instance.

00089 {
00090   ACE_TRACE ("ACE_Framework_Repository::instance");
00091 
00092   if (ACE_Framework_Repository::repository_ == 0)
00093     {
00094       // Perform Double-Checked Locking Optimization.
00095       ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00096                                 *ACE_Static_Object_Lock::instance (), 0));
00097       if (ACE_Framework_Repository::repository_ == 0)
00098         {
00099           if (ACE_Object_Manager::starting_up () ||
00100               !ACE_Object_Manager::shutting_down ())
00101             {
00102               ACE_NEW_RETURN (ACE_Framework_Repository::repository_,
00103                               ACE_Framework_Repository (size),
00104                               0);
00105             }
00106         }
00107     }
00108 
00109   return ACE_Framework_Repository::repository_;
00110 }

int ACE_Framework_Repository::open int    size = DEFAULT_SIZE
 

Initialize the repository.

Definition at line 41 of file Framework_Component.cpp.

References ACE_NEW_RETURN, ACE_TRACE, component_vector_, and total_size_.

Referenced by ACE_Framework_Repository.

00042 {
00043   ACE_TRACE ("ACE_Framework_Repository::open");
00044 
00045   ACE_Framework_Component **temp;
00046 
00047   ACE_NEW_RETURN (temp,
00048                   ACE_Framework_Component *[size],
00049                   -1);
00050 
00051   this->component_vector_ = temp;
00052   this->total_size_ = size;
00053   return 0;
00054 }

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 125 of file Framework_Component.cpp.

References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_TRACE, component_vector_, current_size_, LM_ERROR, ACE_Framework_Component::this_, and total_size_.

Referenced by ACE_DLL_Singleton_T::instance.

00126 {
00127   ACE_TRACE ("ACE_Framework_Repository::register_component");
00128   ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
00129   int i;
00130 
00131   // Check to see if it's already registered
00132   for (i = 0; i < this->current_size_; i++)
00133     if (this->component_vector_[i] &&
00134         fc->this_ == this->component_vector_[i]->this_)
00135       {
00136         ACE_ERROR_RETURN ((LM_ERROR,
00137                            ACE_LIB_TEXT ("AFR::register_component: error, ")
00138                            ACE_LIB_TEXT ("compenent already registered\n")),
00139                           -1);
00140       }
00141 
00142   if (i < this->total_size_)
00143     {
00144       this->component_vector_[i] = fc;
00145       this->current_size_++;
00146       return 0;
00147     }
00148 
00149   return -1;
00150 }

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 153 of file Framework_Component.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_TCHAR, ACE_TRACE, compact, component_vector_, current_size_, and ACE_OS_String::strcmp.

00154 {
00155   ACE_TRACE ("ACE_Framework_Repository::remove_component");
00156   ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
00157   int i;
00158 
00159   for (i = 0; i < this->current_size_; i++)
00160     if (this->component_vector_[i] &&
00161         ACE_OS_String::strcmp (this->component_vector_[i]->name_, name) == 0)
00162       {
00163         delete this->component_vector_[i];
00164         this->component_vector_[i] = 0;
00165         this->compact ();
00166         return 0;
00167       }
00168 
00169   return -1;
00170 }

int ACE_Framework_Repository::remove_dll_components const ACE_TCHAR   dll_name
 

Remove all components associated with a particular dll.

Definition at line 173 of file Framework_Component.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_TCHAR, ACE_TRACE, remove_dll_components_i, and shutting_down_.

Referenced by ACE_DLL_Handle::close.

00174 {
00175   ACE_TRACE ("ACE_Framework_Repository::remove_dll_components");
00176 
00177   if (this->shutting_down_)
00178     return this->remove_dll_components_i (dll_name);
00179   ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
00180 
00181   return this->remove_dll_components_i (dll_name);
00182 }

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 185 of file Framework_Component.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, compact, component_vector_, current_size_, ACE::debug, LM_DEBUG, and ACE_OS_String::strcmp.

Referenced by remove_dll_components.

00186 {
00187   ACE_TRACE ("ACE_Framework_Repository::remove_dll_components_i");
00188 
00189   int i;
00190   int retval = -1;
00191 
00192   for (i = 0; i < this->current_size_; i++)
00193     if (this->component_vector_[i] &&
00194         ACE_OS_String::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0)
00195       {
00196           if (ACE::debug ())
00197             ACE_DEBUG ((LM_DEBUG,
00198                         ACE_LIB_TEXT ("AFR::remove_dll_components_i (%s) ")
00199                         ACE_LIB_TEXT ("component \"%s\"\n"),
00200                         dll_name, this->component_vector_[i]->name_));
00201         delete this->component_vector_[i];
00202         this->component_vector_[i] = 0;
00203         ++retval;
00204       }
00205 
00206   this->compact ();
00207 
00208   return retval == -1 ? -1 : 0;
00209 }

ACE_INLINE int ACE_Framework_Repository::total_size void    const
 

Return the total size of the repository.

Definition at line 30 of file Framework_Component.inl.

References ACE_GUARD_RETURN, ACE_MT, ACE_TRACE, and total_size_.

00031 {
00032   ACE_TRACE ("ACE_Framework_Repository::total_size");
00033   ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->lock_, -1));
00034   return this->total_size_;
00035 }


Friends And Related Function Documentation

friend class ACE_Framework_Component [friend]
 

Definition at line 94 of file Framework_Component.h.


Member Data Documentation

ACE_Framework_Repository::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 142 of file Framework_Component.h.

ACE_Framework_Component** ACE_Framework_Repository::component_vector_ [private]
 

Contains all the framework components.

Definition at line 158 of file Framework_Component.h.

Referenced by close, compact, open, register_component, remove_component, and remove_dll_components_i.

int ACE_Framework_Repository::current_size_ [private]
 

Current number of components.

Definition at line 161 of file Framework_Component.h.

Referenced by close, compact, current_size, register_component, remove_component, and remove_dll_components_i.

ACE_Framework_Repository * ACE_Framework_Repository::repository_ = 0 [static, private]
 

Pointer to a process-wide ACE_Framework_Repository.

Definition at line 32 of file Framework_Component.cpp.

Referenced by close_singleton, and instance.

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 29 of file Framework_Component.cpp.

Referenced by close, and remove_dll_components.

int ACE_Framework_Repository::total_size_ [private]
 

Maximum number of components.

Definition at line 164 of file Framework_Component.h.

Referenced by open, register_component, and total_size.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:48:06 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002