GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
cdef-manager.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2012-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_cdef_manager_h)
27 #define octave_cdef_manager_h 1
28 
29 #include "octave-config.h"
30 
31 #include "cdef-class.h"
32 #include "cdef-method.h"
33 #include "cdef-package.h"
34 #include "cdef-property.h"
35 #include "ov-builtin.h"
36 
37 namespace octave
38 {
39  class interpreter;
40 
42  {
43  public:
44 
45  cdef_manager (interpreter& interp);
46 
47  // No copying!
48 
49  cdef_manager (const cdef_manager&) = delete;
50 
52 
53  ~cdef_manager (void) = default;
54 
55  cdef_class find_class (const std::string& name,
56  bool error_if_not_found = true,
57  bool load_if_not_found = true);
58 
59  octave_value find_method_symbol (const std::string& method_name,
60  const std::string& class_name);
61 
62  cdef_package find_package (const std::string& name,
63  bool error_if_not_found = true,
64  bool load_if_not_found = true);
65 
66  octave_value find_package_symbol (const std::string& pack_name);
67 
68  void register_class (const cdef_class& cls)
69  {
70  m_all_classes[cls.get_name ()] = cls;
71  }
72 
73  void unregister_class (const cdef_class& cls)
74  {
75  m_all_classes.erase(cls.get_name ());
76  }
77 
78  void register_package (const cdef_package& pkg)
79  {
80  m_all_packages[pkg.get_name ()] = pkg;
81  }
82 
83  void unregister_package (const cdef_package& pkg)
84  {
85  m_all_packages.erase (pkg.get_name ());
86  }
87 
88  const cdef_class& meta_class (void) const { return m_meta_class; }
89  const cdef_class& meta_property (void) const { return m_meta_property; }
90  const cdef_class& meta_method (void) const { return m_meta_method; }
91  const cdef_class& meta_package (void) const { return m_meta_package; }
92 
93  const cdef_package& meta (void) const { return m_meta; }
94 
95  cdef_class make_class (const std::string& name,
96  const std::list<cdef_class>& super_list = std::list<cdef_class> ());
97 
98  cdef_class make_class (const std::string& name, const cdef_class& super);
99 
100  cdef_class make_meta_class (const std::string& name,
101  const cdef_class& super);
102 
104  const std::string& name,
105  const octave_value& get_method = Matrix (),
106  const std::string& get_access = "public",
107  const octave_value& set_method = Matrix (),
108  const std::string& set_access = "public");
109 
111  const std::string& name);
112 
113  cdef_method make_method (const cdef_class& cls,
114  const std::string& name,
115  const octave_value& fcn,
116  const std::string& m_access = "public",
117  bool is_static = false);
118 
119  cdef_method make_method (const cdef_class& cls,
120  const std::string& name,
122  const std::string& m_access = "public",
123  bool is_static = false);
124 
125  cdef_method make_method (const cdef_class& cls,
126  const std::string& name,
128  const std::string& m_access = "public",
129  bool is_static = false);
130 
131  cdef_package make_package (const std::string& nm,
132  const std::string& parent = "");
133 
134  octave_value find_method (const std::string& class_name,
135  const std::string& name) const;
136 
137  private:
138 
140 
141  // All registered/loaded classes
142  std::map<std::string, cdef_class> m_all_classes;
143 
144  // All registered/loaded packages
145  std::map<std::string, cdef_package> m_all_packages;
146 
151 
153  };
154 }
155 
156 #endif
Definition: dMatrix.h:42
std::string get_name(void) const
Definition: cdef-class.h:304
octave_value find_method_symbol(const std::string &method_name, const std::string &class_name)
std::map< std::string, cdef_package > m_all_packages
Definition: cdef-manager.h:145
cdef_class m_meta_class
Definition: cdef-manager.h:147
const cdef_package & meta(void) const
Definition: cdef-manager.h:93
cdef_class find_class(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
interpreter & m_interpreter
Definition: cdef-manager.h:139
std::map< std::string, cdef_class > m_all_classes
Definition: cdef-manager.h:142
cdef_property make_property(const cdef_class &cls, const std::string &name, const octave_value &get_method=Matrix(), const std::string &get_access="public", const octave_value &set_method=Matrix(), const std::string &set_access="public")
cdef_class m_meta_method
Definition: cdef-manager.h:149
const cdef_class & meta_package(void) const
Definition: cdef-manager.h:91
cdef_manager(const cdef_manager &)=delete
void register_package(const cdef_package &pkg)
Definition: cdef-manager.h:78
cdef_class make_meta_class(const std::string &name, const cdef_class &super)
void unregister_class(const cdef_class &cls)
Definition: cdef-manager.h:73
cdef_package make_package(const std::string &nm, const std::string &parent="")
cdef_class m_meta_package
Definition: cdef-manager.h:150
cdef_manager(interpreter &interp)
void register_class(const cdef_class &cls)
Definition: cdef-manager.h:68
octave_value find_package_symbol(const std::string &pack_name)
cdef_method make_method(const cdef_class &cls, const std::string &name, const octave_value &fcn, const std::string &m_access="public", bool is_static=false)
const cdef_class & meta_property(void) const
Definition: cdef-manager.h:89
cdef_class m_meta_property
Definition: cdef-manager.h:148
const cdef_class & meta_method(void) const
Definition: cdef-manager.h:90
cdef_package m_meta
Definition: cdef-manager.h:152
cdef_class make_class(const std::string &name, const std::list< cdef_class > &super_list=std::list< cdef_class >())
cdef_package find_package(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
void unregister_package(const cdef_package &pkg)
Definition: cdef-manager.h:83
cdef_manager & operator=(const cdef_manager &)=delete
~cdef_manager(void)=default
cdef_property make_attribute(const cdef_class &cls, const std::string &name)
const cdef_class & meta_class(void) const
Definition: cdef-manager.h:88
octave_value find_method(const std::string &class_name, const std::string &name) const
std::string get_name(void) const
Definition: cdef-package.h:205
octave_value_list(* fcn)(const octave_value_list &, int)
Definition: ov-builtin.h:63
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition: ov-builtin.h:60
QString name