26 #if ! defined (octave_load_path_h)
27 #define octave_load_path_h 1
29 #include "octave-config.h"
52 typedef void (*hook_fcn_ptr) (
const std::string& dir);
60 void initialize (
bool set_initial_path =
false);
64 void set (
const std::string& p,
bool warn =
false,
bool is_init =
false);
66 void append (
const std::string& dir,
bool warn =
false);
68 void prepend (
const std::string& dir,
bool warn =
false);
70 bool remove (
const std::string& dir);
72 void update (
void)
const;
74 bool contains_canonical (
const std::string& dir_name)
const;
76 bool contains_file_in_dir (
const std::string& file_name,
77 const std::string& dir_name);
80 const std::string& meth,
81 std::string& dir_name,
82 const std::string& pack_name =
"")
84 return get_package (pack_name).find_method (class_name, meth, dir_name);
88 const std::string& meth,
89 const std::string& pack_name =
"")
92 return find_method (class_name, meth, dir_name, pack_name);
95 std::list<std::string>
methods (
const std::string& class_name,
96 const std::string& pack_name =
"")
98 return get_package (pack_name).methods (class_name);
101 std::list<std::string> overloads (
const std::string& meth)
const;
105 return (package_map.find (package_name) != package_map.end ());
108 std::list<std::string>
109 get_all_package_names (
bool only_top_level =
true)
const;
111 std::string
find_fcn (
const std::string& fcn, std::string& dir_name,
112 const std::string& pack_name =
"")
114 return get_package (pack_name).find_fcn (fcn, dir_name);
118 const std::string& pack_name =
"")
120 std::string dir_name;
121 return find_fcn (fcn, dir_name, pack_name);
125 const std::string& fcn,
126 const std::string& pack_name =
"")
128 return get_package (pack_name).find_private_fcn (dir, fcn);
132 const std::string& pack_name =
"")
134 std::string dir_name;
135 return get_package (pack_name).find_fcn (fcn, dir_name, M_FILE);
139 const std::string& pack_name =
"")
141 std::string dir_name;
142 return get_package (pack_name).find_fcn (fcn, dir_name, M_FILE);
146 const std::string& pack_name =
"")
148 std::string dir_name;
149 return get_package (pack_name).find_fcn (fcn, dir_name, M_FILE);
152 std::string find_file (
const std::string& file)
const;
154 std::string find_dir (
const std::string& dir)
const;
156 string_vector find_matching_dirs (
const std::string& dir)
const;
164 std::list<std::string> dir_list (
void)
const;
166 string_vector files (
const std::string& dir,
bool omit_exts =
false)
const;
170 std::string
path (
void)
const;
172 void display (std::ostream& os)
const;
194 void execute_pkg_add (
const std::string& dir);
195 void execute_pkg_del (
const std::string& dir);
199 if (m_command_line_path.empty ())
200 m_command_line_path = p;
207 return m_command_line_path;
212 static const int M_FILE = 1;
213 static const int OCT_FILE = 2;
214 static const int MEX_FILE = 4;
230 class_info (
void) : method_file_map (), private_file_map () { }
233 : method_file_map (ci.method_file_map),
234 private_file_map (ci.private_file_map)
271 : dir_name (
d), abs_dir_name (), is_relative (false),
272 dir_mtime (), dir_time_last_checked (), all_files (), fcn_files (),
273 private_file_map (), method_file_map (), package_dir_map ()
297 bool is_package (
const std::string&
name)
const;
303 void get_file_list (
const std::string&
d);
305 void get_private_file_map (
const std::string&
d);
307 void get_method_file_map (
const std::string&
d,
308 const std::string& class_name);
310 void get_package_dir (
const std::string&
d,
311 const std::string& package_name);
320 file_info (
const std::string&
d,
int t) : dir_name (
d), types (t) { }
323 : dir_name (
fi.dir_name), types (
fi.types) { }
331 dir_name =
fi.dir_name;
377 typedef std::map<std::string, dir_info::fcn_file_map_type>
394 : m_package_name (package_name), dir_list (), fcn_map (),
400 : m_package_name (l.m_package_name), dir_list (l.dir_list),
401 private_fcn_map (l.private_fcn_map), method_map (l.method_map)
427 add_to_fcn_map (di, at_end, updating);
429 add_to_private_fcn_map (di);
431 add_to_method_map (di, at_end);
434 void move (
const dir_info& di,
bool at_end);
444 private_fcn_map.clear ();
449 void display (std::ostream& out)
const;
452 find_fcn (
const std::string& fcn, std::string& dir_name,
453 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
456 find_private_fcn (
const std::string& dir,
const std::string& fcn,
457 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
460 find_method (
const std::string& class_name,
const std::string& meth,
461 std::string& dir_name,
462 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
464 std::list<std::string> methods (
const std::string& class_name)
const;
466 void overloads (
const std::string& meth, std::list<std::string>& l)
const;
472 void add_to_fcn_map (
const dir_info& di,
bool at_end,
bool updating);
474 void add_to_private_fcn_map (
const dir_info& di);
476 void add_to_method_map (
const dir_info& di,
bool at_end);
478 void move_fcn_map (
const std::string& dir,
481 void move_method_map (
const std::string& dir,
bool at_end);
483 void remove_fcn_map (
const std::string& dir,
486 void remove_private_fcn_map (
const std::string& dir);
488 void remove_method_map (
const std::string& dir);
490 bool check_file_type (std::string& fname,
int type,
int possible_types,
491 const std::string& fcn,
const char *who)
const;
493 void print_types (std::ostream& os,
int types)
const;
495 void print_fcn_list (std::ostream& os,
535 void execute_pkg_add_or_del (
const std::string& dir,
536 const std::string& script_file);
541 bool contains (
const std::string& dir)
const;
545 void move (
const dir_info& di,
bool at_end,
const std::string& pname =
"");
547 void remove (
const dir_info& di,
const std::string& pname =
"");
549 void add (
const std::string& dir,
bool at_end,
bool warn);
551 void add (
const dir_info& di,
bool at_end,
const std::string& pname =
"",
552 bool updating =
false)
const;
554 bool is_package (
const std::string&
name)
const;
558 if (!
name.empty () && is_package (
name))
562 if (l == package_map.end ())
563 l = package_map.insert (package_map.end (),
569 return top_level_package;
572 string_vector get_file_list (
const dir_info::fcn_file_map_type& lst)
const;
574 friend dir_info::fcn_file_map_type
get_fcn_files (
const std::string&
d);
static std::string path_sep_str(void)
file_info & operator=(const file_info &)=default
method_file_map_type::const_iterator const_method_file_map_iterator
package_dir_map_type package_dir_map
package_dir_map_type::iterator package_dir_map_iterator
method_file_map_type::iterator method_file_map_iterator
sys::time dir_time_last_checked
fcn_file_map_type private_file_map
dir_info(const std::string &d)
fcn_file_map_type::const_iterator const_fcn_file_map_iterator
std::map< std::string, class_info > method_file_map_type
package_dir_map_type::const_iterator const_package_dir_map_iterator
std::map< std::string, int > fcn_file_map_type
std::map< std::string, dir_info > package_dir_map_type
fcn_file_map_type::iterator fcn_file_map_iterator
method_file_map_type method_file_map
dir_info(const dir_info &)=default
file_info(const std::string &d, int t)
file_info(const file_info &fi)
std::string m_package_name
package_info(const package_info &l)
private_fcn_map_type private_fcn_map
~package_info(void)=default
void add(const dir_info &di, bool at_end, bool updating)
package_info(const std::string &package_name="")
method_map_type method_map
std::list< std::string > dir_list
abs_dir_cache_type::const_iterator const_abs_dir_cache_iterator
std::string find_private_fcn(const std::string &dir, const std::string &fcn, const std::string &pack_name="")
static std::string sys_path
std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
std::string m_command_line_path
std::set< std::string > init_dirs
file_info_list_type::const_iterator const_file_info_list_iterator
package_info & get_package(const std::string &name) const
load_path(const load_path &)=delete
std::string find_fcn_file(const std::string &fcn, const std::string &pack_name="")
std::map< std::string, fcn_map_type > method_map_type
method_map_type::iterator method_map_iterator
package_map_type::const_iterator const_package_map_iterator
std::function< void(const std::string &)> get_add_hook(void)
std::string find_mex_file(const std::string &fcn, const std::string &pack_name="")
bool find_package(const std::string &package_name) const
private_fcn_map_type::iterator private_fcn_map_iterator
std::string find_fcn(const std::string &fcn, const std::string &pack_name="")
std::string find_oct_file(const std::string &fcn, const std::string &pack_name="")
fcn_map_type::iterator fcn_map_iterator
void set_remove_hook(const std::function< void(const std::string &)> &f)
std::list< std::string > methods(const std::string &class_name, const std::string &pack_name="")
std::map< std::string, dir_info > abs_dir_cache_type
std::map< std::string, package_info > package_map_type
std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name="")
std::map< std::string, dir_info::fcn_file_map_type > private_fcn_map_type
std::map< std::string, file_info_list_type > fcn_map_type
private_fcn_map_type::const_iterator const_private_fcn_map_iterator
std::string system_path(void) const
dir_info_list_type dir_info_list
std::string find_method(const std::string &class_name, const std::string &meth, const std::string &pack_name="")
file_info_list_type::iterator file_info_list_iterator
std::string get_command_line_path(void) const
abs_dir_cache_type::iterator abs_dir_cache_iterator
static abs_dir_cache_type abs_dir_cache
dir_info_list_type::const_iterator const_dir_info_list_iterator
std::function< void(const std::string &)> get_remove_hook(void)
dir_info_list_type::iterator dir_info_list_iterator
interpreter & m_interpreter
package_info top_level_package
method_map_type::const_iterator const_method_map_iterator
package_map_type::iterator package_map_iterator
std::function< void(const std::string &)> add_hook
std::list< dir_info > dir_info_list_type
void set_add_hook(const std::function< void(const std::string &)> &f)
package_map_type package_map
fcn_map_type::const_iterator const_fcn_map_iterator
std::function< void(const std::string &)> remove_hook
void set_command_line_path(const std::string &p)
std::list< file_info > file_info_list_type
static std::list< std::string > find_first_of(const std::string &path, const std::list< std::string > &names, bool all)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
static void initialize(void)
static double f(double k, double l_nu, double c_pm)
load_path::dir_info::fcn_file_map_type get_fcn_files(const std::string &d)
std::string genpath(const std::string &dirname, const string_vector &skip)
~class_info(void)=default
fcn_file_map_type method_file_map
class_info(const class_info &ci)
fcn_file_map_type private_file_map