GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
cdef-manager.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2012-2025 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-fwd.h"
33#include "cdef-method.h"
34#include "cdef-package.h"
35#include "cdef-property.h"
36#include "ov-builtin.h"
37
39
40class interpreter;
41
42class OCTINTERP_API cdef_manager
43{
44public:
45
46 OCTINTERP_API cdef_manager (interpreter& interp);
47
48 OCTAVE_DISABLE_COPY_MOVE (cdef_manager)
49
50 ~cdef_manager () = default;
51
52 OCTINTERP_API cdef_class
53 find_class (const std::string& name, bool error_if_not_found = true,
54 bool load_if_not_found = true);
55
56 OCTINTERP_API octave_value
57 find_method_symbol (const std::string& method_name,
58 const std::string& class_name);
59
60 OCTINTERP_API cdef_package
61 find_package (const std::string& name, bool error_if_not_found = true,
62 bool load_if_not_found = true);
63
64 OCTINTERP_API octave_value
65 find_package_symbol (const std::string& pack_name);
66
67 void register_class (const cdef_class& cls)
68 {
69 m_all_classes[cls.get_name ()] = cls;
70 }
71
72 void unregister_class (const cdef_class& cls)
73 {
74 m_all_classes.erase(cls.get_name ());
75 }
76
78 {
79 m_all_packages[pkg.get_name ()] = pkg;
80 }
81
83 {
84 m_all_packages.erase (pkg.get_name ());
85 }
86
87 const cdef_class& meta_class () const { return m_meta_class; }
88 const cdef_class& meta_property () const { return m_meta_property; }
89 const cdef_class& meta_method () const { return m_meta_method; }
90 const cdef_class& meta_package () const { return m_meta_package; }
91
92 const cdef_package& meta () const { return m_meta; }
93
94 OCTINTERP_API cdef_class
95 make_class (const std::string& name,
96 const std::list<cdef_class>& super_list = std::list<cdef_class> ());
97
98 OCTINTERP_API cdef_class
99 make_class (const std::string& name, const cdef_class& super);
100
101 OCTINTERP_API cdef_class
102 make_meta_class (const std::string& name, const cdef_class& super);
103
104 OCTINTERP_API cdef_property
105 make_property (const cdef_class& cls, const std::string& name,
106 const octave_value& get_method = Matrix (),
107 const std::string& get_access = "public",
108 const octave_value& set_method = Matrix (),
109 const std::string& set_access = "public");
110
111 OCTINTERP_API cdef_property
112 make_attribute (const cdef_class& cls, const std::string& name);
113
114 OCTINTERP_API cdef_method
115 make_method (const cdef_class& cls, const std::string& name,
116 const octave_value& fcn,
117 const std::string& m_access = "public",
118 bool is_static = false);
119
120 OCTINTERP_API cdef_method
121 make_method (const cdef_class& cls, const std::string& name,
123 const std::string& m_access = "public",
124 bool is_static = false);
125
126 OCTINTERP_API cdef_method
127 make_method (const cdef_class& cls, const std::string& name,
129 const std::string& m_access = "public",
130 bool is_static = false);
131
132 OCTINTERP_API cdef_package
133 make_package (const std::string& nm, const std::string& parent = "");
134
135 OCTINTERP_API octave_value
136 find_method (const std::string& class_name,
137 const std::string& name) const;
138
139private:
140
141 interpreter& m_interpreter;
142
143 // All registered/loaded classes
144 std::map<std::string, cdef_class> m_all_classes;
145
146 // All registered/loaded packages
147 std::map<std::string, cdef_package> m_all_packages;
148
149 cdef_class m_meta_class;
150 cdef_class m_meta_property;
151 cdef_class m_meta_method;
152 cdef_class m_meta_package;
153
154 cdef_package m_meta;
155};
156
157OCTAVE_END_NAMESPACE(octave)
158
159#endif
std::string get_name() const
Definition cdef-class.h:329
~cdef_manager()=default
void unregister_package(const cdef_package &pkg)
const cdef_class & meta_package() const
const cdef_package & meta() const
const cdef_class & meta_property() const
const cdef_class & meta_method() const
void unregister_class(const cdef_class &cls)
void register_package(const cdef_package &pkg)
const cdef_class & meta_class() const
void register_class(const cdef_class &cls)
std::string get_name() const
octave_value_list(* fcn)(const octave_value_list &, int)
Definition ov-builtin.h:61
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition ov-builtin.h:58
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn