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

FactoryLibrary_ltdl.hh

Go to the documentation of this file.
00001 /*
00002  * FactoryLibrary_ltdl.hh
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 FactoryLibrary_ltdl.hh
00014  *
00015  * Header file for the FactoryLibrary_ltdl class.
00016  */
00017 
00018 #ifndef _factory_library_impl_hh
00019 #define _factory_library_impl_hh
00020 
00021 #include <map>
00022 #include <string.h>
00023 
00024 #include "AllupS.h"
00025 
00026 #include "HeyParser.hh"
00027 
00028 #include "factory_library.h"
00029 #include "ltdl.h"
00030 
00031 using namespace std;
00032 
00033 /**
00034  * An edu::utah::pces::FactoryLibrary implementation that uses libltdl.
00035  *
00036  * @sa AllupImpl
00037  * @sa libtool
00038  */
00039 class FactoryLibrary_ltdl : public virtual POA_edu::utah::pces::FactoryLibrary
00040 {
00041 
00042 public:
00043 
00044     /**
00045      * Open a library with the given name.
00046      *
00047      * @param poa The POA to use when activating any new objects.
00048      * @param name The name of the library.
00049      * @return A CORBA object reference to the new FactoryLibrary_ltdl object.
00050      *
00051      * @exception edu::utah::pces::NoSuchLibrary if the library could not be
00052      * found or loaded.
00053      */
00054     static edu::utah::pces::FactoryLibrary_ptr OpenLibrary(
00055         PortableServer::POA_ptr poa,
00056         const char *name)
00057         throw (edu::utah::pces::NoSuchLibrary,
00058                CORBA::SystemException);
00059 
00060     /**
00061      * Shutdown the library interface.
00062      */
00063     static void Shutdown(void);
00064 
00065     /**
00066      * Deconstruct a FactoryLibrary_ltdl object.
00067      */
00068     virtual ~FactoryLibrary_ltdl(void);
00069 
00070     /** @copydoc edu::utah::pces::FactoryLibrary::Name */
00071     virtual char *Name(void)
00072         throw (CORBA::SystemException);
00073 
00074     /** @copydoc edu::utah::pces::FactoryLibrary::Hey */
00075     virtual CORBA::Long Hey(const edu::utah::pces::ArgV &args,
00076                             CORBA::String_out o,
00077                             CORBA::String_out e)
00078         throw (CORBA::SystemException);
00079 
00080     /**
00081      * @exception CORBA::BAD_INV_ORDER when called.  This object should always
00082      * be activated under a single threaded POA.
00083      */
00084     virtual PortableServer::POA_ptr _default_POA(void)
00085         throw (CORBA::SystemException)
00086     {
00087         throw CORBA::BAD_INV_ORDER();
00088     };
00089 
00090 protected:
00091     
00092     /**
00093      * Construct a FactoryLibrary_ltdl object with the given arguments.
00094      *
00095      * @param poa The POA this object was activated under and any new objects
00096      * should be activated under.
00097      * @param name The name of this shared library.
00098      * @param dlh The libtool handle on the shared library.
00099      * @param fm The library's factory_method_t.
00100      */
00101     FactoryLibrary_ltdl(PortableServer::POA_ptr poa,
00102                         const char *name,
00103                         lt_dlhandle dlh,
00104                         factory_method_t fm);
00105     
00106 private:
00107 
00108     /**
00109      * Map of library names to FactoryLibrary_ltdl objects.
00110      */
00111     static map<string, FactoryLibrary_ltdl *> open_libraries;
00112 
00113     /**
00114      * Cached reference to the ORB object.
00115      */
00116     static CORBA::ORB_var orb;
00117 
00118     /**
00119      * Construct a FactoryLibrary_ltdl object with the given values.
00120      *
00121      * @param name The name of the library.
00122      * @param library The libtool handle on the library.
00123      * @param fm The reference to the library's factory_method_t function.
00124      */
00125     FactoryLibrary_ltdl(const char *name,
00126                         lt_dlhandle library,
00127                         factory_method_t fm);
00128 
00129     /**
00130      * The POA this object was activated under and any new objects should be
00131      * activated under.
00132      */
00133     PortableServer::POA_var fl_POA;
00134     
00135     /**
00136      * The name of the library being managed by this object.
00137      */
00138     CORBA::String_var fl_Name;
00139 
00140     /**
00141      * The number of times this library has been opened.
00142      */
00143     unsigned int fl_OpenCount;
00144 
00145     /**
00146      * Libtool handle on the shared library.
00147      */
00148     lt_dlhandle fl_Library;
00149 
00150     /**
00151      * Cached reference to the factory_method_t in the shared library.
00152      */
00153     factory_method_t fl_Method;
00154     
00155 };
00156 
00157 #endif

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