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);
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 (m_package_map.find (package_name) != m_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 read_dir_config (
const std::string& dir)
const;
196 void execute_pkg_add (
const std::string& dir);
197 void execute_pkg_del (
const std::string& dir);
201 if (m_command_line_path.empty ())
202 m_command_line_path = p;
209 return m_command_line_path;
214 static const int M_FILE = 1;
215 static const int OCT_FILE = 2;
216 static const int MEX_FILE = 4;
233 class_info (
void) : method_file_map (), private_file_map () { }
236 : method_file_map (ci.method_file_map),
237 private_file_map (ci.private_file_map)
274 : dir_name (
d), abs_dir_name (), is_relative (false),
275 dir_mtime (), dir_time_last_checked (), all_files (), fcn_files (),
276 private_file_map (), method_file_map (), package_dir_map ()
300 bool is_package (
const std::string& name)
const;
306 void get_file_list (
const std::string&
d);
308 void get_private_file_map (
const std::string&
d);
310 void get_method_file_map (
const std::string&
d,
311 const std::string& class_name);
313 void get_package_dir (
const std::string&
d,
314 const std::string& package_name);
323 file_info (
const std::string&
d,
int t) : dir_name (
d), types (t) { }
326 : dir_name (
fi.dir_name), types (
fi.types) { }
334 dir_name =
fi.dir_name;
380 typedef std::map<std::string, dir_info::fcn_file_map_type>
397 : m_package_name (package_name), m_dir_list (), m_fcn_map (),
398 m_private_fcn_map (),
403 : m_package_name (l.m_package_name), m_dir_list (l.m_dir_list),
404 m_private_fcn_map (l.m_private_fcn_map), m_method_map (l.m_method_map)
428 m_dir_list.push_front (di.
dir_name);
430 add_to_fcn_map (di, at_end, updating);
432 add_to_private_fcn_map (di);
434 add_to_method_map (di, at_end);
437 void move (
const dir_info& di,
bool at_end);
447 m_private_fcn_map.clear ();
449 m_method_map.clear ();
452 void display (std::ostream& out)
const;
455 find_fcn (
const std::string& fcn, std::string& dir_name,
456 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
459 find_private_fcn (
const std::string& dir,
const std::string& fcn,
460 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
463 find_method (
const std::string& class_name,
const std::string& meth,
464 std::string& dir_name,
465 int type = M_FILE | OCT_FILE | MEX_FILE)
const;
467 std::list<std::string> methods (
const std::string& class_name)
const;
469 void overloads (
const std::string& meth, std::list<std::string>& l)
const;
475 void add_to_fcn_map (
const dir_info& di,
bool at_end,
bool updating);
477 void add_to_private_fcn_map (
const dir_info& di);
479 void add_to_method_map (
const dir_info& di,
bool at_end);
481 void move_fcn_map (
const std::string& dir,
484 void move_method_map (
const std::string& dir,
bool at_end);
486 void remove_fcn_map (
const std::string& dir,
489 void remove_private_fcn_map (
const std::string& dir);
491 void remove_method_map (
const std::string& dir);
493 bool check_file_type (std::string& fname,
int type,
int possible_types,
494 const std::string& fcn,
const char *who)
const;
496 void print_types (std::ostream& os,
int types)
const;
498 void print_fcn_list (std::ostream& os,
522 void execute_pkg_add_or_del (
const std::string& dir,
523 const std::string& script_file);
528 bool contains (
const std::string& dir)
const;
532 void move (
const dir_info& di,
bool at_end,
const std::string& pname =
"");
534 void remove (
const dir_info& di,
const std::string& pname =
"");
536 void add (
const std::string& dir,
bool at_end,
bool warn);
538 void add (
const dir_info& di,
bool at_end,
const std::string& pname =
"",
539 bool updating =
false);
541 bool is_package (
const std::string& name)
const;
545 if (! name.empty () && is_package (name))
549 if (l == m_package_map.end ())
550 l = m_package_map.insert (m_package_map.end (),
551 package_map_type::value_type (name,
package_info (name)));
556 return m_top_level_package;
559 string_vector get_file_list (
const dir_info::fcn_file_map_type& lst)
const;
561 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
package_dir_map_type package_dir_map
dir_info(const std::string &d)
package_dir_map_type::iterator package_dir_map_iterator
sys::time dir_time_last_checked
method_file_map_type::iterator method_file_map_iterator
std::map< std::string, dir_info > package_dir_map_type
fcn_file_map_type::iterator fcn_file_map_iterator
dir_info(const dir_info &)=default
std::map< std::string, int > fcn_file_map_type
fcn_file_map_type::const_iterator const_fcn_file_map_iterator
method_file_map_type::const_iterator const_method_file_map_iterator
std::map< std::string, class_info > method_file_map_type
fcn_file_map_type private_file_map
package_dir_map_type::const_iterator const_package_dir_map_iterator
method_file_map_type method_file_map
file_info(const file_info &fi)
file_info(const std::string &d, int t)
method_map_type m_method_map
void add(const dir_info &di, bool at_end, bool updating)
package_info(const std::string &package_name="")
std::string m_package_name
private_fcn_map_type m_private_fcn_map
~package_info(void)=default
std::list< std::string > m_dir_list
package_info(const package_info &l)
std::string find_mex_file(const std::string &fcn, const std::string &pack_name="")
private_fcn_map_type::iterator private_fcn_map_iterator
load_path(const load_path &)=delete
abs_dir_cache_type::iterator abs_dir_cache_iterator
void set_add_hook(const std::function< void(const std::string &)> &f)
static std::string s_sys_path
std::list< file_info > file_info_list_type
method_map_type::const_iterator const_method_map_iterator
std::function< void(const std::string &)> get_add_hook(void)
dir_info_list_type::const_iterator const_dir_info_list_iterator
std::map< std::string, dir_info::fcn_file_map_type > private_fcn_map_type
std::string find_oct_file(const std::string &fcn, const std::string &pack_name="")
std::list< dir_info > dir_info_list_type
std::map< std::string, fcn_map_type > method_map_type
void set_remove_hook(const std::function< void(const std::string &)> &f)
bool find_package(const std::string &package_name) const
std::function< void(const std::string &)> get_remove_hook(void)
std::string find_method(const std::string &class_name, const std::string &meth, const std::string &pack_name="")
dir_info_list_type m_dir_info_list
std::map< std::string, dir_info > abs_dir_cache_type
std::set< std::string > m_init_dirs
static abs_dir_cache_type s_abs_dir_cache
dir_info_list_type::iterator dir_info_list_iterator
file_info_list_type::const_iterator const_file_info_list_iterator
std::function< void(const std::string &)> add_hook
std::string find_fcn(const std::string &fcn, const std::string &pack_name="")
interpreter & m_interpreter
std::map< std::string, package_info > package_map_type
package_map_type m_package_map
std::string system_path(void) const
package_info m_top_level_package
std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name="")
std::string find_private_fcn(const std::string &dir, const std::string &fcn, const std::string &pack_name="")
std::string get_command_line_path(void) const
fcn_map_type::const_iterator const_fcn_map_iterator
abs_dir_cache_type::const_iterator const_abs_dir_cache_iterator
std::string find_fcn_file(const std::string &fcn, const std::string &pack_name="")
std::list< std::string > methods(const std::string &class_name, const std::string &pack_name="")
package_info & get_package(const std::string &name)
package_map_type::iterator package_map_iterator
std::string m_command_line_path
private_fcn_map_type::const_iterator const_private_fcn_map_iterator
void set_command_line_path(const std::string &p)
package_map_type::const_iterator const_package_map_iterator
method_map_type::iterator method_map_iterator
fcn_map_type::iterator fcn_map_iterator
std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
std::function< void(const std::string &)> remove_hook
file_info_list_type::iterator file_info_list_iterator
std::map< std::string, file_info_list_type > fcn_map_type
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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
F77_RET_T const F77_DBLE const F77_DBLE * f
load_path::dir_info::fcn_file_map_type get_fcn_files(const std::string &d)
std::string genpath(const std::string &dir, const string_vector &skip="private")
static void initialize(void)
class_info(const class_info &ci)
~class_info(void)=default
fcn_file_map_type method_file_map
fcn_file_map_type private_file_map