00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #include <sys/types.h>
00021 #include <signal.h>
00022
00023 #include <assert_pp.h>
00024
00025 #include "AllupImpl.hh"
00026
00027 #include "FactoryLibrary_ltdl.hh"
00028
00029 AllupImpl::AllupImpl(PortableServer::POA_ptr my_poa) :
00030 ai_POA(PortableServer::POA::_duplicate(my_poa))
00031 {
00032 }
00033
00034 AllupImpl::~AllupImpl(void)
00035 {
00036 }
00037
00038 edu::utah::pces::FactoryLibrary_ptr AllupImpl::OpenLibrary(const char *name)
00039 throw (edu::utah::pces::NoSuchLibrary,
00040 CORBA::SystemException)
00041 {
00042 edu::utah::pces::FactoryLibrary_var retval;
00043
00044
00045 if( name == NULL )
00046 {
00047 throw CORBA::BAD_PARAM();
00048 }
00049
00050
00051 retval = FactoryLibrary_ltdl::OpenLibrary(this->ai_POA.in(), name);
00052
00053
00054 if( this->ai_Libraries.count(name) == 0 )
00055 {
00056 this->ai_Libraries[name] = edu::utah::pces::FactoryLibrary::
00057 _duplicate(retval.in());
00058 }
00059
00060 return( retval._retn() );
00061 }
00062
00063 edu::utah::pces::FactoryLibraryList *AllupImpl::Libraries(void)
00064 throw (CORBA::SystemException)
00065 {
00066 edu::utah::pces::FactoryLibraryList *retval;
00067 library_map_t::const_iterator pos;
00068 size_t list_size;
00069 int lpc;
00070
00071 list_size = this->ai_Libraries.size();
00072
00073 retval = new edu::utah::pces::FactoryLibraryList(list_size);
00074 retval->length(list_size);
00075
00076 for( pos = this->ai_Libraries.begin(), lpc = 0;
00077 pos != this->ai_Libraries.end();
00078 pos++, lpc++ )
00079 {
00080 (*retval)[lpc] = edu::utah::pces::FactoryLibrary::
00081 _duplicate(pos->second.in());
00082 }
00083 return( retval );
00084 }
00085
00086 void AllupImpl::Shutdown(void)
00087 throw (CORBA::SystemException)
00088 {
00089 library_map_t::iterator pos;
00090 char *argv[] = { NULL };
00091 CORBA::ORB_var orb;
00092 int argc = 0;
00093
00094 orb = CORBA::ORB_init(argc, argv);
00095
00096 for( pos = this->ai_Libraries.begin();
00097 pos != this->ai_Libraries.end();
00098 pos++ )
00099 {
00100 PortableServer::ObjectId_var oid;
00101 PortableServer::ServantBase *sb;
00102
00103 oid = this->ai_POA->reference_to_id(pos->second.in());
00104 sb = this->ai_POA->id_to_servant(oid.in());
00105 this->ai_POA->deactivate_object(oid.in());
00106
00107 delete sb;
00108 sb = NULL;
00109 }
00110 FactoryLibrary_ltdl::Shutdown();
00111
00112 orb->shutdown(0);
00113 }