46 typedef std::map<std::string, octave_value>::const_iterator
56 fcn_info_rep (
const std::string& nm)
57 : name (nm), package_name (), local_functions (),
58 private_functions (), class_constructors (), class_methods (),
59 cmdline_function (), autoload_function (), function_on_path (),
62 std::size_t pos = name.rfind (
'.');
64 if (pos != std::string::npos)
66 package_name = name.substr (0, pos);
67 name = name.substr (pos+1);
71 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (fcn_info_rep)
73 ~fcn_info_rep () =
default;
75 octave_value install_local_function (
const std::string& file_name);
77 octave_value load_private_function (
const std::string& dir_name);
81 octave_value load_class_method (
const std::string& dispatch_type);
90 octave_value find_private_function (
const std::string& dir_name);
92 octave_value find_method (
const std::string& dispatch_type);
102 bool is_user_function_defined ()
const
104 return function_on_path.is_defined ();
110 return find (search_scope, args);
115 cmdline_function =
f;
119 const std::string& file_name)
121 local_functions[file_name] =
f;
126 function_on_path =
f;
131 built_in_function =
f;
134 void install_built_in_dispatch (
const std::string& klass);
136 template <
typename T>
138 clear_map (std::map<T, octave_value>& map,
bool force =
false)
140 auto p = map.begin ();
142 while (p != map.end ())
144 if (force || ! p->second.islocked ())
151 void clear_autoload_function (
bool force =
false)
153 if (force || ! autoload_function.islocked ())
159 void clear_user_function (
bool force =
false)
161 clear_autoload_function (force);
163 if (force || ! function_on_path.islocked ())
166 if (force || ! cmdline_function.islocked ())
170 void clear_mex_function ()
172 if (function_on_path.is_mex_function ())
173 clear_user_function ();
176 void clear_package ()
178 package = octave_value ();
181 void clear (
bool force =
false)
183 clear_map (local_functions, force);
184 clear_map (private_functions, force);
185 clear_map (class_constructors, force);
186 clear_map (class_methods, force);
188 clear_autoload_function (force);
189 clear_user_function (force);
195 std::string full_name ()
const
197 if (package_name.empty ())
200 return package_name +
'.' + name;
205 std::string package_name;
208 std::map<std::string, octave_value> local_functions;
211 std::map<std::string, octave_value> private_functions;
214 std::map<std::string, octave_value> class_constructors;
217 std::map<std::string, octave_value> class_methods;
240 : m_rep (new fcn_info_rep (nm)) { }
251 return m_rep->find (search_scope, args);
257 return m_rep->builtin_find (search_scope);
262 return m_rep->find_scoped_function (search_scope);
267 return m_rep->find_private_function (dir_name);
272 return m_rep->find_method (dispatch_type);
277 return m_rep->built_in_function;
282 return m_rep->cmdline_function;
287 return m_rep->find_autoload ();
293 return m_rep->find_user_function ();
298 return m_rep->is_user_function_defined ();
305 return m_rep->find_function (search_scope, args);
310 m_rep->install_cmdline_function (
f);
314 const std::string& file_name)
316 m_rep->install_local_function (
f, file_name);
321 m_rep->install_user_function (
f);
326 m_rep->install_built_in_function (
f);
331 m_rep->install_built_in_dispatch (klass);
334 void clear (
bool force =
false) { m_rep->clear (force); }
338 m_rep->clear_user_function (force);
343 m_rep->clear_autoload_function (force);
352 std::shared_ptr<fcn_info_rep> m_rep;