diff libinterp/corefcn/interpreter-private.cc @ 23438:d24d01273bd0

eliminate load-path singleton * load-path.h, load-path.cc (class load_path): Don't use singleton idiom. * interpreter-private.h, interpreter-private.cc: New files. * interpreter.cc, interpreter.h (interpreter::m_load_path): New data member. Manage initialization of load_path in interpreter class. (interpreter::get_load_path): New method. Change all uses of static load_path methods to use global load_path object instead.
author John W. Eaton <jwe@octave.org>
date Thu, 20 Apr 2017 00:20:59 -0400
parents
children 232c8d69d934
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/interpreter-private.cc	Thu Apr 20 00:20:59 2017 -0400
@@ -0,0 +1,51 @@
+/*
+
+Copyright (C) 2017 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+Octave is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
+#include <string>
+
+#include "error.h"
+#include "interpreter-private.h"
+#include "octave.h"
+
+namespace octave
+{
+  interpreter& __get_interpreter__ (const std::string& who)
+  {
+    interpreter *interp = octave::application::the_interpreter ();
+
+    if (! interp)
+      error ("%s: interpreter context missing", who.c_str ());
+
+    return *interp;
+  }
+
+  load_path& __get_load_path__ (const std::string& who)
+  {
+    interpreter& interp = __get_interpreter__ (who);
+
+    return interp.get_load_path ();
+  }
+}