Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AllupImpl.cc

Go to the documentation of this file.
00001 /*
00002  * AllupImpl.cc
00003  *
00004  * Copyright (c) 2003, 2004 The University of Utah and the Flux Group.
00005  * All rights reserved.
00006  *
00007  * This file is licensed under the terms of the GNU Public License.  
00008  * See the file "license.terms" for restrictions on redistribution 
00009  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  */
00011 
00012 /**
00013  * @file AllupImpl.cc
00014  *
00015  * Implementation file for the AllupImpl class.
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     /* Check the input and */
00045     if( name == NULL )
00046     {
00047         throw CORBA::BAD_PARAM();
00048     }
00049 
00050     /* Try opening the library and */
00051     retval = FactoryLibrary_ltdl::OpenLibrary(this->ai_POA.in(), name);
00052 
00053     /* ... then add it to the map, if it is not already there. */
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     /* Create a sequence large enough to hold all the opened libraries and */
00073     retval = new edu::utah::pces::FactoryLibraryList(list_size);
00074     retval->length(list_size);
00075     /* ... fill it in. */
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     /* Try to clean up the libraries and */
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     /* ... shutdown the ORB to break the run() loop. */
00112     orb->shutdown(0);
00113 }

Generated on Fri Oct 22 07:50:24 2004 for CPU Broker by  doxygen 1.3.9.1