dynamic-ld.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1993-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_dynamic_ld_h)
00024 #define octave_dynamic_ld_h 1
00025 
00026 #include <string>
00027 
00028 #include "oct-shlib.h"
00029 
00030 class octave_function;
00031 
00032 class
00033 octave_dynamic_loader
00034 {
00035 protected:
00036 
00037   octave_dynamic_loader (void) { }
00038 
00039 public:
00040 
00041   virtual ~octave_dynamic_loader (void) { }
00042 
00043   static octave_function *
00044   load_oct (const std::string& fcn_name,
00045              const std::string& file_name = std::string (),
00046              bool relative = false);
00047 
00048   static octave_function *
00049   load_mex (const std::string& fcn_name,
00050              const std::string& file_name = std::string (),
00051              bool relative = false);
00052 
00053   static bool remove_oct (const std::string& fcn_name, octave_shlib& shl);
00054 
00055   static bool remove_mex (const std::string& fcn_name, octave_shlib& shl);
00056 
00057 private:
00058 
00059   // No copying!
00060 
00061   octave_dynamic_loader (const octave_dynamic_loader&);
00062 
00063   octave_dynamic_loader& operator = (const octave_dynamic_loader&);
00064 
00065   static octave_dynamic_loader *instance;
00066 
00067   static void cleanup_instance (void) { delete instance; instance = 0; }
00068 
00069   static bool instance_ok (void);
00070 
00071   octave_function *
00072   do_load_oct (const std::string& fcn_name,
00073                 const std::string& file_name = std::string (),
00074                 bool relative = false);
00075 
00076   octave_function *
00077   do_load_mex (const std::string& fcn_name,
00078                 const std::string& file_name = std::string (),
00079                 bool relative = false);
00080 
00081   bool do_remove_oct (const std::string& fcn_name, octave_shlib& shl);
00082 
00083   bool do_remove_mex (const std::string& fcn_name, octave_shlib& shl);
00084 
00085   static bool doing_load;
00086 
00087 protected:
00088 
00089   static std::string name_mangler (const std::string& name);
00090 
00091   static std::string name_uscore_mangler (const std::string& name);
00092 
00093   static std::string mex_mangler (const std::string& name);
00094 
00095   static std::string mex_uscore_mangler (const std::string& name);
00096 
00097   static std::string mex_f77_mangler (const std::string& name);
00098 };
00099 
00100 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines