00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file ValueFactory_Map.h 00006 * 00007 * $Id: ValueFactory_Map.h 72137 2006-04-19 09:17:17Z jwillemsen $ 00008 * 00009 * @author Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef TAO_VALUEFACTORY_MAP_H 00015 #define TAO_VALUEFACTORY_MAP_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "tao/orbconf.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "ace/Hash_Map_Manager_T.h" 00026 #include "ace/Thread_Mutex.h" 00027 #include "ace/Null_Mutex.h" 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 namespace CORBA 00032 { 00033 class ValueFactoryBase; 00034 typedef ValueFactoryBase *ValueFactory; 00035 } 00036 00037 class TAO_ValueFactory_Map 00038 { 00039 public: 00040 00041 TAO_ValueFactory_Map (void); 00042 ~TAO_ValueFactory_Map (void); 00043 00044 /** 00045 * Associate the factory (int_id) with the repo_id (ext_id). 00046 * Invokes _add_ref () on the factory. 00047 * If previous factory had been bind with this repo_id, this one is 00048 * returned in factory (and the caller holds a reference). 00049 * Returns -1 on failure, 0 on success and 1 if a previous factory 00050 * is found (and returned in factory). 00051 */ 00052 int rebind (const char *repo_id, 00053 CORBA::ValueFactory &factory); 00054 00055 /// Removes entry for repo_id from the map and sets factory to 00056 /// the tied one. 00057 int unbind (const char *repo_id, 00058 CORBA::ValueFactory &factory); 00059 00060 /** 00061 * Lookup a matching factory for repo_id. 00062 * Invokes _add_ref () on the factory if found. 00063 * Returns -1 on failure and 0 on success. 00064 */ 00065 int find (const char *repo_id, 00066 CORBA::ValueFactory &factory); 00067 00068 void dump (void); 00069 00070 /// Return singleton instance of this class. 00071 static TAO_ValueFactory_Map * instance (void); 00072 00073 private: 00074 00075 /// The hash table data structure. 00076 typedef ACE_Hash_Map_Manager_Ex<const char *, 00077 CORBA::ValueFactory, 00078 ACE_Hash<const char *>, 00079 ACE_Equal_To<const char *>, 00080 ACE_SYNCH_NULL_MUTEX> 00081 FACTORY_MAP_MANAGER; 00082 FACTORY_MAP_MANAGER map_; 00083 00084 /// synchronization of the map 00085 TAO_SYNCH_MUTEX mutex_; 00086 }; /* TAO_ValueFactory_Map */ 00087 00088 TAO_END_VERSIONED_NAMESPACE_DECL 00089 00090 #include /**/ "ace/post.h" 00091 00092 #endif /* TAO_VALUEFACTORY_MAP_H */