File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed
plugins/OGF/gompy/interpreter Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ namespace OGF {
199199 PyDict_SetItemString (sys_modules, " gompy.gom" , py_gom);
200200 PyDict_SetItemString (sys_modules, " gompy.types" , py_meta_types);
201201 PyDict_SetItemString (sys_modules, " gompy.types.OGF" , py_OGF);
202+
202203 return ;
203204 }
204205
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ namespace OGF {
107107 if (!abstract) {
108108 set_factory (new FactoryMetaClass (this ));
109109 }
110+ instance_ = nullptr ;
110111 }
111112
112113 MetaClass::MetaClass (
Original file line number Diff line number Diff line change @@ -299,6 +299,15 @@ namespace OGF {
299299 */
300300 virtual bool is_subclass_of (const MetaClass* other) const ;
301301
302+ gom_properties:
303+ /* *
304+ * \brief For singletons, returns instance
305+ * \return the unique instance or nullptr if not already created
306+ */
307+ Object* get_instance () const {
308+ return instance_;
309+ }
310+
302311 public:
303312
304313 /* *
@@ -455,6 +464,13 @@ namespace OGF {
455464 */
456465 std::string get_doc () const override ;
457466
467+ /* *
468+ * \brief For singletons, sets instance
469+ * \param[in] object the unique instance or nullptr
470+ */
471+ void set_instance (Object* object) {
472+ instance_ = object;
473+ }
458474
459475 protected:
460476
@@ -525,6 +541,7 @@ namespace OGF {
525541 bool abstract_;
526542 Factory_var factory_;
527543 friend class ::OGF::MetaConstructor;
544+ Object* instance_; // For singletons
528545 };
529546
530547 /* *
Original file line number Diff line number Diff line change @@ -69,9 +69,13 @@ namespace OGF {
6969 application_(nullptr ) {
7070 Grob::scene_graph_ = this ;
7171 SceneGraphLibrary::instance ()->set_scene_graph (this , transfer_ownership);
72+ Any value;
73+ value.set_value (this );
74+ meta_class ()->set_instance (this );
7275 }
7376
7477 SceneGraph::~SceneGraph () {
78+ meta_class ()->set_instance (nullptr );
7579 }
7680
7781 void SceneGraph::set_scene_graph_shader_manager (
You can’t perform that action at this time.
0 commit comments