26 #if ! defined (octave_cdef_class_h)
27 #define octave_cdef_class_h 1
29 #include "octave-config.h"
66 OCTINTERP_API cdef_class_rep (
const std::list<cdef_class>& superclasses);
68 cdef_class_rep& operator = (
const cdef_class_rep&) =
delete;
70 ~cdef_class_rep () =
default;
74 bool is_class ()
const {
return true; }
76 std::string get_name ()
const
77 {
return get (
"Name").string_value (); }
79 void set_name (
const std::string& nm) { put (
"Name", nm); }
81 bool is_abstract ()
const {
return get (
"Abstract").bool_value (); }
83 bool is_sealed ()
const {
return get (
"Sealed").bool_value (); }
86 find_method (
const std::string& nm,
bool local =
false);
92 get_methods (
bool include_ctor);
94 OCTINTERP_API std::map<std::string, cdef_method>
95 get_method_map (
bool only_inherited,
bool include_ctor);
97 OCTINTERP_API
cdef_property find_property (
const std::string& nm);
99 OCTINTERP_API
void install_property (
const cdef_property& prop);
101 OCTINTERP_API
Cell get_properties (
int mode);
103 OCTINTERP_API std::map<std::string, cdef_property>
104 get_property_map (
int mode);
108 void set_directory (
const std::string& dir) { m_directory = dir; }
110 std::string get_directory ()
const {
return m_directory; }
112 OCTINTERP_API
void delete_object (
const cdef_object& obj);
115 meta_subsref (
const std::string& type,
116 const std::list<octave_value_list>& idx,
int nargout);
118 OCTINTERP_API
void meta_release ();
120 bool meta_accepts_postfix_index (
char type)
const
122 return (type ==
'(' || type ==
'.');
125 OCTINTERP_API
octave_value get_method (
const std::string& name)
const;
134 OCTINTERP_API
void initialize_object (
cdef_object& obj);
139 void mark_as_handle_class () { m_handle_class =
true; }
141 bool is_handle_class ()
const {
return m_handle_class; }
153 m_method_map.clear ();
154 m_property_map.clear ();
160 void mark_as_meta_class () { m_meta =
true; }
162 bool is_meta_class ()
const {
return m_meta; }
164 void file_name (
const std::string& nm) { m_file_name = nm; }
166 std::string
file_name ()
const {
return m_file_name; }
170 OCTINTERP_API
void load_all_methods ();
172 OCTINTERP_API
void find_names (std::set<std::string>& names,
bool all);
175 find_properties (std::map<std::string, cdef_property>& props,
179 find_methods (std::map<std::string, cdef_method>& meths,
180 bool only_inherited,
bool include_ctor =
false);
191 std::string m_directory;
193 std::string m_file_name;
197 std::map<std::string, cdef_method> m_method_map;
201 std::map<std::string, cdef_property> m_property_map;
216 std::list<cdef_class> m_implicit_ctor_list;
224 typedef std::map<std::string, cdef_method>::iterator method_iterator;
225 typedef std::map<std::string, cdef_method>::const_iterator method_const_iterator;
226 typedef std::map<std::string, cdef_property>::iterator property_iterator;
227 typedef std::map<std::string, cdef_property>::const_iterator property_const_iterator;
229 cdef_class_rep (
const cdef_class_rep& c) =
default;
239 const std::list<cdef_class>& superclasses)
242 get_rep ()->set_name (nm);
252 error (
"internal error: invalid assignment from %s to meta.class object",
253 class_name ().c_str ());
266 find_method (
const std::string& nm,
bool local =
false);
270 get_rep ()->install_method (meth);
275 return get_rep ()->get_methods (include_ctor);
278 std::map<std::string, cdef_method>
281 return get_rep ()->get_method_map (only_inherited, include_ctor);
284 OCTINTERP_API
cdef_property find_property (
const std::string& nm);
288 get_rep ()->install_property (prop);
293 return get_rep ()->get_properties (mode);
296 std::map<std::string, cdef_property>
299 return get_rep ()->get_property_map (mode);
306 bool is_sealed ()
const {
return get_rep ()->is_sealed (); }
310 get_rep ()->set_directory (dir);
315 return get_rep ()->get_directory ();
318 std::string
get_name ()
const {
return get_rep ()->get_name (); }
320 bool is_builtin ()
const {
return get_directory ().empty (); }
324 get_rep ()->delete_object (obj);
349 bool is_at_folder =
false);
353 return get_rep ()->get_method (nm);
358 return get_rep ()->get_method (ln);
361 OCTINTERP_API
octave_value get_method_function (
const std::string& nm);
365 return get_method_function (get_name ());
370 return get_rep ()->construct (args);
375 return get_rep ()->construct_object (args);
380 get_rep ()->initialize_object (obj);
385 get_rep ()->run_constructor (obj, args);
390 get_rep ()->mark_as_handle_class ();
395 return get_rep ()->is_handle_class ();
402 void file_name (
const std::string& nm) { get_rep ()->file_name (nm); }
404 std::string
file_name ()
const {
return get_rep ()->file_name (); }
417 cdef_class_rep * get_rep ()
422 const cdef_class_rep * get_rep ()
const
439 return (clsa.get_rep () == clsb.get_rep ());
445 return ! (clsa == clsb);
453 return clsa.get_rep () < clsb.get_rep ();
459 return get_rep ()->find_method (nm, local);
465 return get_rep ()->find_property (nm);
468 OCTAVE_END_NAMESPACE(
octave)
bool operator==(const cdef_class &clsa, const cdef_class &clsb)
bool operator!=(const cdef_class &clsa, const cdef_class &clsb)
bool operator<(const cdef_class &clsa, const cdef_class &clsb)
cdef_method find_method(const std::string &nm, bool local=false)
void mark_as_meta_class()
octave_value construct(const octave_value_list &args)
void install_property(const cdef_property &prop)
cdef_class(const std::string &nm, const std::list< cdef_class > &superclasses)
void mark_as_handle_class()
void install_method(const cdef_method &meth)
void run_constructor(cdef_object &obj, const octave_value_list &args)
octave_value get_method(int ln) const
octave_value get_method(const std::string &nm) const
string_vector get_names()
std::map< std::string, cdef_property > get_property_map(int mode=property_normal)
std::map< std::string, cdef_method > get_method_map(bool only_inherited=false, bool include_ctor=false)
octave_value get_constructor_function()
std::string get_directory() const
cdef_class(const cdef_class &cls)
std::string get_name() const
void file_name(const std::string &nm)
std::string file_name() const
void initialize_object(cdef_object &obj)
void delete_object(const cdef_object &obj)
bool is_handle_class() const
bool is_meta_class() const
cdef_property find_property(const std::string &nm)
friend void install_classdef(octave::interpreter &interp)
Cell get_properties(int mode=property_normal)
cdef_object construct_object(const octave_value_list &args)
cdef_class(const cdef_object &obj)
Cell get_methods(bool include_ctor=false)
void set_directory(const std::string &dir)
const cdef_object_rep * get_rep() const
cdef_object & operator=(const cdef_object &obj)
octave_value make_meta_class(interpreter &interp, bool is_at_folder=false)
std::string file_name() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)