00001 #ifndef PSANA_DYNLOADER_H 00002 #define PSANA_DYNLOADER_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: DynLoader.h 4451 2012-09-12 00:18:42Z salnikov@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class DynLoader. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 #include <string> 00017 #include <boost/shared_ptr.hpp> 00018 00019 //---------------------- 00020 // Base Class Headers -- 00021 //---------------------- 00022 00023 //------------------------------- 00024 // Collaborating Class Headers -- 00025 //------------------------------- 00026 #include "psana/Module.h" 00027 #include "psana/InputModule.h" 00028 00029 //------------------------------------ 00030 // Collaborating Class Declarations -- 00031 //------------------------------------ 00032 00033 // --------------------- 00034 // -- Class Interface -- 00035 // --------------------- 00036 00037 namespace psana { 00038 00039 /** 00040 * @ingroup psana 00041 * 00042 * @brief Class which can load modules from dynamic libraries. 00043 * 00044 * This software was developed for the LCLS project. If you use all or 00045 * part of it, please give an appropriate acknowledgment. 00046 * 00047 * @version \$Id: DynLoader.h 4451 2012-09-12 00:18:42Z salnikov@SLAC.STANFORD.EDU $ 00048 * 00049 * @author Andrei Salnikov 00050 */ 00051 00052 class DynLoader { 00053 public: 00054 00055 /** 00056 * @brief Load one user module. 00057 * 00058 * The name of the module has a format [Language:][Package.]Class[:name]. 00059 * Accepted languages are "c++", "python", "py" (same as "python). 00060 */ 00061 boost::shared_ptr<Module> loadModule(const std::string& name) const; 00062 00063 /** 00064 * @brief Load one input module. 00065 * 00066 * The name of the module has a format [Package.]Class[:name] 00067 */ 00068 boost::shared_ptr<InputModule> loadInputModule(const std::string& name) const; 00069 00070 protected: 00071 00072 /** 00073 * @brief Load the library for a package. 00074 * 00075 * @param[in] packageName Package name. 00076 * @return Library handle. 00077 * 00078 * @throw ExceptionDlerror 00079 */ 00080 void* loadPackageLib(const std::string& packageName) const; 00081 00082 /** 00083 * @brief Load the library and find factory symbol 00084 * 00085 * @param[in] className String in the format Package.Class 00086 * @param[in] factory Prefix for factory function name, like "_psana_module_" 00087 * @return pointer to factory function. 00088 * 00089 * @throw ExceptionModuleName 00090 * @throw ExceptionDlerror 00091 */ 00092 void* loadFactoryFunction(const std::string& className, const std::string& factory) const; 00093 00094 private: 00095 00096 /** 00097 * @brief Load one user module for the given language. The name of the module has a format 00098 * [Package.]Class[:name] 00099 */ 00100 boost::shared_ptr<Module> loadModule(const std::string& name, const std::string& language) const; 00101 00102 }; 00103 00104 } // namespace psana 00105 00106 #endif // PSANA_DYNLOADER_H